本文整理汇总了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');
});
示例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;
}
示例3: items
@computed('value.@each')
get items() : MutableArray<string> {
return this.value ? this.value : A();
}
示例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
示例5: A
(function() {
return A(records).every(record => record.hasOwnProperty('_internalModel') === true);
})()
示例6: deserialize
deserialize(serialized: any) {
serialized = A(serialized);
return serialized;
}
示例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);
},