本文整理汇总了TypeScript中@phosphor/coreutils.JSONExt.deepCopy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript JSONExt.deepCopy方法的具体用法?TypeScript JSONExt.deepCopy怎么用?TypeScript JSONExt.deepCopy使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类@phosphor/coreutils.JSONExt
的用法示例。
在下文中一共展示了JSONExt.deepCopy方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should be emitted when the specs change', async () => {
const specs = JSONExt.deepCopy(KERNELSPECS) as Kernel.ISpecModels;
specs.default = 'shell';
handleRequest(manager, 200, specs);
let called = false;
manager.specsChanged.connect((sender, args) => {
expect(sender).to.equal(manager);
expect(args.default).to.equal(specs.default);
called = true;
});
await manager.refreshSpecs();
expect(called).to.equal(true);
});
示例2: toJSON
/**
* Serialize the model to JSON.
*/
toJSON(): JSONObject {
const out: JSONObject = Object.create(null);
const keys = this.keys();
for (let key of keys) {
const value = this.get(key);
if (value !== undefined) {
out[key] = JSONExt.deepCopy(value);
}
}
return out;
}
示例3: populate
fetch: plugin => {
// Only override the canonical schema the first time.
if (!canonical) {
canonical = JSONExt.deepCopy(plugin.schema);
populate(canonical);
}
return {
data: plugin.data,
id: plugin.id,
raw: plugin.raw,
schema: canonical,
version: plugin.version
};
}
示例4: ajaxSettingsWithToken
function ajaxSettingsWithToken(ajaxSettings?: IAjaxSettings, token?: string): IAjaxSettings {
if (!ajaxSettings) {
ajaxSettings = {};
} else {
ajaxSettings = JSONExt.deepCopy(ajaxSettings);
}
if (!token) {
token = PageConfig.getOption('token');
}
if (!token || token === '') {
return ajaxSettings;
}
if (!ajaxSettings.requestHeaders) {
ajaxSettings.requestHeaders = {};
}
ajaxSettings.requestHeaders['Authorization'] = `token ${token}`;
return ajaxSettings;
}