當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript array.A函數代碼示例

本文整理匯總了TypeScript中@ember/array.A函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript A函數的具體用法?TypeScript A怎麽用?TypeScript A使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了A函數的7個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: test

  test('it honors an explicit key', function(assert) {
    const logger = debugLogger('test:sample-key');
    logger('placeholder message');

    let [message] = A(log.args).get('lastObject') || [''];
    assert.ok(/test:sample-key/.test(message), 'Log entry should contain the namespace');
    assert.ok(/placeholder message/.test(message), 'Log entry should contain the message');
  });
開發者ID:salsify,項目名稱:ember-debug-logger,代碼行數:8,代碼來源:debug-logger-test.ts

示例2: getHeader

/**
 * Do a case-insensitive lookup of an HTTP header
 *
 * @function getHeader
 * @private
 */
export default function getHeader(
  headers: Headers | undefined,
  name: string | undefined
): string | undefined | null {
  if (isNone(headers) || isNone(name)) {
    return undefined;
  }

  const matchedKey = A(Object.keys(headers)).find(key => {
    return key.toLowerCase() === name.toLowerCase();
  });

  return matchedKey ? headers[matchedKey] : undefined;
}
開發者ID:knownasilya,項目名稱:ember-ajax,代碼行數:20,代碼來源:get-header.ts

示例3: items

 @computed('value.@each')
 get items() : MutableArray<string> {
   return this.value ? this.value : A();
 }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:4,代碼來源:component.ts

示例4: A

import { assertType } from './lib/assert';
import EmberObject from '@ember/object';
import EmberArray, { A } from '@ember/array';
import MutableArray from '@ember/array/mutable';

type Person = typeof Person.prototype;
const Person = EmberObject.extend({
    name: '',
    isHappy: false
});

const people = A([
    Person.create({ name: 'Yehuda', isHappy: true }),
    Person.create({ name: 'Majd', isHappy: false }),
]);

assertType<number>(people.get('length'));
assertType<Person>(people.get('lastObject'));
assertType<Person>(people.get('firstObject'));
assertType<boolean>(people.isAny('isHappy'));
assertType<boolean>(people.isAny('isHappy', 'false'));

const persons1: Person[] = people.filterBy('isHappy');
const persons2: MutableArray<Person> = people.filterBy('isHappy');
const persons3: Person[] = people.rejectBy('isHappy');
const persons4: MutableArray<Person> = people.rejectBy('isHappy');
const persons5: Person[] = people.filter((person) => person.get('name') === 'Yehuda');
const persons6: MutableArray<Person> = people.filter((person) => person.get('name') === 'Yehuda');

assertType<typeof people>(people.get('[]'));
assertType<Person>(people.get('[]').get('firstObject')); // $ExpectType any
開發者ID:AlexGalays,項目名稱:DefinitelyTyped,代碼行數:31,代碼來源:array.ts

示例5: A

 (function() {
   return A(records).every(record => record.hasOwnProperty('_internalModel') === true);
 })()
開發者ID:emberjs,項目名稱:data,代碼行數:3,代碼來源:internal-model.ts

示例6: deserialize

 deserialize(serialized: any) {
   serialized = A(serialized);
   return serialized;
 }
開發者ID:pjcarly,項目名稱:ember-mist-components,代碼行數:4,代碼來源:strings.ts

示例7: _shouldSendHeaders

   * This hook is used to help prevent sending headers to every host, regardless
   * of the destination, since this could be a security issue if authentication
   * tokens are accidentally leaked to third parties.
   *
   * To avoid that problem, subclasses should utilize the `headers` computed
   * property to prevent authentication from being sent to third parties, or
   * implement this hook for more fine-grain control over when headers are sent.
   *
   * By default, the headers are sent if the host of the request matches the
   * `host` property designated on the class.
   */
  _shouldSendHeaders({ url, host }: AJAXOptions) {
    url = url || '';
    host = host || get(this, 'host') || '';

    const trustedHosts = get(this, 'trustedHosts') || A<Matcher>();
    const { hostname } = parseURL(url);

    // Add headers on relative URLs
    if (!isFullURL(url)) {
      return true;
    } else if (
      trustedHosts.find(matcher => this._matchHosts(hostname, matcher))
    ) {
      return true;
    }

    // Add headers on matching host
    return haveSameHost(url, host);
  },
開發者ID:knownasilya,項目名稱:ember-ajax,代碼行數:30,代碼來源:ajax-request.ts


注:本文中的@ember/array.A函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。