{"_id":"jsurl2","_rev":"3-ec6984237ff8b96db671ccb2de28e124","name":"jsurl2","dist-tags":{"latest":"2.2.0"},"versions":{"2.1.0":{"name":"jsurl2","description":"URL friendly JSON-like formatting and parsing","version":"2.1.0","license":"MIT","homepage":"http://github.com/wmertens/jsurl2","author":{"name":"Wout Mertens"},"repository":{"type":"git","url":"git://github.com/wmertens/jsurl2.git"},"main":"lib/jsurl2.js","dependencies":{},"devDependencies":{"blns":"^2.0.4","jest":"^27.0.6","jest-cli":"^27.0.6","prettier":"^2.3.2"},"directories":{"lib":"./lib"},"scripts":{"test":"jest","test-watch":"jest --watch","format":"prettier -w ."},"contributors":[{"name":"Bruno Jouhier","email":"bruno.jouhier@sage.com"}],"gitHead":"5e468c0c19505c73f974582110e10acc4d62f9de","bugs":{"url":"https://github.com/wmertens/jsurl2/issues"},"_id":"jsurl2@2.1.0","_nodeVersion":"14.17.3","_npmVersion":"6.14.13","dist":{"integrity":"sha512-dN5xpdjYWxhkn/hN9jGovVP/sy8HqP3BiNU7nKm7pwtRSfQlKG8FZO7wlO4kmydAYzv3UwVVzGjAnEBr4KCmmw==","shasum":"4c7f0cd33344f318cea5e321089c983194e947c7","tarball":"https://registry.npmjs.org/jsurl2/-/jsurl2-2.1.0.tgz","fileCount":5,"unpackedSize":17713,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.13\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJhE7eSCRA9TVsSAnZWagAAp6AP/Rv6GZRQWV0VXY6rrsRA\naLwBlMBR5CVbTamYT5/ZD8SHVyfc6e9dNayvyxsWFet3Ew9oTIsmOffWCScP\nrv99dYGsgRTdKYQ1FANvapnhpzX3LcKc/+fpnVKbrLFO4uyH/2FaujLj4HJx\noz888rBRWOZgk6437GDjODlIyHLHwKoS8mJ/jtyAktnJd+WBWuS2md6/5ijd\nhnSC1moMsaAsbyHgYeTnAzA78XhT86VrSPwDXfGSOl8vlkRRS6LPoCdj6YAR\nnEIx49CTdNo6yuwYPjzyX0eucZwG3F2/mL0cv/P8TcckziJz8/rMTwojn0I6\nMG6WGNB3GBzpmaHriQbfzlwlLK5YbrvavmTe95ok2Hbmvlvw3Fa2nbNKoJNP\n0blU/HYpUe9JkpZ6Ti74a21Dc7k6d0CMq5zREUly3rOuQQ4v+m0g/WBE8Sm3\nDzvvhf4ay51WtaUV88pQdnANqREibjPMIetRrYhbin7s8tmtMfZbmBHDtCwn\n3BI/O8U6gUwt7MB8WFecs/K7wPhjZ941l1sNchAo2MoEjih2jXF4A+RKfCCx\nss5Kfi9QqyLkGVGNeQiThZ12GU8/UVHnliPAosU3kBbYfOAvA33vbxMWaTl0\nJ0ABdfq3mTTAeaytWzcPz9fySislXz5J0Tdy38NWdRlfOdvtDXgQsCbliqa+\nWYEG\r\n=4U6W\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCICBs9j+Slb2ou8FYNtS4QsmUgt1/6EbjzhhntUOnV3hHAiEAsxor7Enu10CMg22/lR1Onmb8UPdPDUEvG0rNx0LcgcQ="}]},"_npmUser":{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"},"maintainers":[{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsurl2_2.1.0_1628682130798_0.8243395776782301"},"_hasShrinkwrap":false},"2.1.1":{"name":"jsurl2","description":"URL friendly JSON-like formatting and parsing","version":"2.1.1","license":"MIT","homepage":"http://github.com/wmertens/jsurl2","author":{"name":"Wout Mertens"},"repository":{"type":"git","url":"git://github.com/wmertens/jsurl2.git"},"main":"lib/jsurl2.js","dependencies":{},"devDependencies":{"blns":"^2.0.4","jest":"^27.0.6","jest-cli":"^27.0.6","prettier":"^2.3.2"},"directories":{"lib":"./lib"},"scripts":{"test":"jest","test-watch":"jest --watch","format":"prettier -w .","release":"npx np"},"_id":"jsurl2@2.1.1","contributors":[{"name":"Bruno Jouhier","email":"bruno.jouhier@sage.com"}],"gitHead":"1641d7d359a06aea6eb317f3bfa8c27d52726139","bugs":{"url":"https://github.com/wmertens/jsurl2/issues"},"_nodeVersion":"20.11.0","_npmVersion":"10.2.4","dist":{"integrity":"sha512-/uBKJcoxaGt51HHR+Xs58wrFoOzPuczHpaukanbVLAvQfxEB9a6Meuy49ZhVCdx5SBbXIuitGoe4u0jSeEpMog==","shasum":"fa87ef550ead73a08572545bd328d843fcfe3500","tarball":"https://registry.npmjs.org/jsurl2/-/jsurl2-2.1.1.tgz","fileCount":5,"unpackedSize":17895,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEQCIG7Y4y8AzEFwuZ3F/uvghZvfaLm7CSG6G8gezlsFeYFsAiAPZwJkAZipsgRKuvPhnYtPJhWXDZCF0wbHRbbPhVH28w=="}]},"_npmUser":{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"},"maintainers":[{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsurl2_2.1.1_1707329887627_0.692665497104926"},"_hasShrinkwrap":false},"2.2.0":{"name":"jsurl2","version":"2.2.0","description":"URL friendly JSON-like formatting and parsing","keywords":["json","url","query","stringify","parse","serialize","deserialize"],"license":"MIT","homepage":"http://github.com/wmertens/jsurl2","author":{"name":"Wout Mertens"},"repository":{"type":"git","url":"git://github.com/wmertens/jsurl2.git"},"main":"dist/index.js","types":"./dist/index.d.ts","exports":{".":{"import":"./dist/index.mjs","require":"./dist/index.js","types":"./dist/index.d.ts"}},"packageManager":"pnpm@8.15.5","devDependencies":{"@rollup/plugin-terser":"^0.4.4","@types/node":"^20.11.30","blns":"^2.0.4","prettier":"^3.2.5","terser":"^5.30.0","vite":"^5.2.6","vite-plugin-dts":"^3.8.1","vitest":"^1.4.0"},"scripts":{"build":"vite build","bench":"vitest bench","format":"prettier -w .","test":"vitest","release":"npx np"},"bugs":{"url":"https://github.com/wmertens/jsurl2/issues"},"_id":"jsurl2@2.2.0","_integrity":"sha512-jFwgc2G7eVMF6/uyxsF+7DbNEg7fj7SRWmJuVfu/SAOK0iIH9gOpLK9FL1jLvENCXS7kYsYcmFxRFQFyQEb7jg==","_resolved":"/tmp/246dbfdc7409dd78be20e9e4a23e87be/jsurl2-2.2.0.tgz","_from":"file:jsurl2-2.2.0.tgz","_nodeVersion":"18.18.2","_npmVersion":"9.8.1","dist":{"integrity":"sha512-jFwgc2G7eVMF6/uyxsF+7DbNEg7fj7SRWmJuVfu/SAOK0iIH9gOpLK9FL1jLvENCXS7kYsYcmFxRFQFyQEb7jg==","shasum":"627d452d6c4cbf443bb7c09718bcbbfff4ebba90","tarball":"https://registry.npmjs.org/jsurl2/-/jsurl2-2.2.0.tgz","fileCount":8,"unpackedSize":42740,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQDXjIVne2iK+Waa3Q3k74/qc2j4NOLnPsAvuxj4vFwL0gIhAMcnchFASEQie9PV1yYAkP7YpIpMGpZ3zMB7RZdjr547"}]},"_npmUser":{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"},"directories":{},"maintainers":[{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/jsurl2_2.2.0_1711787776067_0.20207541507273818"},"_hasShrinkwrap":false}},"time":{"created":"2021-08-11T11:42:10.797Z","2.1.0":"2021-08-11T11:42:10.933Z","modified":"2024-03-30T08:36:16.387Z","2.1.1":"2024-02-07T18:18:07.817Z","2.2.0":"2024-03-30T08:36:16.221Z"},"maintainers":[{"name":"wmertens","email":"Wout.Mertens+npm@gmail.com"}],"description":"URL friendly JSON-like formatting and parsing","homepage":"http://github.com/wmertens/jsurl2","repository":{"type":"git","url":"git://github.com/wmertens/jsurl2.git"},"author":{"name":"Wout Mertens"},"bugs":{"url":"https://github.com/wmertens/jsurl2/issues"},"license":"MIT","readme":"# JSURL2\n\nLive demo: https://wmertens.github.io/jsurl2/\nLive editor: https://cv122s.csb.app/\n\nJSURL2 aims to be a drop-in replacement for JSON encoding with better size and time characteristics.\n\nJSURL2 has been designed to be\n\n- Compact: shorter output than JSON\n- Readable: it leaves accented characters unchanged and doesn't add much characters for encoding\n- URI-ready: It does not encode everything that should be URI-encoded, but it does encode all delimiters of query strings.\n  - You can embed it as part of a query string, and normally you won't need to do any URI encoding yourself (browser/http client will take care of that).\n  - It will be correctly detected as part of the URI by most auto-URL-from-text implementations.\n- Embeddable:\n  - You can safely put it in `<script>` tags inside single-quoted Javascript strings (unlike JSON)\n  - Added whitespace can simply be removed, it is not used\n- Extensible:\n  - `rich` mode encodes/decodes `Date` objects, `undefined`, `NaN` and `Infinity`\n  - Future: The encoding dictionary can be extended, providing more space optimization\n  - Future: You can provide your own stringify/parse for custom objects\n- Easy upgrade:\n  - Simply replace `JSON.parse` with `JSURL.parse` and `JSON.stringify` with `JSURL.stringify`\n  - Parses JSON as well\n  - A stringify/parse cycle generates the same output as with JSON\n  - (one exception: it always returns a string, even when JSON would return `undefined`)\n  - It will never generate valid JSON except when it's the correct representation\n- Fast-ish: our test suite used to outperform JSON but recent v8 optimizations made JSON faster again\n\nGiven its speed and size, it is well-suited to pass JS values to scripts in HTML, like initial data after Server-Side-Rendering. To do so, embed the result inside a single-quoted string (not double-quoted) and parse that in your script.\n\nSome room has been left in the encoding space for special values. If you enable `rich` on the stringifier, it will encode JS Date objects so that they decode as JS Date objects, and later it might support custom encode/decode of your own object types.\n\n## Examples\n\nJSON:\n\n```json\n{\"name\": \"John Doé\", \"age\": 42, \"user\": true, \"children\": [\"Mary\", \"Bill\"]}\n```\n\nJSON + URI encoding:\n\n```text\n%7B%22name%22%3A%22John%20Do%C3%22%2C%22age%22%3A42%2C%22user%22%3Atrue%2C%22children%22%3A%5B%22Mary%22%2C%22Bill%22%5D%7D\n```\n\nJSURL2:\n\n```jsurl\n(name~John_Doé~age~42~user~~children~!Mary~Bill)~\n```\n\nJSURL2 + URI encoding:\n\n```text\n(name~John_Do%C3%A9~age~42~user~~children~!Mary~Bill)~\n```\n\n## Installing\n\nThe easiest way to [install `jsurl2` is with NPM](https://www.npmjs.com/package/jsurl2):\n\n```sh\nnpm install jsurl2\n```\n\n## API\n\n```javascript\nvar JSURL = require(\"jsurl2\");\n\n// Options:\n// * `rich`: encode Date, `undefined`, `Infinity`\n// * `short`: remove optional trailing delimiters\nstr = JSURL.stringify(obj[, options]);\n\n// Options:\n// * `deURI`: remove URI encoding and whitespace\nobj = JSURL.parse(str[, options]);\n\n// return `default` instead of throwing on error; options are passed to `parse()`\nobj = JSURL.tryParse(str[, default][, options]);\n```\n\n## Syntax\n\nJSURL uses the allowable characters in URI schemes for multiple purposes depending on the location in the result. Some examples:\n\n- `!` starts an array if it is the first character in a value, but inside a string it is unchanged.\n- `~` and `)` are used as end-of-value and end-of-object delimiters, and are illegal inside encoded values.\n- `*` starts a string, but can be left out if the first string character is a-z. Inside a string, it escapes special characters.\n- whitespace is never legal, so you can strip it before parsing if it can be introduced accidentally\n\nJSURL has a `short` mode, which omits the unnecessary ending delimiters. You can use this to save a few more bytes, but you won't be able to spot an encoded value on sight by the ending `~`.\n\nSince browsers may choose to encode any character with URI escaping, and special characters are shown in URLs, no attempt is made to make v2 URI-neutral. Decoding will work no matter how many encodings happened, if you pass the `deURI: true` option to the parser.\n\n## Roadmap\n\n- Indenting\n  - `stringify` adds whitespace (post-process, too slow in parser code)\n- Encoding dictionary\n  - Pass to `parse` and `stringify`\n  - Allow embedding dictionary in encoded output\n    - Only embed used keys\n    - Auto mode that encodes object keys with length > 4\n- Custom encoding\n  - Dictionary of encoders that get called on Objects\n  - First one to return a value other than `undefined` wins\n  - Decoders get called on their encoded values\n- `new JSURL`-based API to prepare custom encoding and dictionary\n- Interactive demo webpage\n  - Examples that you can edit with JSON/JSURL side-by-side\n  - For each example, compare with JSON: length, length when URI encoded, stringify speed, parse speed\n  - Benchmark: generates random objects to encode, average space and time savings\n- Async/streaming decoding\n  - Would also allow creating initial state in a webpage without first allocating the whole string\n\n## License\n\nThis work is licensed under the [MIT license](http://en.wikipedia.org/wiki/MIT_License).\n","readmeFilename":"README.md","keywords":["json","url","query","stringify","parse","serialize","deserialize"]}