@naturalcycles/db-lib 10.25.0 → 10.26.1

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.
@@ -1,6 +1,6 @@
1
1
  import { pMap } from '@naturalcycles/js-lib/promise/pMap.js';
2
2
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2';
3
- import { createReadStreamAsNDJSON, Pipeline } from '@naturalcycles/nodejs-lib/stream';
3
+ import { Pipeline } from '@naturalcycles/nodejs-lib/stream';
4
4
  /**
5
5
  * Persists in local filesystem as ndjson.
6
6
  */
@@ -25,7 +25,7 @@ export class LocalFilePersistencePlugin {
25
25
  const filePath = `${this.cfg.storagePath}/${table}.${ext}`;
26
26
  if (!(await fs2.pathExistsAsync(filePath)))
27
27
  return [];
28
- return await createReadStreamAsNDJSON(filePath).toArray();
28
+ return await Pipeline.fromNDJsonFile(filePath).toArray();
29
29
  }
30
30
  async saveFiles(ops) {
31
31
  await pMap(ops, async (op) => await this.saveFile(op.table, op.rows), { concurrency: 32 });
@@ -269,7 +269,7 @@ export class CommonDao {
269
269
  // this can make the stream async-iteration-friendly
270
270
  // but not applying it now for perf reasons
271
271
  // UPD: applying, to be compliant with `.toArray()`, etc.
272
- .on('error', err => stream.emit('error', err))
272
+ .on('error', err => stream.destroy(err))
273
273
  .pipe(transformNoOp()));
274
274
  }
275
275
  async queryIds(q, opt = {}) {
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@naturalcycles/db-lib",
3
3
  "type": "module",
4
- "version": "10.25.0",
4
+ "version": "10.26.1",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@naturalcycles/nodejs-lib": "^15"
8
8
  },
9
9
  "devDependencies": {
10
- "@naturalcycles/dev-lib": "19.36.0"
10
+ "@naturalcycles/dev-lib": "18.4.2"
11
11
  },
12
12
  "files": [
13
13
  "dist",
@@ -1,7 +1,7 @@
1
1
  import { pMap } from '@naturalcycles/js-lib/promise/pMap.js'
2
2
  import type { ObjectWithId } from '@naturalcycles/js-lib/types'
3
3
  import { fs2 } from '@naturalcycles/nodejs-lib/fs2'
4
- import { createReadStreamAsNDJSON, Pipeline } from '@naturalcycles/nodejs-lib/stream'
4
+ import { Pipeline } from '@naturalcycles/nodejs-lib/stream'
5
5
  import type { DBSaveBatchOperation } from '../../db.model.js'
6
6
  import type { FileDBPersistencePlugin } from './file.db.model.js'
7
7
 
@@ -46,7 +46,7 @@ export class LocalFilePersistencePlugin implements FileDBPersistencePlugin {
46
46
 
47
47
  if (!(await fs2.pathExistsAsync(filePath))) return []
48
48
 
49
- return await createReadStreamAsNDJSON(filePath).toArray()
49
+ return await Pipeline.fromNDJsonFile<ROW>(filePath).toArray()
50
50
  }
51
51
 
52
52
  async saveFiles(ops: DBSaveBatchOperation<any>[]): Promise<void> {
@@ -384,7 +384,7 @@ export class CommonDao<
384
384
  // this can make the stream async-iteration-friendly
385
385
  // but not applying it now for perf reasons
386
386
  // UPD: applying, to be compliant with `.toArray()`, etc.
387
- .on('error', err => stream.emit('error', err))
387
+ .on('error', err => stream.destroy(err))
388
388
  .pipe(transformNoOp())
389
389
  )
390
390
  }