本文整理汇总了TypeScript中vs/base/common/arrays.fill函数的典型用法代码示例。如果您正苦于以下问题:TypeScript fill函数的具体用法?TypeScript fill怎么用?TypeScript fill使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了fill函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: relative
export function relative(from: string, to: string): string {
const originalNormalizedFrom = normalize(from);
const originalNormalizedTo = normalize(to);
// we're assuming here that any non=linux OS is case insensitive
// so we must compare each part in its lowercase form
const normalizedFrom = isLinux ? originalNormalizedFrom : originalNormalizedFrom.toLowerCase();
const normalizedTo = isLinux ? originalNormalizedTo : originalNormalizedTo.toLowerCase();
const fromParts = normalizedFrom.split(sep);
const toParts = normalizedTo.split(sep);
let i = 0, max = Math.min(fromParts.length, toParts.length);
for (; i < max; i++) {
if (fromParts[i] !== toParts[i]) {
break;
}
}
const result = [
...fill(fromParts.length - i, () => '..'),
...originalNormalizedTo.split(sep).slice(i)
];
return result.join(sep);
}
示例2: test
test('stableSort', () => {
let counter = 0;
let data = arrays.fill(10000, () => ({ n: 1, m: counter++ }));
arrays.mergeSort(data, (a, b) => a.n - b.n);
let lastM = -1;
for (const element of data) {
assert.ok(lastM < element.m);
lastM = element.m;
}
});