@naturalcycles/js-lib 14.42.0 → 14.45.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/CHANGELOG.md +28 -0
- package/dist/index.d.ts +4 -3
- package/dist/index.js +5 -3
- package/dist/json-schema/jsonSchema.model.d.ts +7 -0
- package/dist/json-schema/jsonSchemaBuilder.d.ts +13 -7
- package/dist/json-schema/jsonSchemaBuilder.js +9 -1
- package/dist/string/stringifyAny.d.ts +1 -1
- package/dist/string/stringifyAny.js +1 -1
- package/dist/typeFest.d.ts +16 -0
- package/dist/vendor/is.d.ts +224 -0
- package/dist/vendor/is.js +466 -0
- package/dist-esm/array/array.util.js +0 -1
- package/dist-esm/array/range.js +0 -1
- package/dist-esm/decorators/createPromiseDecorator.js +0 -1
- package/dist-esm/decorators/debounce.decorator.js +0 -1
- package/dist-esm/decorators/debounce.js +0 -1
- package/dist-esm/decorators/decorator.util.js +0 -1
- package/dist-esm/decorators/logMethod.decorator.js +0 -1
- package/dist-esm/decorators/memo.decorator.js +0 -1
- package/dist-esm/decorators/memo.util.js +0 -1
- package/dist-esm/decorators/memoFn.js +0 -1
- package/dist-esm/decorators/memoSimple.decorator.js +0 -1
- package/dist-esm/decorators/retry.decorator.js +0 -1
- package/dist-esm/decorators/timeout.decorator.js +0 -1
- package/dist-esm/error/app.error.js +0 -1
- package/dist-esm/error/assert.js +0 -1
- package/dist-esm/error/error.model.js +0 -1
- package/dist-esm/error/error.util.js +0 -1
- package/dist-esm/error/errorMode.js +0 -1
- package/dist-esm/error/http.error.js +0 -1
- package/dist-esm/error/try.js +0 -1
- package/dist-esm/error/tryCatch.js +0 -1
- package/dist-esm/index.js +3 -3
- package/dist-esm/json-schema/jsonSchema.cnst.js +0 -1
- package/dist-esm/json-schema/jsonSchema.model.js +0 -1
- package/dist-esm/json-schema/jsonSchema.util.js +0 -1
- package/dist-esm/json-schema/jsonSchemaBuilder.js +9 -2
- package/dist-esm/json-schema/jsonSchemas.js +0 -1
- package/dist-esm/lodash.types.js +0 -1
- package/dist-esm/math/math.util.js +0 -1
- package/dist-esm/math/sma.js +0 -1
- package/dist-esm/number/createDeterministicRandom.js +0 -1
- package/dist-esm/number/number.util.js +0 -1
- package/dist-esm/object/deepEquals.js +0 -1
- package/dist-esm/object/object.util.js +0 -1
- package/dist-esm/object/sortObject.js +0 -1
- package/dist-esm/object/sortObjectDeep.js +0 -1
- package/dist-esm/promise/AggregatedError.js +0 -1
- package/dist-esm/promise/pBatch.js +0 -1
- package/dist-esm/promise/pDefer.js +0 -1
- package/dist-esm/promise/pDelay.js +0 -1
- package/dist-esm/promise/pFilter.js +0 -1
- package/dist-esm/promise/pHang.js +0 -1
- package/dist-esm/promise/pMap.js +0 -1
- package/dist-esm/promise/pProps.js +0 -1
- package/dist-esm/promise/pRetry.js +0 -1
- package/dist-esm/promise/pState.js +0 -1
- package/dist-esm/promise/pTimeout.js +0 -1
- package/dist-esm/promise/pTuple.js +0 -1
- package/dist-esm/string/case.js +0 -1
- package/dist-esm/string/json.util.js +0 -1
- package/dist-esm/string/lodash/unicodeWords.js +0 -1
- package/dist-esm/string/lodash/words.js +0 -1
- package/dist-esm/string/string.util.js +0 -1
- package/dist-esm/string/stringifyAny.js +1 -2
- package/dist-esm/time/time.util.js +0 -1
- package/dist-esm/typeFest.js +0 -1
- package/dist-esm/types.js +0 -1
- package/dist-esm/unit/size.util.js +0 -1
- package/dist-esm/vendor/is.js +463 -0
- package/package.json +2 -1
- package/src/index.ts +8 -1
- package/src/json-schema/jsonSchema.model.ts +8 -0
- package/src/json-schema/jsonSchemaBuilder.ts +27 -18
- package/src/string/stringifyAny.ts +2 -2
- package/src/typeFest.ts +30 -0
- package/src/vendor/is.ts +837 -0
- package/dist-esm/array/array.util.js.map +0 -1
- package/dist-esm/array/range.js.map +0 -1
- package/dist-esm/decorators/createPromiseDecorator.js.map +0 -1
- package/dist-esm/decorators/debounce.decorator.js.map +0 -1
- package/dist-esm/decorators/debounce.js.map +0 -1
- package/dist-esm/decorators/decorator.util.js.map +0 -1
- package/dist-esm/decorators/logMethod.decorator.js.map +0 -1
- package/dist-esm/decorators/memo.decorator.js.map +0 -1
- package/dist-esm/decorators/memo.util.js.map +0 -1
- package/dist-esm/decorators/memoFn.js.map +0 -1
- package/dist-esm/decorators/memoSimple.decorator.js.map +0 -1
- package/dist-esm/decorators/retry.decorator.js.map +0 -1
- package/dist-esm/decorators/timeout.decorator.js.map +0 -1
- package/dist-esm/error/app.error.js.map +0 -1
- package/dist-esm/error/assert.js.map +0 -1
- package/dist-esm/error/error.model.js.map +0 -1
- package/dist-esm/error/error.util.js.map +0 -1
- package/dist-esm/error/errorMode.js.map +0 -1
- package/dist-esm/error/http.error.js.map +0 -1
- package/dist-esm/error/try.js.map +0 -1
- package/dist-esm/error/tryCatch.js.map +0 -1
- package/dist-esm/index.js.map +0 -1
- package/dist-esm/json-schema/jsonSchema.cnst.js.map +0 -1
- package/dist-esm/json-schema/jsonSchema.model.js.map +0 -1
- package/dist-esm/json-schema/jsonSchema.util.js.map +0 -1
- package/dist-esm/json-schema/jsonSchemaBuilder.js.map +0 -1
- package/dist-esm/json-schema/jsonSchemas.js.map +0 -1
- package/dist-esm/lodash.types.js.map +0 -1
- package/dist-esm/math/math.util.js.map +0 -1
- package/dist-esm/math/sma.js.map +0 -1
- package/dist-esm/number/createDeterministicRandom.js.map +0 -1
- package/dist-esm/number/number.util.js.map +0 -1
- package/dist-esm/object/deepEquals.js.map +0 -1
- package/dist-esm/object/object.util.js.map +0 -1
- package/dist-esm/object/sortObject.js.map +0 -1
- package/dist-esm/object/sortObjectDeep.js.map +0 -1
- package/dist-esm/promise/AggregatedError.js.map +0 -1
- package/dist-esm/promise/pBatch.js.map +0 -1
- package/dist-esm/promise/pDefer.js.map +0 -1
- package/dist-esm/promise/pDelay.js.map +0 -1
- package/dist-esm/promise/pFilter.js.map +0 -1
- package/dist-esm/promise/pHang.js.map +0 -1
- package/dist-esm/promise/pMap.js.map +0 -1
- package/dist-esm/promise/pProps.js.map +0 -1
- package/dist-esm/promise/pRetry.js.map +0 -1
- package/dist-esm/promise/pState.js.map +0 -1
- package/dist-esm/promise/pTimeout.js.map +0 -1
- package/dist-esm/promise/pTuple.js.map +0 -1
- package/dist-esm/string/case.js.map +0 -1
- package/dist-esm/string/json.util.js.map +0 -1
- package/dist-esm/string/lodash/unicodeWords.js.map +0 -1
- package/dist-esm/string/lodash/words.js.map +0 -1
- package/dist-esm/string/string.util.js.map +0 -1
- package/dist-esm/string/stringifyAny.js.map +0 -1
- package/dist-esm/time/time.util.js.map +0 -1
- package/dist-esm/typeFest.js.map +0 -1
- package/dist-esm/types.js.map +0 -1
- package/dist-esm/unit/size.util.js.map +0 -1
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { _uniq } from '../array/array.util';
|
|
2
2
|
import { mergeJsonSchemaObjects, _deepCopy, _sortObject, } from '../index';
|
|
3
3
|
import { JSON_SCHEMA_ORDER } from './jsonSchema.cnst';
|
|
4
|
-
/* eslint-disable id-blacklist, @typescript-eslint/explicit-module-boundary-types */
|
|
5
4
|
/**
|
|
6
5
|
* Fluent (chainable) API to manually create Json Schemas.
|
|
7
6
|
* Inspired by Joi
|
|
@@ -33,6 +32,11 @@ export const jsonSchema = {
|
|
|
33
32
|
type: 'boolean',
|
|
34
33
|
});
|
|
35
34
|
},
|
|
35
|
+
buffer() {
|
|
36
|
+
return new JsonSchemaAnyBuilder({
|
|
37
|
+
instanceof: 'Buffer',
|
|
38
|
+
});
|
|
39
|
+
},
|
|
36
40
|
// number types
|
|
37
41
|
number() {
|
|
38
42
|
return new JsonSchemaNumberBuilder();
|
|
@@ -125,6 +129,10 @@ export class JsonSchemaAnyBuilder {
|
|
|
125
129
|
Object.assign(this.schema, { allOf: schemas });
|
|
126
130
|
return this;
|
|
127
131
|
}
|
|
132
|
+
instanceof(of) {
|
|
133
|
+
this.schema.instanceof = of;
|
|
134
|
+
return this;
|
|
135
|
+
}
|
|
128
136
|
optional(optional = true) {
|
|
129
137
|
if (optional) {
|
|
130
138
|
this.schema.optionalField = true;
|
|
@@ -341,4 +349,3 @@ export class JsonSchemaTupleBuilder extends JsonSchemaAnyBuilder {
|
|
|
341
349
|
});
|
|
342
350
|
}
|
|
343
351
|
}
|
|
344
|
-
//# sourceMappingURL=jsonSchemaBuilder.js.map
|
package/dist-esm/lodash.types.js
CHANGED
package/dist-esm/math/sma.js
CHANGED
|
@@ -3,4 +3,3 @@ export async function pFilter(iterable, filterFn, opt) {
|
|
|
3
3
|
const values = await pMap(iterable, async (item, index) => await Promise.all([filterFn(item, index), item]), opt);
|
|
4
4
|
return values.filter(value => Boolean(value[0])).map(value => value[1]);
|
|
5
5
|
}
|
|
6
|
-
//# sourceMappingURL=pFilter.js.map
|
package/dist-esm/promise/pMap.js
CHANGED
package/dist-esm/string/case.js
CHANGED
|
@@ -91,10 +91,9 @@ export function _stringifyAny(obj, opt = {}) {
|
|
|
91
91
|
if (s === undefined)
|
|
92
92
|
return 'undefined';
|
|
93
93
|
// Handle maxLen
|
|
94
|
-
const { maxLen =
|
|
94
|
+
const { maxLen = 10000 } = opt;
|
|
95
95
|
if (maxLen && s.length > maxLen) {
|
|
96
96
|
s = s.slice(0, maxLen) + `... ${Math.ceil(s.length / 1024)} KB message truncated`;
|
|
97
97
|
}
|
|
98
98
|
return s;
|
|
99
99
|
}
|
|
100
|
-
//# sourceMappingURL=stringifyAny.js.map
|
package/dist-esm/typeFest.js
CHANGED
package/dist-esm/types.js
CHANGED