本文整理匯總了TypeScript中@bokehjs/document.Document.from_json_string方法的典型用法代碼示例。如果您正苦於以下問題:TypeScript Document.from_json_string方法的具體用法?TypeScript Document.from_json_string怎麽用?TypeScript Document.from_json_string使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類@bokehjs/document.Document
的用法示例。
在下文中一共展示了Document.from_json_string方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。
示例1: it
it("computes patch for models added during construction", () => {
const d = new Document()
expect(d.roots().length).to.equal(0)
expect(Object.keys(d._all_models).length).to.equal(0)
const root1 = new ModelWithConstructTimeChanges()
// change it so it doesn't match what initialize() does
root1.foo = 3
root1.child = null
d.add_root(root1)
const json = d.to_json_string()
const parsed = JSON.parse(json)
parsed.version = js_version
const copy = Document.from_json_string(JSON.stringify(parsed))
const patch = Document._compute_patch_since_json(JSON.parse(json), copy)
expect(patch.events.length).to.equal(2)
expect(root1.foo).to.equal(3)
expect(root1.child).to.equal(null)
d.apply_json_patch(patch)
expect(root1.foo).to.equal(4)
expect(root1.child).to.be.an.instanceof(AnotherModel)
})
示例2: it
it("should round-trip through document serialization", () => {
const d = new Document()
d.add_root(r)
const json = d.to_json_string()
const parsed = JSON.parse(json)
parsed.version = js_version
const copy = Document.from_json_string(JSON.stringify(parsed))
const r_copy = copy.get_model_by_id(r.id)! as CustomJSHover
const rng_copy = copy.get_model_by_id(rng.id)! as CustomJSHover
expect(r.values).to.be.deep.equal([rng])
expect(r_copy.values).to.be.deep.equal([rng_copy])
})
示例3: stderrTrap
const out6 = stderrTrap(() => Document.from_json_string(JSON.stringify(parsed)))