File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @dataparty/api" ,
33 "private" : false ,
4- "version" : " 1.2.21 " ,
4+ "version" : " 1.2.22 " ,
55 "main" : " dist/dataparty.js" ,
66 "frontend" : " dist/dataparty-browser.js" ,
77 "backend" : " dist/dataparty.js" ,
5959 },
6060 "dependencies" : {
6161 "@dataparty/bouncer-db" : " 1.0.1" ,
62- "@dataparty/crypto" : " 1.0.3 " ,
62+ "@dataparty/crypto" : " ^1.1.0 " ,
6363 "@dataparty/tasker" : " ^0.0.2" ,
6464 "@diva.exchange/i2p-sam" : " ^4.1.8" ,
6565 "@markwylde/liferaft" : " ^1.3.4" ,
Original file line number Diff line number Diff line change 1-
1+ const EventEmitter = require ( 'eventemitter3' )
22
33/**
44 * @interface module:Config.IConfig
55 * @link module.Config
66 */
7- class IConfig {
7+ class IConfig extends EventEmitter {
88 constructor ( ) { }
99 async start ( ) { throw 'not implemented' }
1010 async clear ( ) { throw 'not implemented' }
Original file line number Diff line number Diff line change @@ -52,16 +52,16 @@ class JsonFileConfig extends IConfig {
5252 logger ( 'started' )
5353 }
5454
55- clear ( ) {
55+ async clear ( ) {
5656 this . content = { }
5757 }
5858
59- readAll ( ) {
59+ async readAll ( ) {
6060
6161 return Object . assign ( { } , this . content )
6262 }
6363
64- read ( key ) {
64+ async read ( key ) {
6565 logger ( 'reading path: ' + key )
6666 return reach ( this . content , key )
6767 }
@@ -73,8 +73,8 @@ class JsonFileConfig extends IConfig {
7373 }
7474
7575
76- exists ( key ) {
77- return ( read ( key ) !== undefined )
76+ async exists ( key ) {
77+ return ( await read ( key ) ) !== undefined
7878 }
7979
8080 async save ( ) {
Original file line number Diff line number Diff line change @@ -23,15 +23,15 @@ class LocalStorageConfig extends IConfig {
2323 this . defaults . logicalSeparator = '.'
2424 }
2525
26- start ( ) {
27- return Promise . resolve ( this )
26+ async start ( ) {
27+ return this
2828 }
2929
30- clear ( ) {
30+ async clear ( ) {
3131 localStorage . setItem ( this . basePath , JSON . stringify ( { } ) )
3232 }
3333
34- readAll ( ) {
34+ async readAll ( ) {
3535 try {
3636 return Object . assign (
3737 { } ,
@@ -44,14 +44,14 @@ class LocalStorageConfig extends IConfig {
4444 }
4545 }
4646
47- read ( key ) {
47+ async read ( key ) {
4848 logger ( 'reading path: ' + key )
49- return reach ( this . readAll ( ) , key )
49+ return reach ( await this . readAll ( ) , key )
5050 }
5151
5252 async write ( key , value ) {
5353
54- let data = this . readAll ( )
54+ let data = await this . readAll ( )
5555
5656 deepSet ( data , key , value )
5757
@@ -61,8 +61,8 @@ class LocalStorageConfig extends IConfig {
6161 }
6262
6363
64- exists ( key ) {
65- return ( read ( key ) !== undefined )
64+ async exists ( key ) {
65+ return ( await read ( key ) ) !== undefined
6666 }
6767
6868 async save ( ) {
Original file line number Diff line number Diff line change @@ -21,28 +21,28 @@ class MemoryConfig extends IConfig {
2121 this . content = Object . assign ( { } , defaults )
2222 }
2323
24- start ( ) {
24+ async start ( ) {
2525 //read and merge defaults
2626 return this
2727 }
2828
29- clear ( ) {
29+ async clear ( ) {
3030 this . content = { }
3131 }
3232
33- readAll ( ) {
33+ async readAll ( ) {
3434
3535 return Object . assign ( { } , this . content )
3636 }
3737
38- read ( key ) {
38+ async read ( key ) {
3939 logger ( 'reading path: ' + key )
40- return reach ( this . readAll ( ) , key )
40+ return reach ( await this . readAll ( ) , key )
4141 }
4242
4343 async write ( key , value ) {
4444
45- let data = this . readAll ( )
45+ let data = await this . readAll ( )
4646
4747 deepSet ( data , key , value )
4848
@@ -52,8 +52,8 @@ class MemoryConfig extends IConfig {
5252 }
5353
5454
55- exists ( key ) {
56- return ( read ( key ) !== undefined )
55+ async exists ( key ) {
56+ return ( await read ( key ) ) !== undefined
5757 }
5858
5959 async save ( ) {
Original file line number Diff line number Diff line change @@ -31,7 +31,7 @@ class NconfConfig extends IConfig {
3131 this . started = false
3232 }
3333
34- start ( ) {
34+ async start ( ) {
3535 if ( this . started ) { return Promise . resolve ( this ) }
3636
3737 this . touchDir ( '' )
@@ -66,7 +66,7 @@ class NconfConfig extends IConfig {
6666 return Promise . resolve ( this )
6767 }
6868
69- clear ( ) {
69+ async clear ( ) {
7070 logger ( 'clear' )
7171 return Promise ( ( resolve , reject ) => {
7272 logger ( 'clearing' )
@@ -80,12 +80,12 @@ class NconfConfig extends IConfig {
8080 } )
8181 }
8282
83- readAll ( ) {
83+ async readAll ( ) {
8484 logger ( 'read all' )
8585 return nconf . get ( ) ;
8686 }
8787
88- read ( key ) {
88+ async read ( key ) {
8989 logger ( 'reading key: ' + key )
9090 let val = nconf . get ( key )
9191
@@ -104,8 +104,8 @@ class NconfConfig extends IConfig {
104104 }
105105
106106
107- exists ( key ) {
108- return ( read ( key ) !== undefined )
107+ async exists ( key ) {
108+ return ( await read ( key ) ) !== undefined
109109 }
110110
111111 async save ( ) {
You can’t perform that action at this time.
0 commit comments