{"id":19560022,"url":"https://github.com/plotdb/datadom","last_synced_at":"2025-02-26T08:26:56.812Z","repository":{"id":57137262,"uuid":"316379924","full_name":"plotdb/datadom","owner":"plotdb","description":"dom serializer / deserializer.","archived":false,"fork":false,"pushed_at":"2023-06-15T08:57:46.000Z","size":5763,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-02-11T12:07:02.504Z","etag":null,"topics":["dom","dom-tree","json"],"latest_commit_sha":null,"homepage":"","language":"LiveScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/plotdb.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2020-11-27T02:20:59.000Z","updated_at":"2022-01-22T02:10:38.000Z","dependencies_parsed_at":"2022-09-01T03:00:58.991Z","dependency_job_id":null,"html_url":"https://github.com/plotdb/datadom","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fdatadom","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fdatadom/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fdatadom/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/plotdb%2Fdatadom/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/plotdb","download_url":"https://codeload.github.com/plotdb/datadom/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":240816910,"owners_count":19862389,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["dom","dom-tree","json"],"created_at":"2024-11-11T05:05:38.709Z","updated_at":"2025-02-26T08:26:56.722Z","avatar_url":"https://github.com/plotdb.png","language":"LiveScript","readme":"# datadom\n\nDOM serializer / deserializer with scriptable plugins.\n\nWIP, please consider this as an unstable library.\n\n\n# Usage\n\ninstall via npm:\n\n    npm install --save @plotdb/datadom\n\nAdd `datadom.js` in your HTML:\n\n    \u003cscript src=\"datadom.js\"\u003e\u003c/script\u003e\n\n\nserialize/deserialize a DOM tree:\n\n    json = datadom.serialize(document.querySelector(\"your-selector\"), [])\n    datadom.deserialize(json,[])\n      .then({node, promise}) -\u003e\n        node # node is the deserialized DOM tree root.\n        promise # promise for asynchronous content\n      .then ({node, promise}) -\u003e # all content prepared.\n\ndatadom is also a constructor:\n\n    dd = new datadom({ ... })\n    dd.init().then(function() { ... });\n\n\n# API\n\nconstructor options:\n\n - `plugin`: function, of Array of functions as default plugin(s).\n   - plugin function accepts 1 parameters: subtree root ( for serialize ) / subdoc root ( for deserialize )\n - `data`: datadom json\n - `node`: root of DOM tree. ignored if `data` is provided.\n - `window`: optional `window` object if run in NodeJS.\n\ndatadom object methods:\n\n - `init()`: initialize data and node ( from provided counterpart ). Return promise.\n - `update(ops)`: apply ops ( operation transformations ) to internal data and DOM tree.\n - `getData()`: return datadom json.\n - `getNode()`: return root of the corresponding DOM tree.\n\ndatadom class methods:\n\n - `serialize(node, plugin)`: convert DOM tree (with root `node`) into json.\n   - `node`: root node of DOM tree to serialize\n   - `plugin(d)`: optional handler for custom node types.\n - `deserialize(data, plugin)`: convert datadom json into DOM tree\n   - `data`: a datadom json.\n   - `plugin(d)`: optional handler for custom node types.\n\n\n## Node.js\n\nto run in nodeJS, use `jsdom` and pass `window` as an argument:\n\n    datadom.deserialize(data, [], (new JSDOM()).window);\n\nsimilarly, pass `window` in constructor when using `new datadom( ... )`:\n\n    new datadom({ ..., window: (new JSDOM()).window)});\n\n\n## Plugins\n\n(TBD) check `doc/plugin.md` for more information.\n\n\n# License\n\nMIT\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotdb%2Fdatadom","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fplotdb%2Fdatadom","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fplotdb%2Fdatadom/lists"}