3333 - [ ` put(key, value, [options]) ` -> ` Promise ` ] ( #putkey-value-options---promise )
3434 - [ Arguments] ( #arguments-1 )
3535 - [ Example] ( #example-1 )
36- - [ ` putMany(source, [options]) ` -> ` AsyncIterator<{ key: Key, value: Buffer }> ` ] ( #putmanysource-options---asynciterator-key-key-value-buffer - )
36+ - [ ` putMany(source, [options]) ` -> ` AsyncIterator<{ key: Key, value: Uint8Array }> ` ] ( #putmanysource-options---asynciterator-key-key-value-uint8array - )
3737 - [ Arguments] ( #arguments-2 )
3838 - [ Example] ( #example-2 )
39- - [ ` get(key, [options]) ` -> ` Promise<Buffer > ` ] ( #getkey-options---promisebuffer )
39+ - [ ` get(key, [options]) ` -> ` Promise<Uint8Array > ` ] ( #getkey-options---promiseuint8array )
4040 - [ Arguments] ( #arguments-3 )
4141 - [ Example] ( #example-3 )
42- - [ ` getMany(source, [options]) ` -> ` AsyncIterator<Buffer > ` ] ( #getmanysource-options---asynciteratorbuffer )
42+ - [ ` getMany(source, [options]) ` -> ` AsyncIterator<Uint8Array > ` ] ( #getmanysource-options---asynciteratoruint8array )
4343 - [ Arguments] ( #arguments-4 )
4444 - [ Example] ( #example-4 )
4545 - [ ` delete(key, [options]) ` -> ` Promise ` ] ( #deletekey-options---promise )
4848 - [ ` deleteMany(source, [options]) ` -> ` AsyncIterator<Key> ` ] ( #deletemanysource-options---asynciteratorkey )
4949 - [ Arguments] ( #arguments-6 )
5050 - [ Example] ( #example-6 )
51- - [ ` query(query, [options]) ` -> ` AsyncIterable<Buffer > ` ] ( #queryquery-options---asynciterablebuffer )
51+ - [ ` query(query, [options]) ` -> ` AsyncIterable<Uint8Array > ` ] ( #queryquery-options---asynciterableuint8array )
5252 - [ Arguments] ( #arguments-7 )
5353 - [ Example] ( #example-7 )
5454 - [ ` batch() ` ] ( #batch )
@@ -179,11 +179,11 @@ for await (const { key, data } of batch(store.putMany(source), 10)) {
179179
180180### Keys
181181
182- To allow a better abstraction on how to address values, there is a ` Key ` class which is used as identifier. It's easy to create a key from a ` Buffer ` or a ` string ` .
182+ To allow a better abstraction on how to address values, there is a ` Key ` class which is used as identifier. It's easy to create a key from a ` Uint8Array ` or a ` string ` .
183183
184184``` js
185185const a = new Key (' a' )
186- const b = new Key (Buffer . from ( ' hello ' ))
186+ const b = new Key (new Uint8Array ([ 0 , 1 , 2 , 3 ] ))
187187```
188188
189189The key scheme is inspired by file systems and Google App Engine key model. Keys are meant to be unique across a system. They are typically hierarchical, incorporating more and more specific namespaces. Thus keys can be deemed 'children' or 'ancestors' of other keys:
@@ -234,41 +234,41 @@ Store a value with the given key.
234234| Name | Type | Description |
235235| ---- | ---- | ----------- |
236236| key | [ Key] [ ] | The key to store the value under |
237- | value | [ Buffer ] [ ] | Value to store |
237+ | value | [ Uint8Array ] [ ] | Value to store |
238238| options | [ Object] [ ] | An options object, all properties are optional |
239239| options.signal | [ AbortSignal] [ ] | A way to signal that the caller is no longer interested in the outcome of this operation |
240240
241241#### Example
242242
243243``` js
244- await store .put ([{ key: new Key (' awesome' ), value: Buffer . from ( ' datastores ' ) }])
244+ await store .put ([{ key: new Key (' awesome' ), value: new Uint8Array ([ 0 , 1 , 2 , 3 ] ) }])
245245console .log (' put content' )
246246```
247247
248- ### ` putMany(source, [options]) ` -> ` AsyncIterator<{ key: Key, value: Buffer }> `
248+ ### ` putMany(source, [options]) ` -> ` AsyncIterator<{ key: Key, value: Uint8Array }> `
249249
250250Store many key-value pairs.
251251
252252#### Arguments
253253
254254| Name | Type | Description |
255255| ---- | ---- | ----------- |
256- | source | [ AsyncIterator] [ ] <{ key: [ Key] [ ] , value: [ Buffer ] [ ] }> | The key to store the value under |
257- | value | [ Buffer ] [ ] | Value to store |
256+ | source | [ AsyncIterator] [ ] <{ key: [ Key] [ ] , value: [ Uint8Array ] [ ] }> | The key to store the value under |
257+ | value | [ Uint8Array ] [ ] | Value to store |
258258| options | [ Object] [ ] | An options object, all properties are optional |
259259| options.signal | [ AbortSignal] [ ] | A way to signal that the caller is no longer interested in the outcome of this operation |
260260
261261#### Example
262262
263263``` js
264- const source = [{ key: new Key (' awesome' ), value: Buffer . from ( ' datastores ' ) }]
264+ const source = [{ key: new Key (' awesome' ), value: new Uint8Array ([ 0 , 1 , 2 , 3 ] ) }]
265265
266266for await (const { key , value } of store .putMany (source)) {
267267 console .info (` put content for key ${ key} ` )
268268}
269269```
270270
271- ### ` get(key, [options]) ` -> ` Promise<Buffer > `
271+ ### ` get(key, [options]) ` -> ` Promise<Uint8Array > `
272272
273273#### Arguments
274274
@@ -288,7 +288,7 @@ console.log('got content: %s', value.toString('utf8'))
288288// => got content: datastore
289289```
290290
291- ### ` getMany(source, [options]) ` -> ` AsyncIterator<Buffer > `
291+ ### ` getMany(source, [options]) ` -> ` AsyncIterator<Uint8Array > `
292292
293293#### Arguments
294294
@@ -304,7 +304,7 @@ Retrieve a stream of values stored under the given keys.
304304
305305``` js
306306for await (const value of store .getMany ([new Key (' awesome' )])) {
307- console .log (' got content: %s ' , value . toString (' utf8' ))
307+ console .log (' got content:' , new TextDecoder (' utf8' ). decode (value ))
308308 // => got content: datastore
309309}
310310```
@@ -350,18 +350,18 @@ for await (const key of store.deleteMany(source)) {
350350}
351351```
352352
353- ### ` query(query, [options]) ` -> ` AsyncIterable<Buffer > `
353+ ### ` query(query, [options]) ` -> ` AsyncIterable<Uint8Array > `
354354
355- Search the store for some values. Returns an [ AsyncIterable] [ ] with each item being a [ Buffer ] [ ] .
355+ Search the store for some values. Returns an [ AsyncIterable] [ ] with each item being a [ Uint8Array ] [ ] .
356356
357357#### Arguments
358358
359359| Name | Type | Description |
360360| ---- | ---- | ----------- |
361361| query | [ Object] [ ] | A query object, all properties are optional |
362362| query.prefix | [ String] [ ] | Only return values where the key starts with this prefix |
363- | query.filters | [ Array] [ ] <[ Function] [ ] ( [Buffer ][] ) -> [ Boolean] [ ] > | Filter the results according to the these functions |
364- | query.orders | [ Array] [ ] <[ Function] [ ] ( [Array][]<[Buffer ][]> ) -> [ Array] [ ] <[ Buffer ] [ ] >> | Order the results according to these functions |
363+ | query.filters | [ Array] [ ] <[ Function] [ ] ( [Uint8Array ][] ) -> [ Boolean] [ ] > | Filter the results according to the these functions |
364+ | query.orders | [ Array] [ ] <[ Function] [ ] ( [Array][]<[Uint8Array ][]> ) -> [ Array] [ ] <[ Uint8Array ] [ ] >> | Order the results according to these functions |
365365| query.limit | [ Number] [ ] | Only return this many records |
366366| query.offset | [ Number] [ ] | Skip this many records at the beginning |
367367| options | [ Object] [ ] | An options object, all properties are optional |
@@ -388,7 +388,7 @@ This will return an object with which you can chain multiple operations together
388388const b = store .batch ()
389389
390390for (let i = 0 ; i < 100 ; i++ ) {
391- b .put (new Key (` hello${ i} ` ), Buffer . from (` hello world ${ i} ` ))
391+ b .put (new Key (` hello${ i} ` ), new TextEncoder ( ' utf8 ' ). encode (` hello world ${ i} ` ))
392392}
393393
394394await b .commit ()
@@ -402,7 +402,7 @@ Queue a put operation to the store.
402402| Name | Type | Description |
403403| ---- | ---- | ----------- |
404404| key | [ Key] [ ] | The key to store the value under |
405- | value | [ Buffer ] [ ] | Value to store |
405+ | value | [ Uint8Array ] [ ] | Value to store |
406406
407407#### ` delete(key) `
408408
@@ -428,7 +428,7 @@ Write all queued operations to the underyling store. The batch object should not
428428``` js
429429const batch = store .batch ()
430430
431- batch .put (new Key (' to-put' ), Buffer . from (' hello world' ))
431+ batch .put (new Key (' to-put' ), new TextEncoder ( ' utf8 ' ). encode (' hello world' ))
432432batch .del (new Key (' to-remove' ))
433433
434434await batch .commit ()
@@ -455,7 +455,7 @@ MIT 2017 © IPFS
455455
456456[ Key ] : #Keys
457457[ Object ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object
458- [ Buffer ] : https://nodejs. org/api/buffer.html
458+ [ Uint8Array ] : https://developer.mozilla. org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Uint8Array
459459[ AbortSignal ] : https://developer.mozilla.org/en-US/docs/Web/API/AbortSignal
460460[ AsyncIterator ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Symbol/asyncIterator
461461[ AsyncIterable ] : https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Iteration_protocols
0 commit comments