本文整理匯總了TypeScript中@phosphor/algorithm.some函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript some函數的具體用法?TypeScript some怎麽用?TypeScript some使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了some函數的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it('should verify some items in an iterable satisfy a condition', () => {
let data = [1, 2, 3, 4, 5];
let valid = some(data, x => x > 4);
let invalid = some(data, x => x < 0);
expect(valid).to.equal(true);
expect(invalid).to.equal(false);
});
示例2: postMessage
function postMessage(handler: IMessageHandler, msg: Message): void {
// Handle the common case of a non-conflatable message.
if (!msg.isConflatable) {
enqueueMessage(handler, msg);
return;
}
// Conflate the message with an existing message if possible.
let conflated = some(messageQueue, posted => {
if (posted.handler !== handler) {
return false;
}
if (!posted.msg) {
return false;
}
if (posted.msg.type !== msg.type) {
return false;
}
if (!posted.msg.isConflatable) {
return false;
}
return posted.msg.conflate(msg);
});
// Enqueue the message if it was not conflated.
if (!conflated) {
enqueueMessage(handler, msg);
}
}
示例3: some
isEnabled: () => {
return some(
map(shell.widgets('main'), w => docManager.contextForWidget(w)),
c => c && c.contentsModel && c.contentsModel.writable
);
},