{"id":17749530,"url":"https://github.com/oresoftware/siamese","last_synced_at":"2025-06-16T06:31:55.134Z","repository":{"id":95713168,"uuid":"262218965","full_name":"ORESoftware/siamese","owner":"ORESoftware","description":null,"archived":false,"fork":false,"pushed_at":"2020-05-08T03:35:49.000Z","size":29,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-05-18T16:54:46.170Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"JavaScript","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/ORESoftware.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2020-05-08T03:35:26.000Z","updated_at":"2020-05-14T08:05:51.000Z","dependencies_parsed_at":"2023-05-21T17:45:09.411Z","dependency_job_id":null,"html_url":"https://github.com/ORESoftware/siamese","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/ORESoftware/siamese","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsiamese","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsiamese/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsiamese/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsiamese/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/ORESoftware","download_url":"https://codeload.github.com/ORESoftware/siamese/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/ORESoftware%2Fsiamese/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":260114268,"owners_count":22960865,"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":[],"created_at":"2024-10-26T11:23:37.712Z","updated_at":"2025-06-16T06:31:55.049Z","avatar_url":"https://github.com/ORESoftware.png","language":"JavaScript","readme":"\n\n# Siamese = Idempotent JSON + Promisification\n\n\n## Installation\n\n```bash\n $ npm install siamese -S\n```\n\n# Purpose\n\n1. \u003cb\u003ePrevent yak shaving\u003c/b\u003e - stop \u003ci\u003eworrying\u003c/i\u003e about whether what your parsing is already parsed.\n2. \u003cb\u003eAvoid try/catch\u003c/b\u003e - we have promisified JSON.parse()/JSON.stringify - so no more try/catch needed. \n\n\n## Basic usage\n\n```js \nconst siam = global.siam = require('siamese');  // you have the choice whether it's global or not\n\n```\n\nThis library provides two primary features that I believe are unfortunately missing from the JSON spec\n\n1 =\u003e Idempotence =\u003e\n\n* If you parse something twice, it shouldn't throw an error, it should just return what you gave it\n* If you stringify something twice, or thrice, etc, it shouldn't keep stringifying, and accumulating endless escape characters in the process\n\n2 =\u003e Error handling and flow control with ES6 Promises =\u003e\n\n* Promises do synchronous error-handling out-of-the-box (just don't forget the rejection handler or catch block)\n* We can pass promises to siam.parse() and siam.stringify() and it can parse/stringify the resolution of the promise\n\n\n## Usage\n\n```js\n\n // won't throw an error, even though we passed it a plain object\n \nsiam.parse({foo:'bar'}).then(function(val){  \n    console.log(val);  // =\u003e  {foo:'bar'}\n})\n.catch(function(err){\n     //nope\n});\n\n\n// you can pass it a promise like so:\n\nsiam.parse(new Promise((resolve) =\u003e resolve({foo:'bar'})))\n.then(function(val){\n\n})\n.catch(function(err){\n\n});\n\n\n// since siam.parse and siam.stringify return promises you can do this if you really want to\n\nPromise.all([\n    siam.parse(x),\n    siam.parse(y),\n    siam.stringify(z)\n])\n\n// and since siam.parse and siam.stringify accept promises as arguments, you can do\n\nsiam.parse(siam.stringify(siam.stringify(siam.stringify({foo:'bar'})))).then(function(val){\n    console.log(val);\n});\n\n\n// and since these functions are now idempotent, the final result of the above is:\n\n\n{foo:'bar'}\n```\n\n### voilà !\n\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foresoftware%2Fsiamese","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foresoftware%2Fsiamese","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foresoftware%2Fsiamese/lists"}