From b4e5ed679df7b56f901da0b937d2ba44d60ae356 Mon Sep 17 00:00:00 2001 From: Alex / KATT Date: Sat, 30 Sep 2023 21:57:22 +0200 Subject: [PATCH] feat: add readme (#3) --- CHANGELOG.md | 9 +++------ README.md | 26 +++++++++++++++++++++++++- src/index.ts | 2 ++ 3 files changed, 30 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 58f969ed..43e86c79 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,10 +1,7 @@ - - # 0.2.0 (2023-09-30) - ### Features -* add `createTupleson` fn and more ([#2](https://github.com/KATT/tupleson/issues/2)) ([72910ae](https://github.com/KATT/tupleson/commit/72910ae35c55581b860207e8e45ac098f5bef6ad)) -* initial version ([#1](https://github.com/KATT/tupleson/issues/1)) ([ccce25b](https://github.com/KATT/tupleson/commit/ccce25b6a039cf2e5c1a774c1ab022f0946ca8d5)) -* initialized repo ✨ ([c9e92a4](https://github.com/KATT/tupleson/commit/c9e92a42c97a8bc1ee3a9214f65626425c8598e3)) \ No newline at end of file +- add `createTupleson` fn and more ([#2](https://github.com/KATT/tupleson/issues/2)) ([72910ae](https://github.com/KATT/tupleson/commit/72910ae35c55581b860207e8e45ac098f5bef6ad)) +- initial version ([#1](https://github.com/KATT/tupleson/issues/1)) ([ccce25b](https://github.com/KATT/tupleson/commit/ccce25b6a039cf2e5c1a774c1ab022f0946ca8d5)) +- initialized repo ✨ ([c9e92a4](https://github.com/KATT/tupleson/commit/c9e92a42c97a8bc1ee3a9214f65626425c8598e3)) diff --git a/README.md b/README.md index c40d9ce9..387af25d 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,31 @@ ## Introduction -Not much to see yet, but you can spy on the tests. +A hackable JSON serializer/deserializer that allows you to serialize/deserialize almost[^1] anything. + +### Example + +```ts +const json = createTupleson({ + // This nonce function is used to generate a nonce for the serialized value + // This is used to identify the value as a serialized value + nonce: () => "__tson", + types: [tsonSet], +}); + +const result = json.stringify( + { + foo: "bar", + set: new Set([1, 2, 3]), + }, + 2, +); +console.log(result); +``` + +**Footnotes**: + +[^1]: We don't support circular references as we don't think it's very desireable, but if you wanna contribute with adding opt-in support for that, you are very welcome! ## Contributors diff --git a/src/index.ts b/src/index.ts index 21fc3845..c4c93f3d 100644 --- a/src/index.ts +++ b/src/index.ts @@ -5,3 +5,5 @@ export { tsonSerializer, tsonStringifier, } from "./tson.js"; + +export * from "./handlers/index.js";