Skip to content

Commit e646337

Browse files
committed
doc: improve docs, add import samples
1 parent 4768915 commit e646337

File tree

1 file changed

+83
-17
lines changed

1 file changed

+83
-17
lines changed

README.md

Lines changed: 83 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -78,20 +78,39 @@ See [the list of encodings](https://encoding.spec.whatwg.org/#names-and-labels).
7878

7979
### `@exodus/bytes/utf8.js`
8080

81+
```js
82+
import { utf8fromString, utf8toString } from '@exodus/bytes/utf8.js'
83+
84+
// loose
85+
import { utf8fromStringLoose, utf8toStringLoose } from '@exodus/bytes/utf8.js'
86+
```
87+
8188
##### `utf8fromString(str, format = 'uint8')`
8289
##### `utf8fromStringLoose(str, format = 'uint8')`
8390
##### `utf8toString(arr)`
8491
##### `utf8toStringLoose(arr)`
8592

8693
### `@exodus/bytes/utf16.js`
8794

95+
```js
96+
import { utf16fromString, utf16toString } from '@exodus/bytes/utf16.js'
97+
98+
// loose
99+
import { utf16fromStringLoose, utf16toStringLoose } from '@exodus/bytes/utf16.js'
100+
```
101+
88102
##### `utf16fromString(str, format = 'uint16')`
89103
##### `utf16fromStringLoose(str, format = 'uint16')`
90104
##### `utf16toString(arr, 'uint16')`
91105
##### `utf16toStringLoose(arr, 'uint16')`
92106

93107
### `@exodus/bytes/single-byte.js`
94108

109+
```js
110+
import { createSinglebyteDecoder } from '@exodus/bytes/single-byte.js'
111+
import { windows1252toString } from '@exodus/bytes/single-byte.js'
112+
```
113+
95114
Decode the legacy single-byte encodings according to the [Encoding standard](https://encoding.spec.whatwg.org/)
96115
([§9](https://encoding.spec.whatwg.org/#legacy-single-byte-encodings) and
97116
[§14.5](https://encoding.spec.whatwg.org/#x-user-defined)).
@@ -118,11 +137,15 @@ There is no loose variant for this encoding, all bytes can be decoded.
118137

119138
Same as:
120139
```js
121-
windows1252toString = createSinglebyteDecoder('windows-1252')
140+
const windows1252toString = createSinglebyteDecoder('windows-1252')
122141
```
123142

124143
### `@exodus/bytes/multi-byte.js`
125144

145+
```js
146+
import { createMultibyteDecoder } from '@exodus/bytes/multi-byte.js'
147+
```
148+
126149
Decode the legacy multi-byte encodings according to the [Encoding standard](https://encoding.spec.whatwg.org/)
127150
([§10](https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(simplified)-encodings),
128151
[§11](https://encoding.spec.whatwg.org/#legacy-multi-byte-chinese-(traditional)-encodings),
@@ -142,76 +165,119 @@ That function will have state while `stream = true` is used.
142165

143166
### `@exodus/bytes/bigint.js`
144167

168+
```js
169+
import { fromBigInt, toBigInt } from '@exodus/bytes/bigint.js'
170+
```
171+
145172
##### `fromBigInt(bigint, { length, format = 'uint8' })`
146173
##### `toBigInt(arr)`
147174

148175
### `@exodus/bytes/hex.js`
149176

150-
##### `toHex(arr)`
177+
```js
178+
import { fromHex, toHex } from '@exodus/bytes/hex.js'
179+
```
180+
151181
##### `fromHex(string)`
182+
##### `toHex(arr)`
152183

153184
### `@exodus/bytes/base64.js`
154185

155-
##### `toBase64(arr, { padding = true })`
156-
##### `toBase64url(arr, { padding = false })`
186+
```js
187+
import { fromBase64, toBase64 } from '@exodus/bytes/base64.js'
188+
import { fromBase64url, toBase64url } from '@exodus/bytes/base64.js'
189+
import { fromBase64any } from '@exodus/bytes/base64.js'
190+
```
191+
157192
##### `fromBase64(str, { format = 'uint8', padding = 'both' })`
158193
##### `fromBase64url(str, { format = 'uint8', padding = false })`
159194
##### `fromBase64any(str, { format = 'uint8', padding = 'both' })`
195+
##### `toBase64(arr, { padding = true })`
196+
##### `toBase64url(arr, { padding = false })`
160197

161198
### `@exodus/bytes/base32.js`
162199

163-
##### `toBase32(arr, { padding = false })`
164-
##### `toBase32hex(arr, { padding = false })`
200+
```js
201+
import { fromBase32, toBase32 } from '@exodus/bytes/base32.js'
202+
import { fromBase32hex, toBase32hex } from '@exodus/bytes/base32.js'
203+
```
204+
165205
##### `fromBase32(str, { format = 'uint8', padding = 'both' })`
166206
##### `fromBase32hex(str, { format = 'uint8', padding = 'both' })`
207+
##### `toBase32(arr, { padding = false })`
208+
##### `toBase32hex(arr, { padding = false })`
167209

168210
### `@exodus/bytes/bech32.js`
169211

212+
```js
213+
import { fromBech32, toBech32 } from '@exodus/bytes/bech32.js'
214+
import { fromBech32m, toBech32m } from '@exodus/bytes/base32.js'
215+
import { getPrefix } from '@exodus/bytes/base32.js'
216+
```
217+
170218
##### `getPrefix(str, limit = 90)`
171-
##### `toBech32(prefix, bytes, limit = 90)`
219+
172220
##### `fromBech32(str, limit = 90)`
173-
##### `toBech32m(prefix, bytes, limit = 90)`
221+
##### `toBech32(prefix, bytes, limit = 90)`
222+
174223
##### `fromBech32m(str, limit = 90)`
224+
##### `toBech32m(prefix, bytes, limit = 90)`
175225

176226
### `@exodus/bytes/base58.js`
177227

178-
##### `toBase58(arr)`
228+
```js
229+
import { fromBase58, toBase58 } from '@exodus/bytes/base58.js'
230+
import { fromBase58xrp, toBase58xrp } from '@exodus/bytes/base58.js'
231+
```
232+
179233
##### `fromBase58(str, format = 'uint8')`
234+
##### `toBase58(arr)`
180235

181-
##### `toBase58xrp(arr)`
182236
##### `fromBase58xrp(str, format = 'uint8')`
237+
##### `toBase58xrp(arr)`
183238

184239
### `@exodus/bytes/base58check.js`
185240

241+
```js
242+
import { fromBase58check, toBase58check } from '@exodus/bytes/base58check.js'
243+
import { fromBase58checkSync, toBase58checkSync } from '@exodus/bytes/base58check.js'
244+
import { makeBase58check } from '@exodus/bytes/base58check.js'
245+
```
246+
186247
On non-Node.js, requires peer dependency [@exodus/crypto](https://www.npmjs.com/package/@exodus/crypto) to be installed.
187248

188-
##### `async toBase58check(arr)`
189-
##### `toBase58checkSync(arr)`
190249
##### `async fromBase58check(str, format = 'uint8')`
250+
##### `async toBase58check(arr)`
191251
##### `fromBase58checkSync(str, format = 'uint8')`
252+
##### `toBase58checkSync(arr)`
192253
##### `makeBase58check(hashAlgo, hashAlgoSync)`
193254

194255
### `@exodus/bytes/wif.js`
195256

257+
```js
258+
import { fromWifString, toWifString } from '@exodus/bytes/wif.js'
259+
import { fromWifStringSync, toWifStringSync } from '@exodus/bytes/wif.js'
260+
```
261+
196262
##### `async fromWifString(string, version)`
197263
##### `fromWifStringSync(string, version)`
198264
##### `async toWifString({ version, privateKey, compressed })`
199265
##### `toWifStringSync({ version, privateKey, compressed })`
200266

201267
### `@exodus/bytes/encoding.js`
202268

203-
Implements the [Encoding standard](https://encoding.spec.whatwg.org/):
204-
[TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder),
205-
[TextEncoder](https://encoding.spec.whatwg.org/#interface-textdecoder),
206-
some [hooks](https://encoding.spec.whatwg.org/#specification-hooks) (see below).
207-
208269
```js
209270
import { TextDecoder, TextDecoder } from '@exodus/bytes/encoding.js'
210271

211272
// Hooks for standards
212273
import { getBOMEncoding, legacyHookDecode, labelToName, normalizeEncoding } from '@exodus/bytes/encoding.js'
213274
```
214275

276+
Implements the [Encoding standard](https://encoding.spec.whatwg.org/):
277+
[TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder),
278+
[TextEncoder](https://encoding.spec.whatwg.org/#interface-textdecoder),
279+
some [hooks](https://encoding.spec.whatwg.org/#specification-hooks) (see below).
280+
215281
#### `new TextDecoder(label = 'utf-8', { fatal = false, ignoreBOM = false })`
216282

217283
[TextDecoder](https://encoding.spec.whatwg.org/#interface-textdecoder) implementation/polyfill.

0 commit comments

Comments
 (0)