diff --git a/README.md b/README.md index 867ffcd..50e6b42 100644 --- a/README.md +++ b/README.md @@ -9,8 +9,8 @@ Note: `fromHex` and `compare` mimic the `Buffer.from('ff', 'hex')` and as well as in Node. ```js -import * as uint8arraytools from 'uint8array-tools'; -uint8arraytools.fromHex('ff'); +import * as uint8arraytools from "uint8array-tools"; +uint8arraytools.fromHex("ff"); // Uint8Array(1) [ 255 ] uint8arraytools.toHex(Uint8Array.from([0xff])); // 'ff' @@ -20,4 +20,21 @@ uint8arraytools.compare(Uint8Array.from([0xff]), Uint8Array.from([0xff])); // 0 uint8arraytools.compare(Uint8Array.from([0x01]), Uint8Array.from([0xff])); // -1 -``` \ No newline at end of file +uint8arraytools.fromUtf8("tools"); +// Uint8Array(5) [ 116, 111, 111, 108, 115 ] +uint8arraytools.toUtf8(Uint8Array.from([116, 111, 111, 108, 115])); +// tools +uint8arraytools.concat([Uint8Array.from([1]), Uint8Array.from([2])]); +// Uint8Array(2) [ 1, 2 ] +uint8arraytools.fromBase64("dG9vbHM="); +// Uint8Array(3) [ 182, 138, 37 ] +uint8arraytools.toBase64(Uint8Array.from([116, 111, 111, 108, 115])); +// dG9vbHM= + +const uint8array = new Uint8Array(2); +uint8arraytools.writeUInt16(uint8array, 0, 0xffff - 1, "LE"); +uint8array; +// Uint8Array(2) [ 254, 255 ] +uint8arraytools.readUInt16(uint8array, 0, "LE"); +// 65534 +``` diff --git a/package.json b/package.json index 1f6f13d..2d5fb07 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "uint8array-tools", - "version": "0.0.7", + "version": "0.0.8", "description": "A library for dealing with Uint8Arrays.", "homepage": "https://github.com/bitcoinjs/uint8array-tools#readme", "bugs": {