本文整理匯總了TypeScript中vs/base/common/arrays.topAsync函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript topAsync函數的具體用法?TypeScript topAsync怎麽用?TypeScript topAsync使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。
在下文中一共展示了topAsync函數的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: testTopAsync
async function testTopAsync(cmp: any, m: number) {
{
const result = await arrays.topAsync([], cmp, 1, m);
assert.deepEqual(result, []);
}
{
const result = await arrays.topAsync([1], cmp, 0, m);
assert.deepEqual(result, []);
}
{
const result = await arrays.topAsync([1, 2], cmp, 1, m);
assert.deepEqual(result, [1]);
}
{
const result = await arrays.topAsync([2, 1], cmp, 1, m);
assert.deepEqual(result, [1]);
}
{
const result = await arrays.topAsync([1, 3, 2], cmp, 2, m);
assert.deepEqual(result, [1, 2]);
}
{
const result = await arrays.topAsync([3, 2, 1], cmp, 3, m);
assert.deepEqual(result, [1, 2, 3]);
}
{
const result = await arrays.topAsync([4, 6, 2, 7, 8, 3, 5, 1], cmp, 3, m);
assert.deepEqual(result, [1, 2, 3]);
}
}
示例2:
}).then(() => {
return arrays.topAsync([4, 6, 2, 7, 8, 3, 5, 1], cmp, 3, m)
.then(result => {
assert.deepEqual(result, [1, 2, 3]);
});
});