1.1.3 • Published 25 days ago

@neshca/json-replacer-reviver v1.1.3

Weekly downloads
-
License
MIT
Repository
github
Last release
25 days ago

@neshca/json-replacer-reviver

Utility library for handling Buffer object serialization and deserialization with JSON, offering base64 representations.

npm package Dependencies License

Installation

npm i @neshca/json-replacer-reviver

Usage

const buffer = Buffer.from('hello');
console.log(buffer); // <Buffer 68 65 6c 6c 6f>

const json = JSON.stringify(buffer);
console.log(json); // '{"type":"Buffer","data":[104,101,108,108,111]}'

const parsed = JSON.parse(json, reviveFromJsonRepresentation);
console.log(parsed); // <Buffer 68 65 6c 6c 6f>
const buffer = Buffer.from('hello');
console.log(buffer); // <Buffer 68 65 6c 6c 6f>

const jsonBase64 = JSON.stringify(buffer, replaceJsonWithBase64);
console.log(jsonBase64); // '{"type":"BufferBase64","data":"aGVsbG8="}'

const parsedFromBase64 = JSON.parse(jsonBase64, reviveFromBase64Representation);
console.log(parsed); // <Buffer 68 65 6c 6c 6f>

Developing and contributing

Developing and contributing to this monorepo

Running tests locally

npm run test -w ./packages/json-replacer-reviver

License

MIT

1.1.3

25 days ago

1.1.2

2 months ago

1.1.1

3 months ago

1.1.0

6 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago

13.5.3

7 months ago