{"id":13448624,"url":"https://github.com/voodooattack/serialism","last_synced_at":"2025-04-09T19:35:28.296Z","repository":{"id":56242074,"uuid":"158726293","full_name":"voodooattack/serialism","owner":"voodooattack","description":"Serialize complex JavaScript objects or ES6 classes with circular dependencies natively.","archived":false,"fork":false,"pushed_at":"2022-12-08T06:04:40.000Z","size":782,"stargazers_count":53,"open_issues_count":2,"forks_count":1,"subscribers_count":5,"default_branch":"master","last_synced_at":"2025-04-06T15:55:38.434Z","etag":null,"topics":["binary-protocol","deserialization","javascript","node-addon","nodejs","serialization","structured-clone","typescript","typescript-library"],"latest_commit_sha":null,"homepage":"https://voodooattack.github.io/serialism/","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/voodooattack.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-11-22T16:32:13.000Z","updated_at":"2022-11-24T12:24:41.000Z","dependencies_parsed_at":"2023-01-24T15:00:42.585Z","dependency_job_id":null,"html_url":"https://github.com/voodooattack/serialism","commit_stats":null,"previous_names":[],"tags_count":2,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voodooattack%2Fserialism","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voodooattack%2Fserialism/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voodooattack%2Fserialism/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/voodooattack%2Fserialism/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/voodooattack","download_url":"https://codeload.github.com/voodooattack/serialism/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248098306,"owners_count":21047412,"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":["binary-protocol","deserialization","javascript","node-addon","nodejs","serialization","structured-clone","typescript","typescript-library"],"created_at":"2024-07-31T05:01:50.910Z","updated_at":"2025-04-09T19:35:28.266Z","avatar_url":"https://github.com/voodooattack.png","language":"TypeScript","readme":"# serialism\n\nSerialize complex JavaScript objects or ES6 classes with circular dependencies natively.\n\n[![npm](https://img.shields.io/npm/v/serialism.svg)](https://www.npmjs.com/package/serialism)\n[![GitHub license](https://img.shields.io/github/license/voodooattack/serialism.svg)](https://github.com/voodooattack/serialism/blob/master/LICENSE)\n[![GitHub issues](https://img.shields.io/github/issues/voodooattack/serialism.svg)](https://github.com/voodooattack/serialism/issues)\n[![Build Status](https://travis-ci.org/voodooattack/serialism.svg?branch=master)](https://travis-ci.org/voodooattack/serialism) [![Coverage Status](https://coveralls.io/repos/github/voodooattack/serialism/badge.svg)](https://coveralls.io/github/voodooattack/serialism)\n![npm type definitions](https://img.shields.io/npm/types/serialism.svg)\n\n## Important Warning\n\nThe underlying v8 API used by this native addon is still experimental, and binary compatibility may not be guaranteed between data output by the same application running in two different node versions.\n\nIf you plan to use this over a wire, please bear that in mind.\n\n## Compatibility\n\n- node.js \u003e= v8.13.0 (LTS/Carbon)\n\n## Installation\n\n### Prerequisites\n\nPlease make sure you have the following installed:\n\n- Python\n- Make\n- C++ compiler\n\nUse one of the following commands depending on your platform.\n\n#### Linux\n\nYou need `g++`, `make` and `python` installed.\n\n##### Ubuntu/Debian\n\n`sudo apt-get install -y build-essential python`\n\n##### Fedora\n\n`dnf install gcc-c++ make`\n\n##### RHEL and CentOS\n\n`yum install -y gcc-c++ make`\n\n#### Windows\n\n`npm install -g --production windows-build-tools`\n\n## Usage\n\nUse `npm install serialism` to install the npm package.\n\n### TypeScript\n\n```typescript\nimport { assert } from 'chai';\nimport { Serialism } from 'serialism';\nimport { Class1 } from '...';\n\nconst serialism = new Serialism();\n// or if you plan on serializing a value containing ES6 classes:\n// const serialism = new Serialism([Class1, Class2, ...]);\n\n// serialize an object, an array, a regex, a primitive value, anything works except local symbols\nconst myArray = [1, 2, NaN, /my-regex-here/g, new Class1('ho there!')];\n\n// cyclic and self-references will work\nmyArray.push(myArray);\n\nconst data = serialism.serialize(myArray);\n\nconsole.log(Buffer.isBuffer(data)); // true;\n\nconst deserialized = serialism.deserialize\u003cany\u003e(data); // deserialize the data\n\nassert.deepEqual(data, deserialized); // true, the clone is equal\n\nassert.instanceOf(\n  serialism.deserialize\u003cClass1\u003e(serialism.serialize(new Class1(\"I'm a class\"))),\n  Class1\n); // true\n```\n\n### JavaScript\n\n```js\nconst Serialism = require('serialism').Serialism;\nconst Class1 = require('...');\n\n// serialize an object, an array, a regex, a set, a map, a primitive value, anything works except local symbols\nconst data = serialism.serialize([\n  1,\n  2,\n  NaN,\n  new Map(),\n  new Set(),\n  /my-regex-here/g,\n  new Class1()\n]);\n\nconsole.log(Buffer.isBuffer(data)); // true;\n\nconst deserialized = serialism.deserialize(data); // deserialize the data\n\nassert.deepEqual(data, deserialized); // true, the clone is equal\n```\n\n### Raw interface (no class deserialization)\n\nThis allows you to serialize and deserialize any JavaScript value, without the revival of classes and the processing of global symbols.\n\nThis interface is much faster because it will not traverse the object graph in JavaScript to entomb and revive values.\n\nIn this case, any class instances supplied will be serialized as plain objects.\n\n```typescript\nimport { serializeNative, deserializeNative } from 'serialism';\nimport { assert } from 'chai';\n\nconst target: any = {\n  undef: undefined,\n  nullVal: null,\n  negativeZero: -0,\n  test: 'hello world',\n  array: [1, 2, 3, 'test', Math.PI, new Date()],\n  map: new Map\u003cany, any\u003e([['hi', 3], [Infinity, 'test'], [NaN, null]]),\n  set: new Set\u003cany\u003e([1, 2, 3, +0, null, undefined]),\n  regexp: /hello-world/g,\n  instance: new Dummy(),\n  str: new String('string object instance'),\n  num: new Number(100),\n  object: {\n    'test long key': 'value',\n    emptyString: ''\n  }\n};\n\n// create some basic and deeply nested cyclic dependencies\ntarget.cyclic = target;\ntarget.map.set(target, target.set);\ntarget.set.add(target);\ntarget.map.set(target.array, target.instance);\n\nconst data = serializeNative(target);\n\nconst result = deserializeNative(result);\n\nassert.deepEqual(target, result); // true\n```\n\n### Contributions\n\nAll contributions and pull requests are welcome.\n\nIf you have something to suggest or an idea you'd like to discuss, then please submit an issue or a pull request.\n\nNote: Please commit your changes using `npm run commit` to trigger `conventional-changelog`.\n\n### License (MIT)\n\nCopyright (c) 2018 Abdullah A. Hassan\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n","funding_links":[],"categories":["TypeScript"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoodooattack%2Fserialism","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fvoodooattack%2Fserialism","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fvoodooattack%2Fserialism/lists"}