@naturalcycles/nodejs-lib 15.108.0 → 15.109.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.
@@ -52,5 +52,5 @@ export function arrayToCSVColumns(arr) {
52
52
  cols.add(col);
53
53
  }
54
54
  }
55
- return [...cols];
55
+ return Array.from(cols);
56
56
  }
package/dist/fs/fs2.d.ts CHANGED
@@ -63,9 +63,9 @@ declare class FS2 {
63
63
  isDirectory(filePath: string): boolean;
64
64
  fs: typeof fs;
65
65
  fsp: typeof fsp;
66
- lstat: fs.StatSyncFn;
66
+ lstat: typeof fs.lstatSync;
67
67
  lstatAsync: typeof fsp.lstat;
68
- stat: fs.StatSyncFn;
68
+ stat: typeof fs.statSync;
69
69
  statAsync: typeof fsp.stat;
70
70
  mkdir: typeof fs.mkdirSync;
71
71
  mkdirAsync: typeof fsp.mkdir;
@@ -23,7 +23,7 @@ function objectToJsonSchema(rows) {
23
23
  additionalProperties: true,
24
24
  };
25
25
  _stringMapEntries(typesByKey).forEach(([key, types]) => {
26
- const schema = mergeTypes([...types], rows.map(r => r[key]));
26
+ const schema = mergeTypes(Array.from(types), rows.map(r => r[key]));
27
27
  if (!schema)
28
28
  return;
29
29
  s.properties[key] = schema;
@@ -472,14 +472,14 @@ export class JBuilder extends JSchema {
472
472
  const innerSchema = {
473
473
  ...(builtSchema.type ? { type: builtSchema.type } : {}),
474
474
  anyOf: [builtSchema, alternativesSchema],
475
- optionalValues: [...optionalValues],
475
+ optionalValues: optionalValues.slice(),
476
476
  };
477
477
  // When `null` is specified, we want `null` to be stripped and the value to become `undefined`,
478
478
  // so we must allow `null` values to be parsed by Ajv,
479
479
  // but the typing should not reflect that.
480
480
  if (optionalValues.includes(null)) {
481
481
  return new JSchema({
482
- anyOf: [{ type: 'null', optionalValues: [...optionalValues] }, innerSchema],
482
+ anyOf: [{ type: 'null', optionalValues: optionalValues.slice() }, innerSchema],
483
483
  optionalField: true,
484
484
  });
485
485
  }
@@ -1111,9 +1111,7 @@ export class AjvSchema {
1111
1111
  cfg;
1112
1112
  _compiledFn;
1113
1113
  _getValidateFn() {
1114
- if (!this._compiledFn) {
1115
- this._compiledFn = this.cfg.ajv.compile(this.schema);
1116
- }
1114
+ this._compiledFn ||= this.cfg.ajv.compile(this.schema);
1117
1115
  return this._compiledFn;
1118
1116
  }
1119
1117
  /**
@@ -1407,7 +1405,7 @@ function deepCopyPreservingFunctions(obj) {
1407
1405
  const value = obj[key];
1408
1406
  copy[key] =
1409
1407
  (key === 'customValidations' || key === 'customConversions') && Array.isArray(value)
1410
- ? [...value]
1408
+ ? value.slice()
1411
1409
  : deepCopyPreservingFunctions(value);
1412
1410
  }
1413
1411
  return copy;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.108.0",
4
+ "version": "15.109.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
@@ -18,7 +18,7 @@
18
18
  },
19
19
  "devDependencies": {
20
20
  "@typescript/native-preview": "beta",
21
- "@naturalcycles/dev-lib": "18.4.2"
21
+ "@naturalcycles/dev-lib": "20.48.0"
22
22
  },
23
23
  "exports": {
24
24
  ".": "./dist/index.js",
@@ -83,5 +83,5 @@ export function arrayToCSVColumns(arr: AnyObject[]): string[] {
83
83
  cols.add(col)
84
84
  }
85
85
  }
86
- return [...cols]
86
+ return Array.from(cols)
87
87
  }
@@ -36,7 +36,7 @@ function objectToJsonSchema<T extends AnyObject>(rows: AnyObject[]): JsonSchema<
36
36
 
37
37
  _stringMapEntries(typesByKey).forEach(([key, types]) => {
38
38
  const schema = mergeTypes(
39
- [...types],
39
+ Array.from(types),
40
40
  rows.map(r => r[key]),
41
41
  )
42
42
  if (!schema) return
@@ -644,7 +644,7 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
644
644
  const innerSchema: JsonSchema = {
645
645
  ...(builtSchema.type ? { type: builtSchema.type } : {}),
646
646
  anyOf: [builtSchema, alternativesSchema],
647
- optionalValues: [...optionalValues],
647
+ optionalValues: optionalValues.slice(),
648
648
  }
649
649
 
650
650
  // When `null` is specified, we want `null` to be stripped and the value to become `undefined`,
@@ -652,7 +652,7 @@ export class JBuilder<OUT, Opt> extends JSchema<OUT, Opt> {
652
652
  // but the typing should not reflect that.
653
653
  if (optionalValues.includes(null)) {
654
654
  return new JSchema({
655
- anyOf: [{ type: 'null', optionalValues: [...optionalValues] }, innerSchema],
655
+ anyOf: [{ type: 'null', optionalValues: optionalValues.slice() }, innerSchema],
656
656
  optionalField: true,
657
657
  }) as any
658
658
  }
@@ -1598,9 +1598,7 @@ export class AjvSchema<OUT> {
1598
1598
  private _compiledFn: any
1599
1599
 
1600
1600
  private _getValidateFn(): any {
1601
- if (!this._compiledFn) {
1602
- this._compiledFn = this.cfg.ajv.compile(this.schema as any)
1603
- }
1601
+ this._compiledFn ||= this.cfg.ajv.compile(this.schema as any)
1604
1602
  return this._compiledFn
1605
1603
  }
1606
1604
 
@@ -1974,7 +1972,7 @@ function deepCopyPreservingFunctions<T>(obj: T): T {
1974
1972
  // customValidations/customConversions are arrays of functions - shallow copy the array
1975
1973
  ;(copy as any)[key] =
1976
1974
  (key === 'customValidations' || key === 'customConversions') && Array.isArray(value)
1977
- ? [...value]
1975
+ ? value.slice()
1978
1976
  : deepCopyPreservingFunctions(value)
1979
1977
  }
1980
1978
  return copy