{"id":19904205,"url":"https://github.com/yarabey/stringifyit","last_synced_at":"2025-08-26T06:38:29.602Z","repository":{"id":57372689,"uuid":"82806105","full_name":"yarabey/stringifyit","owner":"yarabey","description":"Fast object stringifier","archived":false,"fork":false,"pushed_at":"2021-06-27T10:00:44.000Z","size":13,"stargazers_count":1,"open_issues_count":1,"forks_count":1,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-08-15T04:12:52.897Z","etag":null,"topics":["javascript","object","stringify"],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/yarabey.png","metadata":{"files":{"readme":"README.md","changelog":null,"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":"2017-02-22T13:14:47.000Z","updated_at":"2019-02-07T22:55:32.000Z","dependencies_parsed_at":"2022-09-16T11:50:28.514Z","dependency_job_id":null,"html_url":"https://github.com/yarabey/stringifyit","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"purl":"pkg:github/yarabey/stringifyit","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarabey%2Fstringifyit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarabey%2Fstringifyit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarabey%2Fstringifyit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarabey%2Fstringifyit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/yarabey","download_url":"https://codeload.github.com/yarabey/stringifyit/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/yarabey%2Fstringifyit/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":272186211,"owners_count":24888333,"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","status":"online","status_checked_at":"2025-08-26T02:00:07.904Z","response_time":60,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"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":["javascript","object","stringify"],"created_at":"2024-11-12T20:27:24.889Z","updated_at":"2025-08-26T06:38:29.578Z","avatar_url":"https://github.com/yarabey.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# stringifyit\nFast node.js stringify library with sorting and typing. Provides [Stringifier](#Stringifier) class. [Stringifier](#Stringifier) provides [stringify Symbol](#stringifierstringify--symbol) to allow you [customize](#stringifierstringifycallback--function) stringifying your own classes.\n\nSee [benchmarks](#benchmarks) for compare to other libs.\n\n# Install\n`npm i stringifyit --save`\n\n# Features\n\n- Supports node.js \u003e= 4.0.0\n- Supports Map/WeakMap, Set/WeakSet and typed arrays\n- Supports sort Set, Map, object keys and optional sort arrays\n- Supports custom stringify rules for user-defined classes\n- Useful for browsers\n- Very fast stringify library\n\n# API\n\n## Classes\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#Stringifier\"\u003eStringifier\u003c/a\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eProvides interface to stringify any value\nSort Map, Set and object keys by default without ability to avoid it\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n## Members\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#stringify\"\u003estringify\u003c/a\u003e : \u003ccode\u003e\u003ca href=\"#Stringifier..stringify\"\u003estringify\u003c/a\u003e\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003c/dd\u003e\n\u003c/dl\u003e\n\n## Functions\n\n\u003cdl\u003e\n\u003cdt\u003e\u003ca href=\"#stringifyit\"\u003estringifyit(value, [options])\u003c/a\u003e ⇒ \u003ccode\u003estring\u003c/code\u003e\u003c/dt\u003e\n\u003cdd\u003e\u003cp\u003eHelper for simple stringify single value\u003c/p\u003e\n\u003c/dd\u003e\n\u003c/dl\u003e\n\n\u003ca name=\"Stringifier\"\u003e\u003c/a\u003e\n\n## Stringifier\nProvides interface to stringify any value\nSort Map, Set and object keys by default without ability to avoid it\n\n**Kind**: global class  \n\n* [Stringifier](#Stringifier)\n    * [new Stringifier([options])](#new_Stringifier_new)\n    * _instance_\n        * [.string](#Stringifier+string) : \u003ccode\u003estring\u003c/code\u003e\n        * [.update(value)](#Stringifier+update)\n    * _inner_\n        * [~stringifyCallback](#Stringifier..stringifyCallback) : \u003ccode\u003efunction\u003c/code\u003e\n        * [~stringify](#Stringifier..stringify) : \u003ccode\u003eSymbol\u003c/code\u003e\n        * [~options](#Stringifier..options) : \u003ccode\u003eObject\u003c/code\u003e\n\n\u003ca name=\"new_Stringifier_new\"\u003e\u003c/a\u003e\n\n### new Stringifier([options])\n\n| Param | Type |\n| --- | --- |\n| [options] | \u003ccode\u003e[options](#Stringifier..options)\u003c/code\u003e | \n\n\u003ca name=\"Stringifier+string\"\u003e\u003c/a\u003e\n\n### stringifier.string : \u003ccode\u003estring\u003c/code\u003e\nAccumulator string\n\n**Kind**: instance property of \u003ccode\u003e[Stringifier](#Stringifier)\u003c/code\u003e  \n**Access:** public  \n\u003ca name=\"Stringifier+update\"\u003e\u003c/a\u003e\n\n### stringifier.update(value)\nStringifies value and append it to current accumulator string\n\n**Kind**: instance method of \u003ccode\u003e[Stringifier](#Stringifier)\u003c/code\u003e  \n\n| Param | Type |\n| --- | --- |\n| value | \u003ccode\u003e\\*\u003c/code\u003e | \n\n\u003ca name=\"Stringifier..stringifyCallback\"\u003e\u003c/a\u003e\n\n### Stringifier~stringifyCallback : \u003ccode\u003efunction\u003c/code\u003e\nCustom stringify callback declared with [stringify Symbol](#Stringifier..stringify)\n\n**Kind**: inner typedef of \u003ccode\u003e[Stringifier](#Stringifier)\u003c/code\u003e  \n\n| Param | Type | Description |\n| --- | --- | --- |\n| stringifier | \u003ccode\u003e[Stringifier](#Stringifier)\u003c/code\u003e | Stringifier instance |\n\n**Example**  \n```js\nconst {stringify} = require('stringifyit');\nCustomType.prototype[stringify] = function (stringifier) {\n    stringifier.string += 'start';\n\n    stringifier.update(this.someProp);\n    stringifier.update(['use', 'any', 'type']);\n\n    stringifier.string += 'end';\n}\n```\n\u003ca name=\"Stringifier..stringify\"\u003e\u003c/a\u003e\n\n### Stringifier~stringify : \u003ccode\u003eSymbol\u003c/code\u003e\nSymbol to add custom stringify rules for user types\n\n**Kind**: inner typedef of \u003ccode\u003e[Stringifier](#Stringifier)\u003c/code\u003e  \n\u003ca name=\"Stringifier..options\"\u003e\u003c/a\u003e\n\n### Stringifier~options : \u003ccode\u003eObject\u003c/code\u003e\nStringifier options\n\n**Kind**: inner typedef of \u003ccode\u003e[Stringifier](#Stringifier)\u003c/code\u003e  \n**Properties**\n\n| Name | Type | Description |\n| --- | --- | --- |\n| sortArrays | \u003ccode\u003eboolean\u003c/code\u003e | Sort arrays before stringify |\n| includePrimitiveTypes | \u003ccode\u003eboolean\u003c/code\u003e | Stringify primitive values (and functions) types |\n| includeConstructorNames | \u003ccode\u003eboolean\u003c/code\u003e | Stringify non-primitive values constructor names |\n\n\u003ca name=\"stringify\"\u003e\u003c/a\u003e\n\n## stringify : \u003ccode\u003e[stringify](#Stringifier..stringify)\u003c/code\u003e\n**Kind**: global variable  \n\u003ca name=\"stringifyit\"\u003e\u003c/a\u003e\n\n## stringifyit(value, [options]) ⇒ \u003ccode\u003estring\u003c/code\u003e\nHelper for simple stringify single value\n\n**Kind**: global function  \n\n| Param | Type |\n| --- | --- |\n| value | \u003ccode\u003e\\*\u003c/code\u003e | \n| [options] | \u003ccode\u003e[options](#Stringifier..options)\u003c/code\u003e | \n\n**Example**  \n```js\nconst {stringifyit} = require('stringifyit');\n\nstringifyit({key: 'value', value: 'key'}) === stringifyit({value: 'key', key: 'value'}); // true\nstringifyit(new Set(['value1', 'value2'])) === stringifyit(new Set(['value2', 'value1'])); // true\nstringifyit(new Map([['key', 'value'], ['value', 'key']])) === stringifyit(new Map([['value', 'key'], ['key', 'value']])); // true\nstringifyit([1, 2, 3]) === stringifyit([1, 2, 3]); // true\nstringifyit([1, 2, 3], {sortArrays: true}) === stringifyit([1, 3, 2], {sortArrays: true}); // true\n\nstringifyit([1, 2, 3]) === stringifyit([1, 3, 2]); // false\nstringifyit(5) === stringifyit('5'); // false\n```\n\n## Custom stringifiers [source](stringifiers)\n\n### Object.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### Array.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### TypedArray.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### Map.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### WeakMap.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### Set.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### WeakSet.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n### Date.prototype[[stringify](#Stringifier..stringify)] : \u003ccode\u003e[stringifyCallback](#Stringifier..stringifyCallback)\u003c/code\u003e\n\n# Benchmarks\n\nBenchmarked with Node.js v6.9.5\n\n## Usage\n\n* `npm run bench` to run benchmarking stringifyit operations/second for different cases\n\n## Results\n\n```\narray x 1,947,707 ops/sec ±1.60% (85 runs sampled)\nobject x 2,366,530 ops/sec ±1.30% (89 runs sampled)\nnestedObject x 29,384 ops/sec ±1.48% (87 runs sampled)\ncomplexObject_5items x 35,847 ops/sec ±1.87% (87 runs sampled)\ncomplexObject_10items x 18,407 ops/sec ±2.03% (87 runs sampled)\ncomplexObject_100items x 1,682 ops/sec ±2.09% (85 runs sampled)\nset x 215,921 ops/sec ±2.52% (84 runs sampled)\nmap x 190,451 ops/sec ±2.57% (84 runs sampled)\n```\n\n\n# License\nMIT\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarabey%2Fstringifyit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fyarabey%2Fstringifyit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fyarabey%2Fstringifyit/lists"}