本文整理汇总了TypeScript中document.Document.from_json_string方法的典型用法代码示例。如果您正苦于以下问题:TypeScript Document.from_json_string方法的具体用法?TypeScript Document.from_json_string怎么用?TypeScript Document.from_json_string使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类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)))