本文整理汇总了TypeScript中vs/base/common/types.isObject函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isObject函数的具体用法?TypeScript isObject怎么用?TypeScript isObject使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isObject函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1:
Object.keys(source).forEach(key => {
if (key in destination) {
if (overwrite) {
if (isObject(destination[key]) && isObject(source[key])) {
mixin(destination[key], source[key], overwrite);
} else {
destination[key] = source[key];
}
}
} else {
destination[key] = source[key];
}
});
开发者ID:developers23,项目名称:vscode,代码行数:13,代码来源:objects.ts
示例2: _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
示例3: _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
示例4: _flaten
private static _flaten(obj: any, result: {[key: string]: any }, order: number = 0, prefix?: string): void {
if (!obj) {
return;
}
for(var item of Object.getOwnPropertyNames(obj)){
const value = obj[item];
const index = prefix ? prefix + item : item;
if (Array.isArray(value)) {
result[index] = safeStringify(value);
} else if (value instanceof Date) {
// TODO unsure why this is here and not in _getData
result[index] = value.toISOString();
} else if (isObject(value)) {
if (order < 2) {
AIAdapter._flaten(value, result, order + 1, index + '.');
} else {
result[index] = safeStringify(value);
}
} else {
result[index] = value;
}
}
}
开发者ID:Buildsoftwaresphere,项目名称:vscode,代码行数:27,代码来源:aiAdapter.ts
示例5:
Object.keys(source).forEach((key: keyof T) => {
let destValue = destination[key];
let sourceValue = source[key];
if (Types.isUndefined(sourceValue)) {
return;
}
if (Types.isUndefined(destValue)) {
destination[key] = sourceValue;
} else {
if (overwrite) {
if (Types.isObject(destValue) && Types.isObject(sourceValue)) {
this.merge(destValue, sourceValue, overwrite);
} else {
destination[key] = sourceValue;
}
}
}
});
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:18,代码来源:parsers.ts
示例6: mixin
export function mixin(destination: any, source: any, overwrite: boolean = true): any {
if (!isObject(destination)) {
return source;
}
if (isObject(source)) {
Object.keys(source).forEach(key => {
if (key in destination) {
if (overwrite) {
if (isObject(destination[key]) && isObject(source[key])) {
mixin(destination[key], source[key], overwrite);
} else {
destination[key] = source[key];
}
}
} else {
destination[key] = source[key];
}
});
}
return destination;
}
开发者ID:developers23,项目名称:vscode,代码行数:22,代码来源:objects.ts
示例7: test
test('create', () => {
let zeroConstructor = function () { /**/ };
assert(types.create(zeroConstructor) instanceof zeroConstructor);
assert(types.isObject(types.create(zeroConstructor)));
let manyArgConstructor = function (this: any, foo, bar) {
this.foo = foo;
this.bar = bar;
};
let foo = {};
let bar = 'foo';
assert(types.create(manyArgConstructor) instanceof manyArgConstructor);
assert(types.isObject(types.create(manyArgConstructor)));
assert(types.create(manyArgConstructor, foo, bar) instanceof manyArgConstructor);
assert(types.isObject(types.create(manyArgConstructor, foo, bar)));
let obj = types.create(manyArgConstructor, foo, bar);
assert.strictEqual(obj.foo, foo);
assert.strictEqual(obj.bar, bar);
});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:24,代码来源:types.test.ts
注:本文中的vs/base/common/types.isObject函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论