is-kit 1.16.4 → 1.16.5

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/README.md CHANGED
@@ -112,6 +112,18 @@ ship the legacy JavaScript Compiler API. Tools that need that API can follow
112
112
  the official [TypeScript 7 side-by-side guidance](https://devblogs.microsoft.com/typescript/announcing-typescript-7-0/#running-side-by-side-with-typescript-6-0)
113
113
  and use `@typescript/typescript6` for programmatic access.
114
114
 
115
+ ### Runtime compatibility
116
+
117
+ - **Node.js 22 or newer** is the supported runtime baseline, matching the
118
+ `engines` field in `package.json`.
119
+ - The published TypeScript declarations support **TypeScript 5.4 and newer**.
120
+ - Both **ESM and CommonJS** builds are published, so `import` and `require`
121
+ consumers are equally supported.
122
+
123
+ `is-kit` may appear to run on an older Node.js version, but successful
124
+ execution there does not imply official support: only the baseline above is
125
+ covered by the project's compatibility guarantees and CI.
126
+
115
127
  vlt requires registry configuration before installing a package by name. Run
116
128
  `vlt setup` once if a registry has not been configured yet.
117
129
 
@@ -838,6 +850,9 @@ public root exports are planned for removal.
838
850
  For detailed API pages and more examples, see:
839
851
 
840
852
  - [Practical guides](https://is-kit.dev/guides)
853
+ - [Design principles and non-goals](https://is-kit.dev/guides/design-principles)
854
+ - [Best practices for real projects](https://is-kit.dev/guides/best-practices)
855
+ - [Where to validate in a real application](https://is-kit.dev/guides/where-to-validate)
841
856
  - [Keep hand-written type guards in sync with TypeScript types](https://is-kit.dev/guides/keep-type-guards-in-sync)
842
857
  - [Refine properties on existing TypeScript types](https://is-kit.dev/guides/refine-properties-on-existing-types)
843
858
  - [Advanced property refinement with the TypeScript Compiler API](https://is-kit.dev/guides/typescript-compiler-api)
package/bin/is-kit.mjs CHANGED
@@ -27,19 +27,39 @@ const fileExists = async (path) => {
27
27
  }
28
28
  };
29
29
 
30
- const parseTarget = (args) => {
31
- const targetIndex = args.indexOf('--target');
30
+ const validateTargetValue = (value) => {
31
+ if (value === undefined || value.length === 0) {
32
+ throw new Error('Missing value for --target');
33
+ }
32
34
 
33
- if (targetIndex === -1) {
34
- return 'agents';
35
+ if (!Object.hasOwn(TARGET_FILES, value)) {
36
+ throw new Error(`Unknown target: ${value}`);
35
37
  }
36
38
 
37
- const target = args[targetIndex + 1];
38
- if (!Object.hasOwn(TARGET_FILES, target)) {
39
- throw new Error(`Unknown target: ${target ?? '(missing)'}`);
39
+ return value;
40
+ };
41
+
42
+ const parseTarget = (args) => {
43
+ let target;
44
+
45
+ for (let index = 0; index < args.length; index += 1) {
46
+ const arg = args[index];
47
+
48
+ if (arg === '--target' || arg.startsWith('--target=')) {
49
+ if (target !== undefined) {
50
+ throw new Error('Repeated --target option');
51
+ }
52
+
53
+ const isInline = arg.startsWith('--target=');
54
+ const value = isInline ? arg.slice('--target='.length) : args[++index];
55
+ target = validateTargetValue(value);
56
+ continue;
57
+ }
58
+
59
+ throw new Error(`Unknown option: ${arg}`);
40
60
  }
41
61
 
42
- return target;
62
+ return target ?? 'agents';
43
63
  };
44
64
 
45
65
  const updateManagedSection = (existingContent, rules) => {
package/dist/index.js CHANGED
@@ -39,6 +39,19 @@ const objectToString = Object.prototype.toString;
39
39
  */
40
40
  const getTag = (value) => objectToString.call(value);
41
41
  //#endregion
42
+ //#region src/utils/object-prototype.ts
43
+ const OBJECT_CONSTRUCTOR_SOURCE = Function.prototype.toString.call(Object);
44
+ /**
45
+ * Checks whether an object is `Object.prototype` from any realm.
46
+ *
47
+ * @param prototype Object to check.
48
+ * @returns Whether `prototype` is an `Object.prototype`.
49
+ */
50
+ const isObjectPrototype = (prototype) => {
51
+ const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
52
+ return typeof constructor === "function" && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === OBJECT_CONSTRUCTOR_SOURCE;
53
+ };
54
+ //#endregion
42
55
  //#region src/core/object.ts
43
56
  const BUILTIN_BRAND_SENTINEL = Object.freeze({});
44
57
  const nativeIsError = Error.isError;
@@ -89,7 +102,8 @@ const readObjectProperty = (value, key) => {
89
102
  const isPlainObject = define((value) => {
90
103
  if (!isObject(value)) return false;
91
104
  const proto = Object.getPrototypeOf(value);
92
- return proto === null || Object.getPrototypeOf(proto) === null;
105
+ if (proto === null || proto === Object.prototype) return true;
106
+ return Object.getPrototypeOf(proto) === null && isObjectPrototype(proto);
93
107
  });
94
108
  /**
95
109
  * Checks whether a value is an array.
@@ -816,7 +830,7 @@ const createSetPredicate = (items) => {
816
830
  });
817
831
  };
818
832
  function oneOfValues(...args) {
819
- const items = normalizeValues(args);
833
+ const items = [...normalizeValues(args)];
820
834
  return items.length <= ONE_OF_VALUES_LINEAR_SCAN_MAX ? createLinearPredicate(items) : createSetPredicate(items);
821
835
  }
822
836
  //#endregion
@@ -847,11 +861,6 @@ function setOf(valueGuard) {
847
861
  }
848
862
  //#endregion
849
863
  //#region src/core/combinators/struct.ts
850
- const OBJECT_CONSTRUCTOR_SOURCE = Function.prototype.toString.call(Object);
851
- const isObjectPrototype = (prototype) => {
852
- const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
853
- return typeof constructor === "function" && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === OBJECT_CONSTRUCTOR_SOURCE;
854
- };
855
864
  const hasOnlyEnumerableOwnStringKeys = (schema) => Object.getOwnPropertyNames(schema).every((key) => Object.prototype.propertyIsEnumerable.call(schema, key));
856
865
  const hasInheritedStringKeys = (schema) => {
857
866
  let prototype = Object.getPrototypeOf(schema);
package/dist/index.mjs CHANGED
@@ -38,6 +38,19 @@ const objectToString = Object.prototype.toString;
38
38
  */
39
39
  const getTag = (value) => objectToString.call(value);
40
40
  //#endregion
41
+ //#region src/utils/object-prototype.ts
42
+ const OBJECT_CONSTRUCTOR_SOURCE = Function.prototype.toString.call(Object);
43
+ /**
44
+ * Checks whether an object is `Object.prototype` from any realm.
45
+ *
46
+ * @param prototype Object to check.
47
+ * @returns Whether `prototype` is an `Object.prototype`.
48
+ */
49
+ const isObjectPrototype = (prototype) => {
50
+ const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
51
+ return typeof constructor === "function" && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === OBJECT_CONSTRUCTOR_SOURCE;
52
+ };
53
+ //#endregion
41
54
  //#region src/core/object.ts
42
55
  const BUILTIN_BRAND_SENTINEL = Object.freeze({});
43
56
  const nativeIsError = Error.isError;
@@ -88,7 +101,8 @@ const readObjectProperty = (value, key) => {
88
101
  const isPlainObject = define((value) => {
89
102
  if (!isObject(value)) return false;
90
103
  const proto = Object.getPrototypeOf(value);
91
- return proto === null || Object.getPrototypeOf(proto) === null;
104
+ if (proto === null || proto === Object.prototype) return true;
105
+ return Object.getPrototypeOf(proto) === null && isObjectPrototype(proto);
92
106
  });
93
107
  /**
94
108
  * Checks whether a value is an array.
@@ -815,7 +829,7 @@ const createSetPredicate = (items) => {
815
829
  });
816
830
  };
817
831
  function oneOfValues(...args) {
818
- const items = normalizeValues(args);
832
+ const items = [...normalizeValues(args)];
819
833
  return items.length <= ONE_OF_VALUES_LINEAR_SCAN_MAX ? createLinearPredicate(items) : createSetPredicate(items);
820
834
  }
821
835
  //#endregion
@@ -846,11 +860,6 @@ function setOf(valueGuard) {
846
860
  }
847
861
  //#endregion
848
862
  //#region src/core/combinators/struct.ts
849
- const OBJECT_CONSTRUCTOR_SOURCE = Function.prototype.toString.call(Object);
850
- const isObjectPrototype = (prototype) => {
851
- const constructor = Object.getOwnPropertyDescriptor(prototype, "constructor")?.value;
852
- return typeof constructor === "function" && constructor.prototype === prototype && Function.prototype.toString.call(constructor) === OBJECT_CONSTRUCTOR_SOURCE;
853
- };
854
863
  const hasOnlyEnumerableOwnStringKeys = (schema) => Object.getOwnPropertyNames(schema).every((key) => Object.prototype.propertyIsEnumerable.call(schema, key));
855
864
  const hasInheritedStringKeys = (schema) => {
856
865
  let prototype = Object.getPrototypeOf(schema);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-kit",
3
- "version": "1.16.4",
3
+ "version": "1.16.5",
4
4
  "description": "Zero-dependency TypeScript runtime validation toolkit for composable type guards and natural type narrowing.",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",