本文整理汇总了TypeScript中vs/base/common/types.isUndefinedOrNull函数的典型用法代码示例。如果您正苦于以下问题:TypeScript isUndefinedOrNull函数的具体用法?TypeScript isUndefinedOrNull怎么用?TypeScript isUndefinedOrNull使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了isUndefinedOrNull函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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.strictEqual(s.getChildrenArray().length, 0);
s = createStat('/path/to/stat', 'sName', false, false, 8096, d);
assert(isUndefinedOrNull(s.getChildrenArray()));
});
开发者ID:jinlongchen2018,项目名称: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: contains
/**
* Returns true if this change event contains the provided file with the given change type (if provided). In case of
* type DELETED, this method will also return true if a folder got deleted that is the parent of the
* provided file path.
*/
contains(resource: URI, type?: FileChangeType): boolean {
if (!resource) {
return false;
}
const checkForChangeType = !isUndefinedOrNull(type);
return this._changes.some(change => {
if (checkForChangeType && change.type !== type) {
return false;
}
// For deleted also return true when deleted folder is parent of target path
if (change.type === FileChangeType.DELETED) {
return isEqualOrParent(resource, change.resource, !isLinux /* ignorecase */);
}
return isEqual(resource, change.resource, !isLinux /* ignorecase */);
});
}
开发者ID:fly-fisher,项目名称:vscode,代码行数:25,代码来源:files.ts
示例6: test
test('isUndefinedOrNull', () => {
assert(!types.isUndefinedOrNull('foo'));
assert(!types.isUndefinedOrNull([]));
assert(!types.isUndefinedOrNull([1, 2, '3']));
assert(!types.isUndefinedOrNull(true));
assert(!types.isUndefinedOrNull({}));
assert(!types.isUndefinedOrNull(/test/));
assert(!types.isUndefinedOrNull(new RegExp('')));
assert(!types.isUndefinedOrNull(new Date()));
assert(!types.isUndefinedOrNull(assert));
assert(!types.isUndefinedOrNull(function foo() { /**/ }));
assert(!types.isUndefinedOrNull({ foo: 'bar' }));
assert(types.isUndefinedOrNull(undefined));
assert(types.isUndefinedOrNull(null));
});
开发者ID:DonJayamanne,项目名称:vscode,代码行数:16,代码来源:types.test.ts
示例7: isFileOperationError
static isFileOperationError(obj: any): obj is FileOperationError {
return obj instanceof Error && !isUndefinedOrNull((obj as FileOperationError).fileOperationResult);
}
开发者ID:igolskyi,项目名称:vscode,代码行数:3,代码来源:files.ts
示例8: isTextFileOperationError
static isTextFileOperationError(obj: unknown): obj is TextFileOperationError {
return obj instanceof Error && !isUndefinedOrNull((obj as TextFileOperationError).textFileOperationResult);
}
开发者ID:eamodio,项目名称:vscode,代码行数:3,代码来源:textfiles.ts
示例9: test
test('does parse condition right', () => {
let insightsDialogModel = new InsightsDialogModel();
let label: IInsightsLabel = {
column: undefined,
state: [
{
condition: {
if: 'always'
},
color: 'green'
}
]
} as IInsightsLabel;
insightsDialogModel.insight = { label } as IInsightsConfigDetails;
insightsDialogModel.rows = [
['label1', 'value1'],
['label2', 'value2'],
['label3', 'value3']
];
let result = insightsDialogModel.getListResources(0, 1);
for (let resource of result) {
assert.equal(resource.stateColor, 'green', 'always Condition did not return val as expected');
}
label.state = [
{
condition: {
if: 'equals',
equals: 'specific value'
},
color: 'green'
}
];
insightsDialogModel.insight = { label } as IInsightsConfigDetails;
insightsDialogModel.rows = [
['label1', 'specific value'],
['label2', 'value2'],
['label3', 'value3']
];
result = insightsDialogModel.getListResources(0, 1);
assert.equal(result[0].stateColor, 'green', 'always Condition did not return val as expected');
assert.equal(isUndefinedOrNull(result[1].stateColor), true, 'always Condition did not return val as expected');
assert.equal(isUndefinedOrNull(result[2].stateColor), true, 'always Condition did not return val as expected');
label.state = [
{
condition: {
if: 'equals',
equals: 'specific value'
},
color: 'green'
},
{
condition: {
if: 'equals',
equals: 'specific value2'
},
color: 'red'
}
];
insightsDialogModel.insight = { label } as IInsightsConfigDetails;
insightsDialogModel.rows = [
['label1', 'specific value'],
['label2', 'specific value2'],
['label3', 'value3']
];
result = insightsDialogModel.getListResources(0, 1);
assert.equal(result[0].stateColor, 'green', 'always Condition did not return val as expected');
assert.equal(result[1].stateColor, 'red', 'always Condition did not return val as expected');
assert.equal(isUndefinedOrNull(result[2].stateColor), true, 'always Condition did not return val as expected');
label.state = [
{
condition: {
if: 'greaterThan',
equals: '2'
},
color: 'green'
},
{
condition: {
if: 'equals',
equals: 'specific value2'
},
color: 'red'
}
];
insightsDialogModel.insight = { label } as IInsightsConfigDetails;
insightsDialogModel.rows = [
['label1', '3'],
['label2', 'specific value2'],
['label3', 'value3']
];
result = insightsDialogModel.getListResources(0, 1);
assert.equal(result[0].stateColor, 'green', 'always Condition did not return val as expected');
assert.equal(result[1].stateColor, 'red', 'always Condition did not return val as expected');
//.........这里部分代码省略.........
开发者ID:AlexxNica,项目名称:sqlopsstudio,代码行数:101,代码来源:insightsDialogModel.test.ts
注:本文中的vs/base/common/types.isUndefinedOrNull函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论