1- # IPFS Repo JavaScript Implementation
1+ # IPFS Repo JavaScript Implementation <!-- omit in toc -->
22
33[ ![ ] ( https://img.shields.io/badge/made%20by-Protocol%20Labs-blue.svg?style=flat-square )] ( http://ipn.io )
44[ ![ ] ( https://img.shields.io/badge/project-IPFS-blue.svg?style=flat-square )] ( http://ipfs.io/ )
1414
1515This is the implementation of the [ IPFS repo spec] ( https://github.com/ipfs/specs/blob/master/REPO.md ) in JavaScript.
1616
17- ## Lead Maintainer
17+ ## Lead Maintainer <!-- omit in toc -->
1818
1919[ Alex Potsides] ( https://github.com/achingbrain )
2020
21- ## Table of Contents
21+ ## Table of Contents <!-- omit in toc -->
2222
2323- [ Background] ( #background )
2424- [ Install] ( #install )
@@ -28,7 +28,40 @@ This is the implementation of the [IPFS repo spec](https://github.com/ipfs/specs
2828 - [ Use in a browser Using a script tag] ( #use-in-a-browser-using-a-script-tag )
2929- [ Usage] ( #usage )
3030- [ API] ( #api )
31+ - [ Setup] ( #setup )
32+ - [ ` new Repo(path[, options]) ` ] ( #new-repopath-options )
33+ - [ ` Promise repo.init () ` ] ( #promise-repoinit- )
34+ - [ ` Promise repo.open () ` ] ( #promise-repoopen- )
35+ - [ ` Promise repo.close () ` ] ( #promise-repoclose- )
36+ - [ ` Promise<boolean> repo.exists () ` ] ( #promiseboolean-repoexists- )
37+ - [ Repos] ( #repos )
38+ - [ ` Promise repo.put (key, value:Buffer) ` ] ( #promise-repoput-key-valuebuffer )
39+ - [ ` Promise<Buffer> repo.get (key) ` ] ( #promisebuffer-repoget-key )
40+ - [ ` Promise<Boolean> repo.isInitialized () ` ] ( #promiseboolean-repoisinitialized- )
41+ - [ ` Promise repo.blocks.put (block:Block) ` ] ( #promise-repoblocksput-blockblock )
42+ - [ ` Promise repo.blocks.putMany (blocks) ` ] ( #promise-repoblocksputmany-blocks )
43+ - [ ` Promise<Buffer> repo.blocks.get (cid) ` ] ( #promisebuffer-repoblocksget-cid )
44+ - [ ` repo.datastore ` ] ( #repodatastore )
45+ - [ Config] ( #config )
46+ - [ ` Promise repo.config.set(key:string, value) ` ] ( #promise-repoconfigsetkeystring-value )
47+ - [ ` Promise repo.config.replace(value) ` ] ( #promise-repoconfigreplacevalue )
48+ - [ ` Promise<?> repo.config.get(key:string) ` ] ( #promise-repoconfiggetkeystring )
49+ - [ ` Promise<Object> repo.config.getAll() ` ] ( #promiseobject-repoconfiggetall )
50+ - [ ` Promise<boolean> repo.config.exists() ` ] ( #promiseboolean-repoconfigexists )
51+ - [ Version] ( #version )
52+ - [ ` Promise<Number> repo.version.get () ` ] ( #promisenumber-repoversionget- )
53+ - [ ` Promise repo.version.set (version:Number) ` ] ( #promise-repoversionset-versionnumber )
54+ - [ API Addr] ( #api-addr )
55+ - [ ` Promise<String> repo.apiAddr.get () ` ] ( #promisestring-repoapiaddrget- )
56+ - [ ` Promise repo.apiAddr.set (value) ` ] ( #promise-repoapiaddrset-value )
57+ - [ Status] ( #status )
58+ - [ ` Promise<Object> repo.stat () ` ] ( #promiseobject-repostat- )
59+ - [ Lock] ( #lock )
60+ - [ ` Promise lock.lock (dir) ` ] ( #promise-locklock-dir )
61+ - [ ` Promise closer.close () ` ] ( #promise-closerclose- )
62+ - [ ` Promise<boolean> lock.locked (dir) ` ] ( #promiseboolean-locklocked-dir )
3163- [ Notes] ( #notes )
64+ - [ Migrations] ( #migrations )
3265- [ Contribute] ( #contribute )
3366- [ License] ( #license )
3467
@@ -210,13 +243,11 @@ Datastore:
210243This contains a full implementation of [ the ` interface-datastore ` API] ( https://github.com/ipfs/interface-datastore#api ) .
211244
212245
213- ### Utils
214-
215- #### ` repo.config `
246+ ### Config
216247
217248Instead of using ` repo.set('config') ` this exposes an API that allows you to set and get a decoded config object, as well as, in a safe manner, change any of the config values individually.
218249
219- ##### ` Promise repo.config.set(key:string, value) `
250+ #### ` Promise repo.config.set(key:string, value) `
220251
221252Set a config value. ` value ` can be any object that is serializable to JSON.
222253
@@ -228,11 +259,11 @@ const config = await repo.config.get()
228259assert .equal (config .a .b .c , ' c value' )
229260```
230261
231- ##### ` Promise repo.config.set (value) `
262+ #### ` Promise repo.config.replace (value) `
232263
233264Set the whole config value. ` value ` can be any object that is serializable to JSON.
234265
235- ##### ` Promise<?> repo.config.get(key:string) `
266+ #### ` Promise<?> repo.config.get(key:string) `
236267
237268Get a config value. Returned promise resolves to the same type that was set before.
238269
@@ -243,25 +274,25 @@ const value = await repo.config.get('a.b.c')
243274console .log (' config.a.b.c = ' , value)
244275```
245276
246- ##### ` Promise<Object> repo.config.get () `
277+ #### ` Promise<Object> repo.config.getAll () `
247278
248279Get the entire config value.
249280
250281#### ` Promise<boolean> repo.config.exists() `
251282
252283Whether the config sub-repo exists.
253284
254- #### ` repo.version `
285+ ### Version
255286
256- ##### ` Promise<Number> repo.version.get () `
287+ #### ` Promise<Number> repo.version.get () `
257288
258289Gets the repo version (an integer).
259290
260- ##### ` Promise repo.version.set (version:Number) `
291+ #### ` Promise repo.version.set (version:Number) `
261292
262293Sets the repo version
263294
264- #### ` repo.apiAddr `
295+ ### API Addr
265296
266297#### ` Promise<String> repo.apiAddr.get () `
267298
@@ -273,7 +304,9 @@ Sets the API address.
273304
274305* ` value ` should be a [ Multiaddr] ( https://github.com/multiformats/js-multiaddr ) or a String representing a valid one.
275306
276- ### ` Promise<Object> repo.stat () `
307+ ### Status
308+
309+ #### ` Promise<Object> repo.stat () `
277310
278311Gets the repo status.
279312
@@ -304,7 +337,7 @@ Sets the lock if one does not already exist. If a lock already exists, should th
304337
305338Returns ` closer ` , where ` closer ` has a ` close ` method for removing the lock.
306339
307- ##### ` Promise closer.close () `
340+ #### ` Promise closer.close () `
308341
309342Closes the lock created by ` lock.open `
310343
0 commit comments