@naturalcycles/nodejs-lib 12.90.2 → 12.90.4
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/dist/csv/csvReader.js +0 -1
- package/dist/util/lruMemoCache.d.ts +2 -2
- package/dist/util/lruMemoCache.js +2 -2
- package/package.json +2 -2
- package/src/csv/csvReader.ts +1 -1
- package/src/stream/pipeline/pipeline.ts +0 -12
- package/src/stream/transform/worker/transformMultiThreaded.ts +0 -2
- package/src/util/lruMemoCache.ts +4 -4
package/dist/csv/csvReader.js
CHANGED
|
@@ -37,7 +37,6 @@ function csvStringToArray(str) {
|
|
|
37
37
|
const objPattern = new RegExp('(,|\\r?\\n|\\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^,\\r\\n]*))', 'gi');
|
|
38
38
|
let matches = null;
|
|
39
39
|
const arr = [[]];
|
|
40
|
-
// eslint-disable-next-line no-cond-assign
|
|
41
40
|
while ((matches = objPattern.exec(str))) {
|
|
42
41
|
if (matches[1].length && matches[1] !== ',') {
|
|
43
42
|
arr.push([]);
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { MemoCache } from '@naturalcycles/js-lib';
|
|
2
|
-
import
|
|
3
|
-
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE>>;
|
|
2
|
+
import { LRUCache } from 'lru-cache';
|
|
3
|
+
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE, any>>;
|
|
4
4
|
/**
|
|
5
5
|
* @example
|
|
6
6
|
* Use it like this:
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.LRUMemoCache = void 0;
|
|
4
|
-
const
|
|
4
|
+
const lru_cache_1 = require("lru-cache");
|
|
5
5
|
/**
|
|
6
6
|
* @example
|
|
7
7
|
* Use it like this:
|
|
@@ -11,7 +11,7 @@ const LRUCache = require("lru-cache");
|
|
|
11
11
|
*/
|
|
12
12
|
class LRUMemoCache {
|
|
13
13
|
constructor(opt) {
|
|
14
|
-
this.lru = new LRUCache({
|
|
14
|
+
this.lru = new lru_cache_1.LRUCache({
|
|
15
15
|
max: 100,
|
|
16
16
|
...opt,
|
|
17
17
|
});
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "12.90.
|
|
3
|
+
"version": "12.90.4",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky install",
|
|
6
6
|
"docs-serve": "vuepress dev docs",
|
|
@@ -33,7 +33,7 @@
|
|
|
33
33
|
"got": "^11.0.1",
|
|
34
34
|
"joi": "17.4.2",
|
|
35
35
|
"jsonwebtoken": "^9.0.0",
|
|
36
|
-
"lru-cache": "^
|
|
36
|
+
"lru-cache": "^9.0.2",
|
|
37
37
|
"move-file": "^2.0.0",
|
|
38
38
|
"through2-concurrent": "^2.0.0",
|
|
39
39
|
"yargs": "^17.0.0"
|
package/src/csv/csvReader.ts
CHANGED
|
@@ -59,7 +59,7 @@ export function csvStringToArray(str: string): string[][] {
|
|
|
59
59
|
const objPattern = new RegExp('(,|\\r?\\n|\\r|^)(?:"([^"]*(?:""[^"]*)*)"|([^,\\r\\n]*))', 'gi')
|
|
60
60
|
let matches = null
|
|
61
61
|
const arr: any[][] = [[]]
|
|
62
|
-
|
|
62
|
+
|
|
63
63
|
while ((matches = objPattern.exec(str))) {
|
|
64
64
|
if (matches[1]!.length && matches[1] !== ',') {
|
|
65
65
|
arr.push([])
|
|
@@ -5,18 +5,6 @@ import { writablePushToArray } from '../../index'
|
|
|
5
5
|
|
|
6
6
|
type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream
|
|
7
7
|
|
|
8
|
-
// /**
|
|
9
|
-
// * Promisified stream.pipeline()
|
|
10
|
-
// */
|
|
11
|
-
// export let _pipeline = promisify(pipeline)
|
|
12
|
-
//
|
|
13
|
-
// // Workaround https://github.com/nodejs/node/issues/40191
|
|
14
|
-
// // todo: remove it when fix is released in 16.x and in AppEngine 16.x
|
|
15
|
-
// if (process.version >= 'v16.10') {
|
|
16
|
-
// const { pipeline } = require('stream/promises')
|
|
17
|
-
// _pipeline = ((streams: AnyStream[]) => pipeline(...streams)) as any
|
|
18
|
-
// }
|
|
19
|
-
|
|
20
8
|
export interface PipelineOptions {
|
|
21
9
|
/**
|
|
22
10
|
* Set to true to allow ERR_STREAM_PREMATURE_CLOSE.
|
|
@@ -4,8 +4,6 @@ import through2Concurrent = require('through2-concurrent')
|
|
|
4
4
|
import { TransformTyped } from '../../stream.model'
|
|
5
5
|
import { WorkerInput, WorkerOutput } from './transformMultiThreaded.model'
|
|
6
6
|
|
|
7
|
-
/* eslint-disable unicorn/require-post-message-target-origin */
|
|
8
|
-
|
|
9
7
|
export interface TransformMultiThreadedOptions {
|
|
10
8
|
/**
|
|
11
9
|
* Absolute path to a js file with worker code
|
package/src/util/lruMemoCache.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { MemoCache } from '@naturalcycles/js-lib'
|
|
2
|
-
import
|
|
2
|
+
import { LRUCache } from 'lru-cache'
|
|
3
3
|
|
|
4
4
|
// Partial, to be able to provide default `max`
|
|
5
|
-
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE>>
|
|
5
|
+
export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE, any>>
|
|
6
6
|
|
|
7
7
|
/**
|
|
8
8
|
* @example
|
|
@@ -13,13 +13,13 @@ export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALU
|
|
|
13
13
|
*/
|
|
14
14
|
export class LRUMemoCache<KEY = any, VALUE = any> implements MemoCache<KEY, VALUE> {
|
|
15
15
|
constructor(opt: LRUMemoCacheOptions<KEY, VALUE>) {
|
|
16
|
-
this.lru = new LRUCache<
|
|
16
|
+
this.lru = new LRUCache<any, any>({
|
|
17
17
|
max: 100,
|
|
18
18
|
...opt,
|
|
19
19
|
})
|
|
20
20
|
}
|
|
21
21
|
|
|
22
|
-
private lru!: LRUCache<
|
|
22
|
+
private lru!: LRUCache<any, any>
|
|
23
23
|
|
|
24
24
|
has(k: any): boolean {
|
|
25
25
|
return this.lru.has(k)
|