本文整理匯總了TypeScript中vs/base/common/linkedList.LinkedList.toArray方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript LinkedList.toArray方法的具體用法?TypeScript LinkedList.toArray怎麽用?TypeScript LinkedList.toArray使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類vs/base/common/linkedList.LinkedList
的用法示例。
在下文中一共展示了LinkedList.toArray方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: entries
public entries(): [Function, any][] {
if (!this._callbacks) {
return [];
}
return this._callbacks
? this._callbacks.toArray()
: [];
}
示例2:
function assertElements<E>(list: LinkedList<E>, ...elements: E[]) {
// first: assert toArray
assert.deepEqual(list.toArray(), elements);
// second: assert iterator
for (let iter = list.iterator(), element = iter.next(); !element.done; element = iter.next()) {
assert.equal(elements.shift(), element.value);
}
assert.equal(elements.length, 0);
}
示例3: invoke
public invoke(...args: any[]): any[] {
if (!this._callbacks) {
return undefined;
}
const ret: any[] = [];
const elements = this._callbacks.toArray();
for (const [callback, context] of elements) {
try {
ret.push(callback.apply(context, args));
} catch (e) {
onUnexpectedError(e);
}
}
return ret;
}
示例4: test
test('Push/toArray', function () {
let list = new LinkedList<string>();
list.push('foo');
list.push('bar');
list.push('far');
list.push('boo');
assert.deepEqual(
list.toArray(),
[
'foo',
'bar',
'far',
'boo',
]
);
});
示例5: test
test('unshift/toArray', () => {
let list = new LinkedList<string>();
list.unshift('foo');
list.unshift('bar');
list.unshift('far');
list.unshift('boo');
assert.deepEqual(
list.toArray(),
[
'boo',
'far',
'bar',
'foo',
]
);
});