@naturalcycles/nodejs-lib 12.65.2 → 12.65.3
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/index.d.ts +2 -2
- package/dist/index.js +2 -3
- package/dist/util/lruMemoCache.d.ts +4 -3
- package/dist/util/lruMemoCache.js +4 -1
- package/package.json +1 -1
- package/src/index.ts +1 -2
- package/src/util/lruMemoCache.ts +9 -5
package/dist/index.d.ts
CHANGED
|
@@ -54,7 +54,7 @@ export * from './stream/writable/writablePushToArray';
|
|
|
54
54
|
export * from './stream/writable/writableVoid';
|
|
55
55
|
import { inspectAny, InspectAnyOptions, inspectAnyStringifyFn } from './string/inspectAny';
|
|
56
56
|
export * from './util/env.util';
|
|
57
|
-
|
|
57
|
+
export * from './util/lruMemoCache';
|
|
58
58
|
export * from './util/zip.util';
|
|
59
59
|
import { readAjvSchemas, readJsonSchemas } from './validation/ajv/ajv.util';
|
|
60
60
|
import { AjvSchema, AjvSchemaCfg, AjvValidationOptions } from './validation/ajv/ajvSchema';
|
|
@@ -67,4 +67,4 @@ import { JoiValidationError, JoiValidationErrorData } from './validation/joi/joi
|
|
|
67
67
|
import { convert, getValidationResult, isValid, JoiValidationResult, undefinedIfInvalid, validate } from './validation/joi/joi.validation.util';
|
|
68
68
|
import { runScript, RunScriptOptions } from './script';
|
|
69
69
|
export type { RunScriptOptions, JoiValidationErrorData, JoiValidationResult, ValidationErrorItem, ExtendedJoi, SchemaTyped, AnySchema, AnySchemaTyped, ArraySchemaTyped, BooleanSchemaTyped, NumberSchemaTyped, ObjectSchemaTyped, StringSchemaTyped, IDebug, IDebugger, SlackServiceCfg, SlackMessage, SlackMessageProps, SlackApiBody, SlackMessagePrefixHook, ReadableTyped, WritableTyped, TransformTyped, PipelineFromNDJsonFileOptions, PipelineToNDJsonFileOptions, TransformJsonParseOptions, TransformToNDJsonOptions, TransformMapOptions, TransformMapSyncOptions, NDJSONStreamForEachOptions, TransformOptions, TransformMultiThreadedOptions, WorkerClassInterface, WorkerInput, WorkerOutput, TableDiffOptions, InspectAnyOptions, Got, GetGotOptions, AfterResponseHook, BeforeErrorHook, BeforeRequestHook, AjvValidationOptions, AjvSchemaCfg, AjvValidationErrorData, };
|
|
70
|
-
export { JoiValidationError, validate, getValidationResult, isValid, undefinedIfInvalid, convert, Joi,
|
|
70
|
+
export { JoiValidationError, validate, getValidationResult, isValid, undefinedIfInvalid, convert, Joi, Debug, SlackService, slackDefaultMessagePrefixHook, ndjsonStreamForEach, pipelineFromNDJsonFile, pipelineToNDJsonFile, NDJsonStats, streamToNDJsonFile, transformJsonParse, bufferReviver, transformToNDJson, transformMap, transformMapSync, transformMultiThreaded, BaseWorkerClass, tableDiff, inspectAny, inspectAnyStringifyFn, RequestError, TimeoutError, _chunkBuffer, Ajv, AjvSchema, AjvValidationError, readJsonSchemas, readAjvSchemas, runScript, };
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.runScript = exports.readAjvSchemas = exports.readJsonSchemas = exports.AjvValidationError = exports.AjvSchema = exports.Ajv = exports._chunkBuffer = exports.TimeoutError = exports.RequestError = exports.inspectAnyStringifyFn = exports.inspectAny = exports.tableDiff = exports.BaseWorkerClass = exports.transformMultiThreaded = exports.transformMapSync = exports.transformMap = exports.transformToNDJson = exports.bufferReviver = exports.transformJsonParse = exports.streamToNDJsonFile = exports.NDJsonStats = exports.pipelineToNDJsonFile = exports.pipelineFromNDJsonFile = exports.ndjsonStreamForEach = exports.slackDefaultMessagePrefixHook = exports.SlackService = exports.Debug = exports.
|
|
3
|
+
exports.runScript = exports.readAjvSchemas = exports.readJsonSchemas = exports.AjvValidationError = exports.AjvSchema = exports.Ajv = exports._chunkBuffer = exports.TimeoutError = exports.RequestError = exports.inspectAnyStringifyFn = exports.inspectAny = exports.tableDiff = exports.BaseWorkerClass = exports.transformMultiThreaded = exports.transformMapSync = exports.transformMap = exports.transformToNDJson = exports.bufferReviver = exports.transformJsonParse = exports.streamToNDJsonFile = exports.NDJsonStats = exports.pipelineToNDJsonFile = exports.pipelineFromNDJsonFile = exports.ndjsonStreamForEach = exports.slackDefaultMessagePrefixHook = exports.SlackService = exports.Debug = exports.Joi = exports.convert = exports.undefinedIfInvalid = exports.isValid = exports.getValidationResult = exports.validate = exports.JoiValidationError = void 0;
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const ajv_1 = require("ajv");
|
|
6
6
|
exports.Ajv = ajv_1.default;
|
|
@@ -74,8 +74,7 @@ const inspectAny_1 = require("./string/inspectAny");
|
|
|
74
74
|
Object.defineProperty(exports, "inspectAny", { enumerable: true, get: function () { return inspectAny_1.inspectAny; } });
|
|
75
75
|
Object.defineProperty(exports, "inspectAnyStringifyFn", { enumerable: true, get: function () { return inspectAny_1.inspectAnyStringifyFn; } });
|
|
76
76
|
(0, tslib_1.__exportStar)(require("./util/env.util"), exports);
|
|
77
|
-
|
|
78
|
-
Object.defineProperty(exports, "LRUMemoCache", { enumerable: true, get: function () { return lruMemoCache_1.LRUMemoCache; } });
|
|
77
|
+
(0, tslib_1.__exportStar)(require("./util/lruMemoCache"), exports);
|
|
79
78
|
(0, tslib_1.__exportStar)(require("./util/zip.util"), exports);
|
|
80
79
|
const ajv_util_1 = require("./validation/ajv/ajv.util");
|
|
81
80
|
Object.defineProperty(exports, "readAjvSchemas", { enumerable: true, get: function () { return ajv_util_1.readAjvSchemas; } });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MemoCache } from '@naturalcycles/js-lib';
|
|
2
2
|
import LRUCache = require('lru-cache');
|
|
3
|
-
export
|
|
3
|
+
export interface LRUMemoCacheOptions<KEY, VALUE> extends Partial<LRUCache.Options<KEY, VALUE>> {
|
|
4
|
+
}
|
|
4
5
|
/**
|
|
5
6
|
* @example
|
|
6
7
|
* Use it like this:
|
|
@@ -8,8 +9,8 @@ export declare type LRUMemoCacheOpts = LRUCache.Options<string, any>;
|
|
|
8
9
|
* @_Memo({ cacheFactory: () => new LRUMemoCache({...}) })
|
|
9
10
|
* method1 ()
|
|
10
11
|
*/
|
|
11
|
-
export declare class LRUMemoCache implements MemoCache {
|
|
12
|
-
constructor(opt:
|
|
12
|
+
export declare class LRUMemoCache<KEY = any, VALUE = any> implements MemoCache<KEY, VALUE> {
|
|
13
|
+
constructor(opt: LRUMemoCacheOptions<KEY, VALUE>);
|
|
13
14
|
private lru;
|
|
14
15
|
has(k: any): boolean;
|
|
15
16
|
get(k: any): any;
|
package/package.json
CHANGED
package/src/index.ts
CHANGED
|
@@ -81,7 +81,7 @@ export * from './stream/writable/writablePushToArray'
|
|
|
81
81
|
export * from './stream/writable/writableVoid'
|
|
82
82
|
import { inspectAny, InspectAnyOptions, inspectAnyStringifyFn } from './string/inspectAny'
|
|
83
83
|
export * from './util/env.util'
|
|
84
|
-
|
|
84
|
+
export * from './util/lruMemoCache'
|
|
85
85
|
export * from './util/zip.util'
|
|
86
86
|
import { readAjvSchemas, readJsonSchemas } from './validation/ajv/ajv.util'
|
|
87
87
|
import { AjvSchema, AjvSchemaCfg, AjvValidationOptions } from './validation/ajv/ajvSchema'
|
|
@@ -165,7 +165,6 @@ export {
|
|
|
165
165
|
undefinedIfInvalid,
|
|
166
166
|
convert,
|
|
167
167
|
Joi,
|
|
168
|
-
LRUMemoCache,
|
|
169
168
|
Debug,
|
|
170
169
|
SlackService,
|
|
171
170
|
slackDefaultMessagePrefixHook,
|
package/src/util/lruMemoCache.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { MemoCache } from '@naturalcycles/js-lib'
|
|
2
2
|
import LRUCache = require('lru-cache')
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
// Partial, to be able to provide default `max`
|
|
5
|
+
export interface LRUMemoCacheOptions<KEY, VALUE> extends Partial<LRUCache.Options<KEY, VALUE>> {}
|
|
5
6
|
|
|
6
7
|
/**
|
|
7
8
|
* @example
|
|
@@ -10,12 +11,15 @@ export type LRUMemoCacheOpts = LRUCache.Options<string, any>
|
|
|
10
11
|
* @_Memo({ cacheFactory: () => new LRUMemoCache({...}) })
|
|
11
12
|
* method1 ()
|
|
12
13
|
*/
|
|
13
|
-
export class LRUMemoCache implements MemoCache {
|
|
14
|
-
constructor(opt:
|
|
15
|
-
this.lru = new LRUCache<
|
|
14
|
+
export class LRUMemoCache<KEY = any, VALUE = any> implements MemoCache<KEY, VALUE> {
|
|
15
|
+
constructor(opt: LRUMemoCacheOptions<KEY, VALUE>) {
|
|
16
|
+
this.lru = new LRUCache<KEY, VALUE>({
|
|
17
|
+
max: 100,
|
|
18
|
+
...opt,
|
|
19
|
+
})
|
|
16
20
|
}
|
|
17
21
|
|
|
18
|
-
private lru!: LRUCache<
|
|
22
|
+
private lru!: LRUCache<KEY, VALUE>
|
|
19
23
|
|
|
20
24
|
has(k: any): boolean {
|
|
21
25
|
return this.lru.has(k)
|