@naturalcycles/js-lib 14.210.0 → 14.211.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/dist/http/fetcher.js +1 -1
- package/dist/json-schema/jsonSchemaBuilder.d.ts +1 -1
- package/dist/object/object.util.js +0 -1
- package/dist/string/stringify.js +1 -1
- package/dist/types.d.ts +10 -0
- package/dist-esm/object/object.util.js +0 -1
- package/package.json +2 -2
- package/src/array/range.ts +2 -2
- package/src/object/object.util.ts +0 -1
- package/src/string/safeJsonStringify.ts +1 -1
- package/src/types.ts +11 -0
package/dist/http/fetcher.js
CHANGED
|
@@ -24,7 +24,7 @@ export declare const jsonSchema: {
|
|
|
24
24
|
dateString(): JsonSchemaStringBuilder;
|
|
25
25
|
object<T_4 extends AnyObject>(props: { [k in keyof T_4]: JsonSchemaAnyBuilder<T_4[k], JsonSchema<T_4[k]>>; }): JsonSchemaObjectBuilder<T_4>;
|
|
26
26
|
rootObject<T_5 extends AnyObject>(props: { [k_1 in keyof T_5]: JsonSchemaAnyBuilder<T_5[k_1], JsonSchema<T_5[k_1]>>; }): JsonSchemaObjectBuilder<T_5>;
|
|
27
|
-
array<ITEM = unknown>(itemSchema: JsonSchemaAnyBuilder<ITEM
|
|
27
|
+
array<ITEM = unknown>(itemSchema: JsonSchemaAnyBuilder<ITEM>): JsonSchemaArrayBuilder<ITEM>;
|
|
28
28
|
tuple<T_6 extends any[] = unknown[]>(items: JsonSchemaAnyBuilder[]): JsonSchemaTupleBuilder<T_6>;
|
|
29
29
|
oneOf<T_7 = unknown>(items: JsonSchemaAnyBuilder[]): JsonSchemaAnyBuilder<T_7, JsonSchemaOneOf<T_7>>;
|
|
30
30
|
allOf<T_8 = unknown>(items: JsonSchemaAnyBuilder[]): JsonSchemaAnyBuilder<T_8, JsonSchemaAllOf<T_8>>;
|
|
@@ -329,7 +329,6 @@ function _set(obj, path, value) {
|
|
|
329
329
|
a[c]
|
|
330
330
|
: // No: create the key. Is the next key a potential array-index?
|
|
331
331
|
(a[c] =
|
|
332
|
-
// @ts-expect-error
|
|
333
332
|
// eslint-disable-next-line
|
|
334
333
|
Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
335
334
|
? [] // Yes: assign a new array object
|
package/dist/string/stringify.js
CHANGED
|
@@ -123,7 +123,7 @@ function _stringify(obj, opt = {}) {
|
|
|
123
123
|
if (s === undefined)
|
|
124
124
|
return 'undefined';
|
|
125
125
|
// Handle maxLen
|
|
126
|
-
const { maxLen =
|
|
126
|
+
const { maxLen = 10_000 } = opt;
|
|
127
127
|
if (maxLen && s.length > maxLen) {
|
|
128
128
|
s = s.slice(0, maxLen) + `... ${Math.ceil(s.length / 1024)} KB message truncated`;
|
|
129
129
|
}
|
package/dist/types.d.ts
CHANGED
|
@@ -177,6 +177,16 @@ export type NumberOfMilliseconds = number;
|
|
|
177
177
|
* Same as `number`, but with semantic meaning that it's an Integer.
|
|
178
178
|
*/
|
|
179
179
|
export type Integer = number;
|
|
180
|
+
/**
|
|
181
|
+
* Convenience type alias, that allows to write this:
|
|
182
|
+
*
|
|
183
|
+
* data: NullableNumber[]
|
|
184
|
+
*
|
|
185
|
+
* instead of this:
|
|
186
|
+
*
|
|
187
|
+
* data: (number | null)[]
|
|
188
|
+
*/
|
|
189
|
+
export type NullableNumber = number | null;
|
|
180
190
|
/**
|
|
181
191
|
* Used as a compact representation of truthy value.
|
|
182
192
|
* undefined ('' or other short falsy value) should be used as falsy value.
|
|
@@ -306,7 +306,6 @@ export function _set(obj, path, value) {
|
|
|
306
306
|
a[c]
|
|
307
307
|
: // No: create the key. Is the next key a potential array-index?
|
|
308
308
|
(a[c] =
|
|
309
|
-
// @ts-expect-error
|
|
310
309
|
// eslint-disable-next-line
|
|
311
310
|
Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
312
311
|
? [] // Yes: assign a new array object
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/js-lib",
|
|
3
|
-
"version": "14.
|
|
3
|
+
"version": "14.211.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
6
|
"build-prod": "build-prod-esm-cjs",
|
|
@@ -13,7 +13,7 @@
|
|
|
13
13
|
"zod": "^3.20.2"
|
|
14
14
|
},
|
|
15
15
|
"devDependencies": {
|
|
16
|
-
"@naturalcycles/bench-lib": "^
|
|
16
|
+
"@naturalcycles/bench-lib": "^2.0.0",
|
|
17
17
|
"@naturalcycles/dev-lib": "^13.0.1",
|
|
18
18
|
"@naturalcycles/nodejs-lib": "^13.0.1",
|
|
19
19
|
"@naturalcycles/time-lib": "^3.5.1",
|
package/src/array/range.ts
CHANGED
|
@@ -39,7 +39,7 @@ export function _rangeIterable(fromIncl: number, toExcl?: number, step = 1): Ite
|
|
|
39
39
|
|
|
40
40
|
return Iterable2.of({
|
|
41
41
|
*[Symbol.iterator]() {
|
|
42
|
-
for (let i = fromIncl; i < toExcl
|
|
42
|
+
for (let i = fromIncl; i < toExcl; i += step) {
|
|
43
43
|
yield i
|
|
44
44
|
}
|
|
45
45
|
},
|
|
@@ -67,7 +67,7 @@ export function _rangeAsyncIterable(
|
|
|
67
67
|
|
|
68
68
|
return AsyncIterable2.of({
|
|
69
69
|
async *[Symbol.asyncIterator]() {
|
|
70
|
-
for (let i = fromIncl; i < toExcl
|
|
70
|
+
for (let i = fromIncl; i < toExcl; i += step) {
|
|
71
71
|
yield i
|
|
72
72
|
}
|
|
73
73
|
},
|
|
@@ -360,7 +360,6 @@ export function _set<T extends AnyObject>(obj: T, path: PropertyPath, value: any
|
|
|
360
360
|
a[c]
|
|
361
361
|
: // No: create the key. Is the next key a potential array-index?
|
|
362
362
|
(a[c] =
|
|
363
|
-
// @ts-expect-error
|
|
364
363
|
// eslint-disable-next-line
|
|
365
364
|
Math.abs(path[i + 1]) >> 0 === +path[i + 1]
|
|
366
365
|
? [] // Yes: assign a new array object
|
|
@@ -37,7 +37,7 @@ function serializer(replacer?: Reviver, cycleReplacer?: Reviver): Reviver {
|
|
|
37
37
|
~thisPos ? stack.splice(thisPos + 1) : stack.push(this)
|
|
38
38
|
~thisPos ? keys.splice(thisPos, Infinity, key) : keys.push(key)
|
|
39
39
|
if (~stack.indexOf(value)) {
|
|
40
|
-
value = cycleReplacer
|
|
40
|
+
value = cycleReplacer.call(this, key, value)
|
|
41
41
|
}
|
|
42
42
|
} else {
|
|
43
43
|
stack.push(value)
|
package/src/types.ts
CHANGED
|
@@ -235,6 +235,17 @@ export type NumberOfMilliseconds = number
|
|
|
235
235
|
*/
|
|
236
236
|
export type Integer = number
|
|
237
237
|
|
|
238
|
+
/**
|
|
239
|
+
* Convenience type alias, that allows to write this:
|
|
240
|
+
*
|
|
241
|
+
* data: NullableNumber[]
|
|
242
|
+
*
|
|
243
|
+
* instead of this:
|
|
244
|
+
*
|
|
245
|
+
* data: (number | null)[]
|
|
246
|
+
*/
|
|
247
|
+
export type NullableNumber = number | null
|
|
248
|
+
|
|
238
249
|
/**
|
|
239
250
|
* Used as a compact representation of truthy value.
|
|
240
251
|
* undefined ('' or other short falsy value) should be used as falsy value.
|