• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

TypeScript polyfills.assign函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了TypeScript中@ember/polyfills.assign函数的典型用法代码示例。如果您正苦于以下问题:TypeScript assign函数的具体用法?TypeScript assign怎么用?TypeScript assign使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了assign函数的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。

示例1: assign

(() => { /* assign */
    assign({}, { a: 'b'});
    assign({}, { a: 'b'}).a; // $ExpectType string
    assign({ a: 6 }, { a: 'b'}).a; // $ExpectType string
    assign({ a: 6 }, {}).a; // $ExpectType number
    assign({ b: 6 }, {}).a; // $ExpectError
    assign({}, { b: 6 }, {}).b; // $ExpectType number
    assign({ a: 'hello' }, { b: 6 }, {}).a; // $ExpectType string
    assign({ a: 'hello' }, { b: 6 }, { a: true }).a; // $ExpectType boolean
    assign({ a: 'hello' }, '', { a: true }).a; // $ExpectError
    assign({ d: ['gobias industries'] }, { a: 'hello' }, { b: 6 }, { a: true }).d; // $ExpectType string[]
})();
开发者ID:AlexGalays,项目名称:DefinitelyTyped,代码行数:12,代码来源:ember__polyfills-tests.ts


示例2: state

  /*
    Ember Data has 3 buckets for storing the value of an attribute on an internalModel.

    `_data` holds all of the attributes that have been acknowledged by
    a backend via the adapter. When rollbackAttributes is called on a model all
    attributes will revert to the record's state in `_data`.

    `_attributes` holds any change the user has made to an attribute
    that has not been acknowledged by the adapter. Any values in
    `_attributes` are have priority over values in `_data`.

    `_inFlightAttributes`. When a record is being synced with the
    backend the values in `_attributes` are copied to
    `_inFlightAttributes`. This way if the backend acknowledges the
    save but does not return the new state Ember Data can copy the
    values from `_inFlightAttributes` to `_data`. Without having to
    worry about changes made to `_attributes` while the save was
    happenign.


    Changed keys builds a list of all of the values that may have been
    changed by the backend after a successful save.

    It does this by iterating over each key, value pair in the payload
    returned from the server after a save. If the `key` is found in
    `_attributes` then the user has a local changed to the attribute
    that has not been synced with the server and the key is not
    included in the list of changed keys.



    If the value, for a key differs from the value in what Ember Data
    believes to be the truth about the backend state (A merger of the
    `_data` and `_inFlightAttributes` objects where
    `_inFlightAttributes` has priority) then that means the backend
    has updated the value and the key is added to the list of changed
    keys.

    @method _changedKeys
    @private
  */
  /*
      TODO IGOR DAVID
      There seems to be a potential bug here, where we will return keys that are not
      in the schema
  */
  _changedKeys(updates) {
    let changedKeys: string[] = [];

    if (updates) {
      let original, i, value, key;
      let keys = Object.keys(updates);
      let length = keys.length;
      let hasAttrs = this.hasChangedAttributes();
      let attrs;
      if (hasAttrs) {
        attrs = this._attributes;
      }

      original = assign(Object.create(null), this._data, this.__inFlightAttributes);

      for (i = 0; i < length; i++) {
        key = keys[i];
        value = updates[key];

        // A value in _attributes means the user has a local change to
        // this attributes. We never override this value when merging
        // updates from the backend so we should not sent a change
        // notification if the server value differs from the original.
        if (hasAttrs === true && attrs[key] !== undefined) {
          continue;
        }

        if (!isEqual(original[key], value)) {
          changedKeys.push(key);
        }
      }
    }

    return changedKeys;
  }
开发者ID:code0100fun,项目名称:data,代码行数:81,代码来源:record-data.ts


示例3: create

 static create(options: any) {
   if (options) {
     return super.create(assign({}, injections, options));
   } else {
     return super.create(injections);
   }
 }
开发者ID:GreatWizard,项目名称:ember.js,代码行数:7,代码来源:outlet.ts


示例4: buildMouseEvent

// eslint-disable-next-line require-jsdoc
function buildMouseEvent(type: MouseEventType, options: any = {}) {
  let event;
  let eventOpts: any = assign({ view: window }, DEFAULT_EVENT_OPTIONS, options);
  if (MOUSE_EVENT_CONSTRUCTOR) {
    event = new MouseEvent(type, eventOpts);
  } else {
    try {
      event = document.createEvent('MouseEvents');
      event.initMouseEvent(
        type,
        eventOpts.bubbles,
        eventOpts.cancelable,
        window,
        eventOpts.detail,
        eventOpts.screenX,
        eventOpts.screenY,
        eventOpts.clientX,
        eventOpts.clientY,
        eventOpts.ctrlKey,
        eventOpts.altKey,
        eventOpts.shiftKey,
        eventOpts.metaKey,
        eventOpts.button,
        eventOpts.relatedTarget
      );
    } catch (e) {
      event = buildBasicEvent(type, options);
    }
  }

  return event;
}
开发者ID:switchfly,项目名称:ember-test-helpers,代码行数:33,代码来源:fire-event.ts


示例5: compileOptions

export default function compileOptions(_options: Partial<CompileOptions>): PrecompileOptions {
  let options = assign({ meta: {} }, _options, {
    customizeComponentName(tagname: string): string {
      return COMPONENT_NAME_SIMPLE_DASHERIZE_CACHE.get(tagname);
    },
  });

  // move `moduleName` into `meta` property
  if (options.moduleName) {
    let meta = options.meta;
    meta.moduleName = options.moduleName;
  }

  if (!options.plugins) {
    options.plugins = { ast: [...USER_PLUGINS, ...PLUGINS] };
  } else {
    let potententialPugins = [...USER_PLUGINS, ...PLUGINS];
    let providedPlugins = options.plugins.ast.map(plugin => wrapLegacyPluginIfNeeded(plugin));
    let pluginsToAdd = potententialPugins.filter(plugin => {
      return options.plugins!.ast.indexOf(plugin) === -1;
    });
    options.plugins.ast = providedPlugins.concat(pluginsToAdd);
  }

  return options;
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:26,代码来源:compile-options.ts


示例6: accumulateQueryParamDescriptors

function accumulateQueryParamDescriptors(_desc: QueryParam, accum: {}) {
  let desc: {} = _desc;
  let tmp: {};
  if (typeof desc === 'string') {
    tmp = {};
    tmp[desc] = { as: null };
    desc = tmp;
  }

  for (let key in desc) {
    if (!desc.hasOwnProperty(key)) {
      return;
    }

    let singleDesc = desc[key];
    if (typeof singleDesc === 'string') {
      singleDesc = { as: singleDesc };
    }

    tmp = accum[key] || { as: null, scope: 'model' };
    assign(tmp, singleDesc);

    accum[key] = tmp;
  }
}
开发者ID:Turbo87,项目名称:ember.js,代码行数:25,代码来源:utils.ts


示例7: queryParams

/**
  This is a helper to be used in conjunction with the link-to helper.
  It will supply url query parameters to the target route.

  Example

  ```handlebars
  {{#link-to 'posts' (query-params direction="asc")}}Sort{{/link-to}}
  ```

  @method query-params
  @for Ember.Templates.helpers
  @param {Object} hash takes a hash of query parameters
  @return {Object} A `QueryParams` object for `{{link-to}}`
  @public
*/
function queryParams({ positional, named }: CapturedArguments) {
  // tslint:disable-next-line:max-line-length
  assert(
    "The `query-params` helper only accepts hash parameters, e.g. (query-params queryParamPropertyName='foo') as opposed to just (query-params 'foo')",
    positional.value().length === 0
  );

  return new QueryParams(assign({}, named.value() as any));
}
开发者ID:GreatWizard,项目名称:ember.js,代码行数:25,代码来源:query-param.ts


示例8: assign

 return payload.errors.map(function(error) {
   if (isObject(error)) {
     const ret = assign({}, error);
     ret.status = `${error.status}`;
     return ret;
   } else {
     return {
       status: `${status}`,
       title: error
     };
   }
 });
开发者ID:knownasilya,项目名称:ember-ajax,代码行数:12,代码来源:normalize-error-response.ts


示例9: computed

  resolvedQueryParams: computed('queryParams', function computeLinkToComponentResolvedQueryParams(
    this: any
  ) {
    let resolvedQueryParams = {};
    let queryParams = get(this, 'queryParams');

    if (queryParams !== EMPTY_QUERY_PARAMS) {
      let { values } = queryParams;
      assign(resolvedQueryParams, values);
    }

    return resolvedQueryParams;
  }),
开发者ID:habdelra,项目名称:ember.js,代码行数:13,代码来源:link-to.ts


示例10: nextTickPromise

  return nextTickPromise().then(() => {
    if (!target) {
      throw new Error('Must pass an element or selector to `triggerKeyEvent`.');
    }

    let element = getElement(target);
    if (!element) {
      throw new Error(`Element not found when calling \`triggerKeyEvent('${target}', ...)\`.`);
    }

    if (!eventType) {
      throw new Error(`Must provide an \`eventType\` to \`triggerKeyEvent\``);
    }

    if (!isKeyboardEventType(eventType)) {
      let validEventTypes = KEYBOARD_EVENT_TYPES.join(', ');
      throw new Error(
        `Must provide an \`eventType\` of ${validEventTypes} to \`triggerKeyEvent\` but you passed \`${eventType}\`.`
      );
    }

    let props;
    if (typeof key === 'number') {
      props = { keyCode: key, which: key, key: keyFromKeyCodeAndModifiers(key, modifiers) };
    } else if (typeof key === 'string' && key.length !== 0) {
      let firstCharacter = key[0];
      if (firstCharacter !== firstCharacter.toUpperCase()) {
        throw new Error(
          `Must provide a \`key\` to \`triggerKeyEvent\` that starts with an uppercase character but you passed \`${key}\`.`
        );
      }

      if (isNumeric(key) && key.length > 1) {
        throw new Error(
          `Must provide a numeric \`keyCode\` to \`triggerKeyEvent\` but you passed \`${key}\` as a string.`
        );
      }

      let keyCode = keyCodeFromKey(key);
      props = { keyCode, which: keyCode, key };
    } else {
      throw new Error(`Must provide a \`key\` or \`keyCode\` to \`triggerKeyEvent\``);
    }

    let options = assign(props, modifiers);

    fireEvent(element, eventType, options);

    return settled();
  });
开发者ID:switchfly,项目名称:ember-test-helpers,代码行数:50,代码来源:trigger-key-event.ts



注:本文中的@ember/polyfills.assign函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
TypeScript polyfills._WeakSet类代码示例发布时间:2022-05-28
下一篇:
TypeScript mixin.create函数代码示例发布时间:2022-05-28
热门推荐
热门话题
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap