本文整理匯總了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;
}