@etomon/encode-tools
Advanced tools
Comparing version 1.0.2 to 1.1.0
{ | ||
"name": "@etomon/encode-tools", | ||
"version": "1.0.2", | ||
"version": "1.1.0", | ||
"description": "This package aggregates different libraries for encoding, serializing, generating ids and hashing things, exposing a common interface.", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
@@ -7,2 +7,35 @@ # Etomon Encode Tools | ||
## Examples | ||
Encoding a Buffer as base64url | ||
``` | ||
let enc = new EncodeTools(); | ||
let buf = Buffer.from('hello world', 'utf8'); | ||
let newBuf = enc.encodeBuffer(buf, BinaryEncoding.base64url); | ||
console.log(newBuf.toString('utf8')); | ||
``` | ||
Hashing an object wth xxhash | ||
``` | ||
let enc = new EncodeTools(); | ||
let obj = { foo: 'bar' }; | ||
let newBuf = await enc.hashObject(obj, HashAlgorithm.xxhash64); | ||
console.log(newBuf.toString('utf8')); | ||
``` | ||
Serializing an object wth msgpack | ||
``` | ||
let enc = new EncodeTools(); | ||
let obj = { foo: 'bar' }; | ||
let newBuf = await enc.serializeObject(obj, SerializationFormat.msgpack); | ||
console.log(newBuf.toString('utf8')); | ||
``` | ||
Generating a base64-encoded UUID v4 | ||
``` | ||
let enc = new EncodeTools(); | ||
let newBuf = await enc.uniqueId(IDFormat.uuidv4); | ||
console.log(newBuf.toString('base64')); | ||
``` | ||
## Algorithms | ||
@@ -9,0 +42,0 @@ |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
848185
104