flash-store 1.3.4 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -156
- package/dist/package.json +64 -0
- package/dist/src/config.d.ts +4 -0
- package/dist/src/config.d.ts.map +1 -0
- package/dist/src/config.js +16 -0
- package/dist/src/config.js.map +1 -0
- package/dist/src/flash-store-sync.d.ts +73 -0
- package/dist/src/flash-store-sync.d.ts.map +1 -0
- package/dist/src/flash-store-sync.js +178 -0
- package/dist/src/flash-store-sync.js.map +1 -0
- package/dist/src/flash-store.d.ts +69 -0
- package/dist/src/flash-store.d.ts.map +1 -0
- package/dist/src/flash-store.js +246 -0
- package/dist/src/flash-store.js.map +1 -0
- package/dist/src/mod.d.ts +10 -0
- package/dist/src/mod.d.ts.map +1 -0
- package/dist/src/mod.js +9 -0
- package/dist/src/mod.js.map +1 -0
- package/package.json +29 -52
- package/dist/cjs/package.json +0 -3
- package/dist/cjs/src/config.d.ts +0 -4
- package/dist/cjs/src/config.d.ts.map +0 -1
- package/dist/cjs/src/config.js +0 -9
- package/dist/cjs/src/config.js.map +0 -1
- package/dist/cjs/src/flash-store-sync.d.ts +0 -44
- package/dist/cjs/src/flash-store-sync.d.ts.map +0 -1
- package/dist/cjs/src/flash-store-sync.js +0 -118
- package/dist/cjs/src/flash-store-sync.js.map +0 -1
- package/dist/cjs/src/flash-store-sync.spec.d.ts +0 -3
- package/dist/cjs/src/flash-store-sync.spec.d.ts.map +0 -1
- package/dist/cjs/src/flash-store-sync.spec.js +0 -131
- package/dist/cjs/src/flash-store-sync.spec.js.map +0 -1
- package/dist/cjs/src/flash-store.d.ts +0 -124
- package/dist/cjs/src/flash-store.d.ts.map +0 -1
- package/dist/cjs/src/flash-store.js +0 -293
- package/dist/cjs/src/flash-store.js.map +0 -1
- package/dist/cjs/src/flash-store.spec.d.ts +0 -3
- package/dist/cjs/src/flash-store.spec.d.ts.map +0 -1
- package/dist/cjs/src/flash-store.spec.js +0 -155
- package/dist/cjs/src/flash-store.spec.js.map +0 -1
- package/dist/cjs/src/mod.d.ts +0 -6
- package/dist/cjs/src/mod.d.ts.map +0 -1
- package/dist/cjs/src/mod.js +0 -12
- package/dist/cjs/src/mod.js.map +0 -1
- package/dist/cjs/src/package-json.d.ts +0 -6
- package/dist/cjs/src/package-json.d.ts.map +0 -1
- package/dist/cjs/src/package-json.js +0 -91
- package/dist/cjs/src/package-json.js.map +0 -1
- package/dist/cjs/src/package-json.spec.d.ts +0 -3
- package/dist/cjs/src/package-json.spec.d.ts.map +0 -1
- package/dist/cjs/src/package-json.spec.js +0 -10
- package/dist/cjs/src/package-json.spec.js.map +0 -1
- package/dist/cjs/tests/integration.spec.d.ts +0 -3
- package/dist/cjs/tests/integration.spec.d.ts.map +0 -1
- package/dist/cjs/tests/integration.spec.js +0 -8
- package/dist/cjs/tests/integration.spec.js.map +0 -1
- package/dist/esm/src/config.d.ts +0 -4
- package/dist/esm/src/config.d.ts.map +0 -1
- package/dist/esm/src/config.js +0 -6
- package/dist/esm/src/config.js.map +0 -1
- package/dist/esm/src/flash-store-sync.d.ts +0 -44
- package/dist/esm/src/flash-store-sync.d.ts.map +0 -1
- package/dist/esm/src/flash-store-sync.js +0 -111
- package/dist/esm/src/flash-store-sync.js.map +0 -1
- package/dist/esm/src/flash-store-sync.spec.d.ts +0 -3
- package/dist/esm/src/flash-store-sync.spec.d.ts.map +0 -1
- package/dist/esm/src/flash-store-sync.spec.js +0 -126
- package/dist/esm/src/flash-store-sync.spec.js.map +0 -1
- package/dist/esm/src/flash-store.d.ts +0 -124
- package/dist/esm/src/flash-store.d.ts.map +0 -1
- package/dist/esm/src/flash-store.js +0 -286
- package/dist/esm/src/flash-store.js.map +0 -1
- package/dist/esm/src/flash-store.spec.d.ts +0 -3
- package/dist/esm/src/flash-store.spec.d.ts.map +0 -1
- package/dist/esm/src/flash-store.spec.js +0 -150
- package/dist/esm/src/flash-store.spec.js.map +0 -1
- package/dist/esm/src/mod.d.ts +0 -6
- package/dist/esm/src/mod.d.ts.map +0 -1
- package/dist/esm/src/mod.js +0 -6
- package/dist/esm/src/mod.js.map +0 -1
- package/dist/esm/src/package-json.d.ts +0 -6
- package/dist/esm/src/package-json.d.ts.map +0 -1
- package/dist/esm/src/package-json.js +0 -88
- package/dist/esm/src/package-json.js.map +0 -1
- package/dist/esm/src/package-json.spec.d.ts +0 -3
- package/dist/esm/src/package-json.spec.d.ts.map +0 -1
- package/dist/esm/src/package-json.spec.js +0 -8
- package/dist/esm/src/package-json.spec.js.map +0 -1
- package/dist/esm/tests/integration.spec.d.ts +0 -3
- package/dist/esm/tests/integration.spec.d.ts.map +0 -1
- package/dist/esm/tests/integration.spec.js +0 -6
- package/dist/esm/tests/integration.spec.js.map +0 -1
- package/src/config.ts +0 -12
- package/src/flash-store-sync.spec.ts +0 -158
- package/src/flash-store-sync.ts +0 -163
- package/src/flash-store.spec.ts +0 -197
- package/src/flash-store.ts +0 -366
- package/src/mod.ts +0 -18
- package/src/package-json.spec.ts +0 -10
- package/src/package-json.ts +0 -91
- package/src/typings.d.ts +0 -0
package/src/flash-store.ts
DELETED
|
@@ -1,366 +0,0 @@
|
|
|
1
|
-
import rimraf from 'rimraf'
|
|
2
|
-
// import encoding from 'encoding-down'
|
|
3
|
-
// import leveldown from 'leveldown'
|
|
4
|
-
// import levelup from 'levelup'
|
|
5
|
-
import level from 'level'
|
|
6
|
-
import levelErrors from 'level-errors'
|
|
7
|
-
|
|
8
|
-
// https://github.com/rollup/rollup/issues/1267#issuecomment-296395734
|
|
9
|
-
// const rimraf = (<any>rimrafProxy).default || rimrafProxy
|
|
10
|
-
// const encoding = (<any>encodingProxy).default || encodingProxy
|
|
11
|
-
// // const leveldown = (<any>leveldownProxy).default || leveldownProxy
|
|
12
|
-
// const levelup = (<any>levelupProxy).default || levelupProxy
|
|
13
|
-
|
|
14
|
-
import type {
|
|
15
|
-
AsyncMapLike,
|
|
16
|
-
} from 'async-map-like'
|
|
17
|
-
|
|
18
|
-
import {
|
|
19
|
-
log,
|
|
20
|
-
VERSION,
|
|
21
|
-
} from './config.js'
|
|
22
|
-
|
|
23
|
-
export interface IteratorOptions {
|
|
24
|
-
gt? : any,
|
|
25
|
-
gte? : any,
|
|
26
|
-
lt? : any,
|
|
27
|
-
lte? : any,
|
|
28
|
-
reverse? : boolean,
|
|
29
|
-
limit? : number,
|
|
30
|
-
|
|
31
|
-
prefix? : any,
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export class FlashStore<K = any, V = any> implements AsyncMapLike<K, V> {
|
|
35
|
-
|
|
36
|
-
static VERSION = VERSION
|
|
37
|
-
|
|
38
|
-
private levelDb: level.LevelDB<K, V>
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* FlashStore is a Key-Value database tool and makes using leveldb more easy for Node.js
|
|
42
|
-
*
|
|
43
|
-
* Creates an instance of FlashStore.
|
|
44
|
-
* @param {string} [workdir=path.join(appRoot, 'flash-store.workdir')]
|
|
45
|
-
* @example
|
|
46
|
-
* import { FlashStore } from 'flash-store'
|
|
47
|
-
* const flashStore = new FlashStore('flashstore.workdir')
|
|
48
|
-
*/
|
|
49
|
-
constructor (
|
|
50
|
-
public workdir: string,
|
|
51
|
-
) {
|
|
52
|
-
log.verbose('FlashStore', 'constructor(%s)', workdir)
|
|
53
|
-
|
|
54
|
-
/**
|
|
55
|
-
* `valueEncoding` is a `encoding-down` options.
|
|
56
|
-
* See: https://github.com/Level/encoding-down#db--requireencoding-downdb-options
|
|
57
|
-
*/
|
|
58
|
-
const levelDb = level(workdir, {
|
|
59
|
-
valueEncoding: 'json',
|
|
60
|
-
})
|
|
61
|
-
levelDb.setMaxListeners(17) // default is Infinity
|
|
62
|
-
|
|
63
|
-
this.levelDb = levelDb
|
|
64
|
-
}
|
|
65
|
-
|
|
66
|
-
public version (): string {
|
|
67
|
-
return VERSION
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
/**
|
|
71
|
-
* Set data in database
|
|
72
|
-
*
|
|
73
|
-
* @param {K} key
|
|
74
|
-
* @param {V} value
|
|
75
|
-
* @returns {Promise<void>}
|
|
76
|
-
* @example
|
|
77
|
-
* await flashStore.put(1, 1)
|
|
78
|
-
*/
|
|
79
|
-
public async set (key: K, value: V): Promise<AsyncMapLike<K, V>> {
|
|
80
|
-
log.verbose('FlashStore', 'set(%s, %s)', key, typeof value)
|
|
81
|
-
log.silly('FlashStore', 'set(%s, %s)', key, JSON.stringify(value))
|
|
82
|
-
await this.levelDb.put(key, value)
|
|
83
|
-
return this
|
|
84
|
-
}
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* Get value from database by key
|
|
88
|
-
*
|
|
89
|
-
* @param {K} key
|
|
90
|
-
* @returns {(Promise<V | null>)}
|
|
91
|
-
* @example
|
|
92
|
-
* console.log(await flashStore.get(1))
|
|
93
|
-
*/
|
|
94
|
-
public async get (key: K): Promise<V | undefined> {
|
|
95
|
-
log.verbose('FlashStore', 'get(%s)', key)
|
|
96
|
-
try {
|
|
97
|
-
const val = await this.levelDb.get(key)
|
|
98
|
-
/**
|
|
99
|
-
* We must `await` inside to
|
|
100
|
-
* catch the `NotFoundError`
|
|
101
|
-
*/
|
|
102
|
-
return val
|
|
103
|
-
} catch (e) {
|
|
104
|
-
if (e instanceof levelErrors.NotFoundError) {
|
|
105
|
-
return undefined
|
|
106
|
-
}
|
|
107
|
-
throw e
|
|
108
|
-
}
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Del data by key
|
|
113
|
-
*
|
|
114
|
-
* @param {K} key
|
|
115
|
-
* @returns {Promise<void>}
|
|
116
|
-
* @example
|
|
117
|
-
* await flashStore.del(1)
|
|
118
|
-
*/
|
|
119
|
-
// public async del (key: K): Promise<void> {
|
|
120
|
-
// log.verbose('FlashStore', '`del()` DEPRECATED. use `delete()` instead')
|
|
121
|
-
// await this.delete(key)
|
|
122
|
-
// }
|
|
123
|
-
|
|
124
|
-
public async delete (key: K): Promise<boolean> {
|
|
125
|
-
log.verbose('FlashStore', 'delete(%s)', key)
|
|
126
|
-
await this.levelDb.del(key)
|
|
127
|
-
// TODO: `del` returns `true` or `false`
|
|
128
|
-
return true
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* @typedef IteratorOptions
|
|
133
|
-
*
|
|
134
|
-
* @property { any } gt - Matches values that are greater than a specified value
|
|
135
|
-
* @property { any } gte - Matches values that are greater than or equal to a specified value.
|
|
136
|
-
* @property { any } lt - Matches values that are less than a specified value.
|
|
137
|
-
* @property { any } lte - Matches values that are less than or equal to a specified value.
|
|
138
|
-
* @property { boolean } reverse - Reverse the result set
|
|
139
|
-
* @property { number } limit - Limits the number in the result set.
|
|
140
|
-
* @property { any } prefix - Make the same prefix key get together.
|
|
141
|
-
*/
|
|
142
|
-
|
|
143
|
-
/**
|
|
144
|
-
* Find keys by IteratorOptions
|
|
145
|
-
*
|
|
146
|
-
* @param {IteratorOptions} [options={}]
|
|
147
|
-
* @returns {AsyncIterableIterator<K>}
|
|
148
|
-
* @example
|
|
149
|
-
* const flashStore = new FlashStore('flashstore.workdir')
|
|
150
|
-
* for await(const key of flashStore.keys({gte: 1})) {
|
|
151
|
-
* console.log(key)
|
|
152
|
-
* }
|
|
153
|
-
*/
|
|
154
|
-
public async * keys (options: IteratorOptions = {}): AsyncIterableIterator<K> {
|
|
155
|
-
log.verbose('FlashStore', 'keys()')
|
|
156
|
-
|
|
157
|
-
// options = Object.assign(options, {
|
|
158
|
-
// keys : true,
|
|
159
|
-
// values : false,
|
|
160
|
-
// })
|
|
161
|
-
|
|
162
|
-
if (options.prefix) {
|
|
163
|
-
if (options.gte || options.lte) {
|
|
164
|
-
throw new Error('can not specify `prefix` with `gte`/`lte` together.')
|
|
165
|
-
}
|
|
166
|
-
options.gte = options.prefix
|
|
167
|
-
options.lte = options.prefix + '\xff'
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
for await (const [key] of this.entries(options)) {
|
|
171
|
-
yield key
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
|
|
175
|
-
/**
|
|
176
|
-
* Find all values
|
|
177
|
-
*
|
|
178
|
-
* @returns {AsyncIterableIterator<V>}
|
|
179
|
-
* @example
|
|
180
|
-
* const flashStore = new FlashStore('flashstore.workdir')
|
|
181
|
-
* for await(const value of flashStore.values()) {
|
|
182
|
-
* console.log(value)
|
|
183
|
-
* }
|
|
184
|
-
*/
|
|
185
|
-
public async * values (options: IteratorOptions = {}): AsyncIterableIterator<V> {
|
|
186
|
-
log.verbose('FlashStore', 'values()')
|
|
187
|
-
|
|
188
|
-
// options = Object.assign(options, {
|
|
189
|
-
// keys : false,
|
|
190
|
-
// values : true,
|
|
191
|
-
// })
|
|
192
|
-
|
|
193
|
-
for await (const [, value] of this.entries(options)) {
|
|
194
|
-
yield value
|
|
195
|
-
}
|
|
196
|
-
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
/**
|
|
200
|
-
* Get the size of the database
|
|
201
|
-
* @returns {Promise<number>}
|
|
202
|
-
* @example
|
|
203
|
-
* const size = await flashStore.size
|
|
204
|
-
* console.log(`database size: ${size}`)
|
|
205
|
-
*/
|
|
206
|
-
// * @deprecated use property `size` instead
|
|
207
|
-
// public async count (): Promise<number> {
|
|
208
|
-
// log.warn('FlashStore', '`count()` DEPRECATED. use `size()` instead.')
|
|
209
|
-
// const size = await this.size
|
|
210
|
-
// return size
|
|
211
|
-
// }
|
|
212
|
-
|
|
213
|
-
public get size (): Promise<number> {
|
|
214
|
-
log.verbose('FlashStore', 'size()')
|
|
215
|
-
|
|
216
|
-
/* eslint no-async-promise-executor: 0 */
|
|
217
|
-
// TODO: is there a better way to count all items from the db?
|
|
218
|
-
return new Promise<number>(async (resolve, reject) => {
|
|
219
|
-
try {
|
|
220
|
-
let count = 0
|
|
221
|
-
for await (const _ of this) {
|
|
222
|
-
count++
|
|
223
|
-
}
|
|
224
|
-
resolve(count)
|
|
225
|
-
} catch (e) {
|
|
226
|
-
reject(e)
|
|
227
|
-
}
|
|
228
|
-
})
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
/**
|
|
232
|
-
* FIXME: use better way to do this
|
|
233
|
-
*/
|
|
234
|
-
public async has (key: K): Promise<boolean> {
|
|
235
|
-
const val = await this.get(key)
|
|
236
|
-
return !!val
|
|
237
|
-
}
|
|
238
|
-
|
|
239
|
-
/**
|
|
240
|
-
* TODO: use better way to do this with leveldb
|
|
241
|
-
*/
|
|
242
|
-
public async clear (): Promise<void> {
|
|
243
|
-
for await (const key of this.keys()) {
|
|
244
|
-
await this.delete(key)
|
|
245
|
-
}
|
|
246
|
-
}
|
|
247
|
-
|
|
248
|
-
get [Symbol.toStringTag] () {
|
|
249
|
-
return Promise.resolve('FlashStore')
|
|
250
|
-
}
|
|
251
|
-
|
|
252
|
-
[Symbol.iterator] (): AsyncIterableIterator<[K, V]> {
|
|
253
|
-
log.verbose('FlashStore', '[Symbol.iterator]()')
|
|
254
|
-
/**
|
|
255
|
-
* Huan(202108): what is this???
|
|
256
|
-
* does it equals to `entries()`?
|
|
257
|
-
*/
|
|
258
|
-
return this.entries()
|
|
259
|
-
}
|
|
260
|
-
|
|
261
|
-
/**
|
|
262
|
-
* @private
|
|
263
|
-
*/
|
|
264
|
-
public async * entries (options?: IteratorOptions): AsyncIterableIterator<[K, V]> {
|
|
265
|
-
log.verbose('FlashStore', '*entries(%s)', JSON.stringify(options))
|
|
266
|
-
|
|
267
|
-
const iterator = (this.levelDb as any).db.iterator(options)
|
|
268
|
-
|
|
269
|
-
while (true) {
|
|
270
|
-
const pair = await new Promise<[K, V] | null>((resolve, reject) => {
|
|
271
|
-
iterator.next(function (err: any, key: K, val: V) {
|
|
272
|
-
if (err) {
|
|
273
|
-
reject(err)
|
|
274
|
-
}
|
|
275
|
-
if (!key && !val) {
|
|
276
|
-
return resolve(null)
|
|
277
|
-
}
|
|
278
|
-
// if (val) {
|
|
279
|
-
// val = JSON.parse(val as any)
|
|
280
|
-
// }
|
|
281
|
-
return resolve([key, val])
|
|
282
|
-
})
|
|
283
|
-
})
|
|
284
|
-
if (!pair) {
|
|
285
|
-
break
|
|
286
|
-
}
|
|
287
|
-
yield pair
|
|
288
|
-
}
|
|
289
|
-
}
|
|
290
|
-
|
|
291
|
-
public async * [Symbol.asyncIterator] (): AsyncIterableIterator<[K, V]> {
|
|
292
|
-
log.verbose('FlashStore', '*[Symbol.asyncIterator]()')
|
|
293
|
-
yield * this.entries()
|
|
294
|
-
}
|
|
295
|
-
|
|
296
|
-
/**
|
|
297
|
-
* @private
|
|
298
|
-
*/
|
|
299
|
-
// public async * streamAsyncIterator (): AsyncIterator<[K, V]> {
|
|
300
|
-
// log.warn('FlashStore', 'DEPRECATED *[Symbol.asyncIterator]()')
|
|
301
|
-
|
|
302
|
-
// const readStream = this.levelDb.createReadStream()
|
|
303
|
-
|
|
304
|
-
// const endPromise = new Promise<false>((resolve, reject) => {
|
|
305
|
-
// readStream
|
|
306
|
-
// .once('end', () => resolve(false))
|
|
307
|
-
// .once('error', reject)
|
|
308
|
-
// })
|
|
309
|
-
|
|
310
|
-
// let pair: [K, V] | false
|
|
311
|
-
|
|
312
|
-
// do {
|
|
313
|
-
// const dataPromise = new Promise<[K, V]>(resolve => {
|
|
314
|
-
// readStream.once('data', (data: any) => resolve([data.key, data.value]))
|
|
315
|
-
// })
|
|
316
|
-
|
|
317
|
-
// pair = await Promise.race([
|
|
318
|
-
// dataPromise,
|
|
319
|
-
// endPromise,
|
|
320
|
-
// ])
|
|
321
|
-
|
|
322
|
-
// if (pair) {
|
|
323
|
-
// yield pair
|
|
324
|
-
// }
|
|
325
|
-
|
|
326
|
-
// } while (pair)
|
|
327
|
-
|
|
328
|
-
// }
|
|
329
|
-
|
|
330
|
-
async forEach (
|
|
331
|
-
callbackfn: (
|
|
332
|
-
value: V,
|
|
333
|
-
key: K,
|
|
334
|
-
// map: TestAsyncMapLike,
|
|
335
|
-
// FIXME(huan) 202007: we have to use any at here, because the typing system is very hard to
|
|
336
|
-
// rename `Map` to `TestAsyncMapLike` in this method function parameters.
|
|
337
|
-
map: any,
|
|
338
|
-
) => void,
|
|
339
|
-
thisArg?: any,
|
|
340
|
-
): Promise<void> {
|
|
341
|
-
log.verbose('FlashStore', 'forEach()')
|
|
342
|
-
|
|
343
|
-
for await (const [key, value] of this) {
|
|
344
|
-
callbackfn.call(thisArg, value, key, this)
|
|
345
|
-
}
|
|
346
|
-
}
|
|
347
|
-
|
|
348
|
-
public async close (): Promise<void> {
|
|
349
|
-
log.verbose('FlashStore', 'close()')
|
|
350
|
-
await this.levelDb.close()
|
|
351
|
-
}
|
|
352
|
-
|
|
353
|
-
/**
|
|
354
|
-
* Destroy the database
|
|
355
|
-
*
|
|
356
|
-
* @returns {Promise<void>}
|
|
357
|
-
*/
|
|
358
|
-
public async destroy (): Promise<void> {
|
|
359
|
-
log.verbose('FlashStore', 'destroy()')
|
|
360
|
-
await this.levelDb.close()
|
|
361
|
-
await new Promise(resolve => rimraf(this.workdir, resolve))
|
|
362
|
-
}
|
|
363
|
-
|
|
364
|
-
}
|
|
365
|
-
|
|
366
|
-
export default FlashStore
|
package/src/mod.ts
DELETED
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
log,
|
|
3
|
-
VERSION,
|
|
4
|
-
} from './config.js'
|
|
5
|
-
import {
|
|
6
|
-
FlashStore,
|
|
7
|
-
} from './flash-store.js'
|
|
8
|
-
import {
|
|
9
|
-
FlashStoreSync,
|
|
10
|
-
} from './flash-store-sync.js'
|
|
11
|
-
|
|
12
|
-
export default FlashStore
|
|
13
|
-
export {
|
|
14
|
-
log,
|
|
15
|
-
FlashStoreSync,
|
|
16
|
-
FlashStore,
|
|
17
|
-
VERSION,
|
|
18
|
-
}
|
package/src/package-json.spec.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env -S node --no-warnings --loader ts-node/esm
|
|
2
|
-
|
|
3
|
-
import { test } from 'tstest'
|
|
4
|
-
|
|
5
|
-
import { packageJson } from './package-json.js'
|
|
6
|
-
|
|
7
|
-
test('Make sure the packageJson is fresh in source code', async t => {
|
|
8
|
-
const keyNum = Object.keys(packageJson).length
|
|
9
|
-
t.equal(keyNum, 0, 'packageJson should be empty in source code, only updated before publish to NPM')
|
|
10
|
-
})
|
package/src/package-json.ts
DELETED
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file was auto generated from scripts/generate-version.sh
|
|
3
|
-
*/
|
|
4
|
-
import type { PackageJson } from 'type-fest'
|
|
5
|
-
export const packageJson: PackageJson = {
|
|
6
|
-
"name": "flash-store",
|
|
7
|
-
"version": "1.3.4",
|
|
8
|
-
"description": "FlashStore is a Key-Value persistent storage with easy to use ES6 Map-like API(both Async and Sync support), powered by LevelDB and TypeScript.",
|
|
9
|
-
"type": "module",
|
|
10
|
-
"exports": {
|
|
11
|
-
".": {
|
|
12
|
-
"import": "./dist/esm/src/mod.js",
|
|
13
|
-
"require": "./dist/cjs/src/mod.js"
|
|
14
|
-
}
|
|
15
|
-
},
|
|
16
|
-
"typings": "./dist/esm/src/mod.d.ts",
|
|
17
|
-
"engines": {
|
|
18
|
-
"node": ">=14"
|
|
19
|
-
},
|
|
20
|
-
"scripts": {
|
|
21
|
-
"clean": "shx rm -fr dist/*",
|
|
22
|
-
"dist": "npm-run-all clean build dist:commonjs",
|
|
23
|
-
"build": "tsc && tsc -p tsconfig.cjs.json",
|
|
24
|
-
"dist:commonjs": "jq -n \"{ type: \\\"commonjs\\\" }\" > dist/cjs/package.json",
|
|
25
|
-
"pack": "npm pack",
|
|
26
|
-
"doc": "npm run dist && echo '# FlashStore v'$(jq -r .version package.json)' Documentation\n' > docs/index.md && jsdoc2md dist/flash-store.js>> docs/index.md",
|
|
27
|
-
"demo": "ts-node example/demo.ts",
|
|
28
|
-
"lint": "npm-run-all lint:es lint:ts lint:md",
|
|
29
|
-
"lint:md": "markdownlint README.md",
|
|
30
|
-
"lint:ts": "tsc --isolatedModules --noEmit",
|
|
31
|
-
"lint:es": "eslint --ignore-pattern fixtures/ \"src/**/*.ts\" \"tests/**/*.ts\"",
|
|
32
|
-
"test": "npm run lint && npm run test:unit",
|
|
33
|
-
"test:pack": "bash -x scripts/npm-pack-testing.sh",
|
|
34
|
-
"test:unit": "tap --node-arg=--loader=ts-node/esm --node-arg=--no-warnings \"src/**/*.spec.ts\" \"tests/**/*.spec.ts\""
|
|
35
|
-
},
|
|
36
|
-
"repository": {
|
|
37
|
-
"type": "git",
|
|
38
|
-
"url": "git+https://github.com/huan/flash-store.git"
|
|
39
|
-
},
|
|
40
|
-
"keywords": [
|
|
41
|
-
"leveldb",
|
|
42
|
-
"nosql",
|
|
43
|
-
"database"
|
|
44
|
-
],
|
|
45
|
-
"author": "Huan LI <zixia@zixia.net>",
|
|
46
|
-
"license": "Apache-2.0",
|
|
47
|
-
"bugs": {
|
|
48
|
-
"url": "https://github.com/huan/flash-store/issues"
|
|
49
|
-
},
|
|
50
|
-
"homepage": "https://github.com/huan/flash-store#readme",
|
|
51
|
-
"dependencies": {
|
|
52
|
-
"async-map-like": "^0.2.5",
|
|
53
|
-
"brolog": "^1.12.4",
|
|
54
|
-
"cuid": "^2.1.8",
|
|
55
|
-
"level": "^7.0.0",
|
|
56
|
-
"rimraf": "^3.0.2",
|
|
57
|
-
"state-switch": "^0.14.1"
|
|
58
|
-
},
|
|
59
|
-
"devDependencies": {
|
|
60
|
-
"@chatie/eslint-config": "^0.14.1",
|
|
61
|
-
"@chatie/git-scripts": "^0.6.2",
|
|
62
|
-
"@chatie/semver": "^0.4.7",
|
|
63
|
-
"@chatie/tsconfig": "^0.20.2",
|
|
64
|
-
"@types/app-root-path": "^1.2.4",
|
|
65
|
-
"@types/level": "^6.0.0",
|
|
66
|
-
"@types/level-errors": "^3.0.0",
|
|
67
|
-
"@types/rimraf": "^3.0.1",
|
|
68
|
-
"jsdoc-to-markdown": "^7.0.1",
|
|
69
|
-
"npm-run-all": "^4.1.5",
|
|
70
|
-
"shx": "^0.3.3",
|
|
71
|
-
"source-map-support": "^0.5.19",
|
|
72
|
-
"tstest": "^0.5.16",
|
|
73
|
-
"typescript": "^4.4.3"
|
|
74
|
-
},
|
|
75
|
-
"files": [
|
|
76
|
-
"src/",
|
|
77
|
-
"dist/"
|
|
78
|
-
],
|
|
79
|
-
"publishConfig": {
|
|
80
|
-
"access": "public",
|
|
81
|
-
"tag": "next"
|
|
82
|
-
},
|
|
83
|
-
"tap": {
|
|
84
|
-
"check-coverage": false
|
|
85
|
-
},
|
|
86
|
-
"git": {
|
|
87
|
-
"scripts": {
|
|
88
|
-
"pre-push": "npx git-scripts-pre-push"
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
} as any
|
package/src/typings.d.ts
DELETED
|
File without changes
|