Skip to content

Commit

Permalink
Merge pull request #10 from Nesopie/bump/0.0.8
Browse files Browse the repository at this point in the history
0.0.8
  • Loading branch information
junderw authored Aug 1, 2024
2 parents 8f9696a + db4f3ce commit 8218fc0
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 4 deletions.
23 changes: 20 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -20,4 +20,21 @@ uint8arraytools.compare(Uint8Array.from([0xff]), Uint8Array.from([0xff]));
// 0
uint8arraytools.compare(Uint8Array.from([0x01]), Uint8Array.from([0xff]));
// -1
```
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
```
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand Down

0 comments on commit 8218fc0

Please sign in to comment.