本文整理汇总了TypeScript中vs/base/common/types.isArray函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isArray函数的具体用法?TypeScript isArray怎么用?TypeScript isArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isArray函数的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: _cloneAndChange
function _cloneAndChange(obj: any, changer: (orig: any) => any, encounteredObjects: any[]): any {
if (isUndefinedOrNull(obj)) {
return obj;
}
const changed = changer(obj);
if (typeof changed !== 'undefined') {
return changed;
}
if (isArray(obj)) {
const r1: any[] = [];
for (let i1 = 0; i1 < obj.length; i1++) {
r1.push(_cloneAndChange(obj[i1], changer, encounteredObjects));
}
return r1;
}
if (isObject(obj)) {
if (encounteredObjects.indexOf(obj) >= 0) {
throw new Error('Cannot clone recursive data-structure');
}
encounteredObjects.push(obj);
const r2 = {};
for (let i2 in obj) {
if (_hasOwnProperty.call(obj, i2)) {
(r2 as any)[i2] = _cloneAndChange(obj[i2], changer, encounteredObjects);
}
}
encounteredObjects.pop();
return r2;
}
return obj;
}
开发者ID:developers23,项目名称:vscode,代码行数:35,代码来源:objects.ts
示例2: _cloneAndChange
function _cloneAndChange(obj: any, changer: (orig: any) => any, seen: Set<any>): any {
if (isUndefinedOrNull(obj)) {
return obj;
}
const changed = changer(obj);
if (typeof changed !== 'undefined') {
return changed;
}
if (isArray(obj)) {
const r1: any[] = [];
for (const e of obj) {
r1.push(_cloneAndChange(e, changer, seen));
}
return r1;
}
if (isObject(obj)) {
if (seen.has(obj)) {
throw new Error('Cannot clone recursive data-structure');
}
seen.add(obj);
const r2 = {};
for (let i2 in obj) {
if (_hasOwnProperty.call(obj, i2)) {
(r2 as any)[i2] = _cloneAndChange(obj[i2], changer, seen);
}
}
seen.delete(obj);
return r2;
}
return obj;
}
开发者ID:PKRoma,项目名称:vscode,代码行数:35,代码来源:objects.ts
示例3: test
test('Properties', function () {
const d = new Date().getTime();
let s = createStat('/path/to/stat', 'sName', true, true, 8096, d);
assert.strictEqual(s.isDirectoryResolved, false);
assert.strictEqual(s.resource.fsPath, toResource('/path/to/stat').fsPath);
assert.strictEqual(s.name, 'sName');
assert.strictEqual(s.isDirectory, true);
assert.strictEqual(s.mtime, new Date(d).getTime());
assert(isArray(s.children) && s.children.length === 0);
s = createStat('/path/to/stat', 'sName', false, false, 8096, d);
assert(isUndefinedOrNull(s.children));
});
开发者ID:JarnoNijboer,项目名称:vscode,代码行数:14,代码来源:explorerModel.test.ts
示例4: test
test("Properties", function() {
let d = new Date().getTime();
let s = createStat("/path/to/stat", "sName", true, true, 8096, d);
assert.strictEqual(s.isDirectoryResolved, false);
assert.strictEqual(s.resource.fsPath, toResource("/path/to/stat").fsPath);
assert.strictEqual(s.name, "sName");
assert.strictEqual(s.isDirectory, true);
assert.strictEqual(s.hasChildren, true);
assert.strictEqual(s.mtime, new Date(d).getTime());
assert(isArray(s.children) && s.children.length === 0);
s = createStat("/path/to/stat", "sName", false, false, 8096, d);
assert(isUndefinedOrNull(s.children));
});
开发者ID:578723746,项目名称:vscode,代码行数:15,代码来源:viewModel.test.ts
示例5: test
test('isArray', () => {
assert(!types.isArray(undefined));
assert(!types.isArray(null));
assert(!types.isArray('foo'));
assert(!types.isArray(5));
assert(!types.isArray(true));
assert(!types.isArray({}));
assert(!types.isArray(/test/));
assert(!types.isArray(new RegExp('')));
assert(!types.isArray(new Date()));
assert(!types.isArray(assert));
assert(!types.isArray(function foo() { /**/ }));
assert(!types.isArray({ foo: 'bar' }));
assert(types.isArray([]));
assert(types.isArray([1, 2, '3']));
});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:17,代码来源:types.test.ts
注:本文中的vs/base/common/types.isArray函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论