is-kit 1.11.4 → 1.11.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
@@ -176,7 +176,7 @@ Add the recommended `is-kit` selection and usage rules to a repository's AI
176
176
  agent instructions:
177
177
 
178
178
  ```bash
179
- npx is-kit init-agent
179
+ npx --yes is-kit@latest init-agent
180
180
  ```
181
181
 
182
182
  The command updates an `is-kit`-managed section in `AGENTS.md` without
@@ -184,7 +184,7 @@ overwriting other instructions. If a repository uses `CLAUDE.md`, target it
184
184
  explicitly:
185
185
 
186
186
  ```bash
187
- npx is-kit init-agent --target claude
187
+ npx --yes is-kit@latest init-agent --target claude
188
188
  ```
189
189
 
190
190
  See [docs/agent-rules.md](./docs/agent-rules.md) for the installed rules.
package/dist/index.js CHANGED
@@ -119,6 +119,8 @@ var hasOwnPropertyKey = (value, key) => Object.hasOwn(value, key);
119
119
  var hasOwnPropertyKeys = (value, keys) => keys.every((key) => hasOwnPropertyKey(value, key));
120
120
 
121
121
  // src/utils/guard-collections.ts
122
+ var mapEntries = Map.prototype.entries;
123
+ var setValues = Set.prototype.values;
122
124
  var everyIterableValue = (values, predicate) => {
123
125
  for (const value of values) {
124
126
  if (!predicate(value)) return false;
@@ -141,10 +143,15 @@ var everyTupleValue = (values, predicates) => {
141
143
  return true;
142
144
  };
143
145
  var everySetValue = (values, predicate) => everyIterableValue(values, predicate);
146
+ var everyBrandedSetValue = (values, predicate) => everyIterableValue(setValues.call(values), predicate);
144
147
  var everyMapEntry = (values, keyPredicate, valuePredicate) => everyKeyValueEntry(
145
148
  values,
146
149
  (key, value) => keyPredicate(key) && valuePredicate(value)
147
150
  );
151
+ var everyBrandedMapEntry = (values, keyPredicate, valuePredicate) => everyKeyValueEntry(
152
+ mapEntries.call(values),
153
+ (key, value) => keyPredicate(key) && valuePredicate(value)
154
+ );
148
155
  var everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => everyIterableValue(
149
156
  Object.keys(values),
150
157
  (key) => keyPredicate(key) && valuePredicate(values[key])
@@ -152,14 +159,6 @@ var everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => everyIte
152
159
 
153
160
  // src/utils/object-tags.ts
154
161
  var objectToString = Object.prototype.toString;
155
- var OBJECT_TAG_DATE = "[object Date]";
156
- var OBJECT_TAG_REGEXP = "[object RegExp]";
157
- var OBJECT_TAG_MAP = "[object Map]";
158
- var OBJECT_TAG_SET = "[object Set]";
159
- var OBJECT_TAG_WEAK_MAP = "[object WeakMap]";
160
- var OBJECT_TAG_WEAK_SET = "[object WeakSet]";
161
- var OBJECT_TAG_ARRAY_BUFFER = "[object ArrayBuffer]";
162
- var OBJECT_TAG_DATA_VIEW = "[object DataView]";
163
162
  var OBJECT_TAG_ERROR = "[object Error]";
164
163
  var getTag = (value) => objectToString.call(value);
165
164
 
@@ -167,7 +166,32 @@ var getTag = (value) => objectToString.call(value);
167
166
  var toBooleanPredicates = (predicates) => predicates;
168
167
 
169
168
  // src/core/object.ts
170
- var defineTagGuard = (tag) => define((value) => getTag(value) === tag);
169
+ var BUILTIN_BRAND_SENTINEL = Object.freeze({});
170
+ var getIntrinsicGetter = (prototype, key) => {
171
+ const getter = Object.getOwnPropertyDescriptor(prototype, key)?.get;
172
+ return getter ?? (() => {
173
+ throw new TypeError(`Missing intrinsic getter: ${String(key)}`);
174
+ });
175
+ };
176
+ var defineIntrinsicBrandGuard = (checkBrand) => define((value) => {
177
+ try {
178
+ checkBrand(value);
179
+ return true;
180
+ } catch {
181
+ return false;
182
+ }
183
+ });
184
+ var dateGetTime = Date.prototype.getTime;
185
+ var mapHas = Map.prototype.has;
186
+ var setHas = Set.prototype.has;
187
+ var weakMapHas = WeakMap.prototype.has;
188
+ var weakSetHas = WeakSet.prototype.has;
189
+ var regExpSource = getIntrinsicGetter(RegExp.prototype, "source");
190
+ var arrayBufferByteLength = getIntrinsicGetter(
191
+ ArrayBuffer.prototype,
192
+ "byteLength"
193
+ );
194
+ var dataViewBuffer = getIntrinsicGetter(DataView.prototype, "buffer");
171
195
  var defineOptionalInstanceGuard = (constructor) => constructor === void 0 ? define(() => false) : define(
172
196
  (value) => typeof constructor === "function" && value instanceof constructor
173
197
  );
@@ -187,14 +211,28 @@ var isPlainObject = define((value) => {
187
211
  return proto === null || Object.getPrototypeOf(proto) === null;
188
212
  });
189
213
  var isArray = define(Array.isArray);
190
- var isDate = define(
191
- (value) => getTag(value) === OBJECT_TAG_DATE && !Number.isNaN(value.getTime())
192
- );
193
- var isRegExp = defineTagGuard(OBJECT_TAG_REGEXP);
194
- var isMap = defineTagGuard(OBJECT_TAG_MAP);
195
- var isSet = defineTagGuard(OBJECT_TAG_SET);
196
- var isWeakMap = defineTagGuard(OBJECT_TAG_WEAK_MAP);
197
- var isWeakSet = defineTagGuard(OBJECT_TAG_WEAK_SET);
214
+ var isDate = define((value) => {
215
+ try {
216
+ return !Number.isNaN(dateGetTime.call(value));
217
+ } catch {
218
+ return false;
219
+ }
220
+ });
221
+ var isRegExp = defineIntrinsicBrandGuard(
222
+ (value) => regExpSource.call(value)
223
+ );
224
+ var isMap = defineIntrinsicBrandGuard(
225
+ (value) => mapHas.call(value, BUILTIN_BRAND_SENTINEL)
226
+ );
227
+ var isSet = defineIntrinsicBrandGuard(
228
+ (value) => setHas.call(value, BUILTIN_BRAND_SENTINEL)
229
+ );
230
+ var isWeakMap = defineIntrinsicBrandGuard(
231
+ (value) => weakMapHas.call(value, BUILTIN_BRAND_SENTINEL)
232
+ );
233
+ var isWeakSet = defineIntrinsicBrandGuard(
234
+ (value) => weakSetHas.call(value, BUILTIN_BRAND_SENTINEL)
235
+ );
198
236
  var isPromiseLike = define(
199
237
  (value) => isFunction(readObjectProperty(value, "then"))
200
238
  );
@@ -204,10 +242,14 @@ var isIterable = define(
204
242
  var isAsyncIterable = define(
205
243
  (value) => isFunction(readObjectProperty(value, Symbol.asyncIterator))
206
244
  );
207
- var isArrayBuffer = defineTagGuard(OBJECT_TAG_ARRAY_BUFFER);
208
- var isDataView = defineTagGuard(OBJECT_TAG_DATA_VIEW);
245
+ var isArrayBuffer = defineIntrinsicBrandGuard(
246
+ (value) => arrayBufferByteLength.call(value)
247
+ );
248
+ var isDataView = defineIntrinsicBrandGuard(
249
+ (value) => dataViewBuffer.call(value)
250
+ );
209
251
  var isTypedArray = define(
210
- (value) => ArrayBuffer.isView(value) && getTag(value) !== OBJECT_TAG_DATA_VIEW
252
+ (value) => ArrayBuffer.isView(value) && !isDataView(value)
211
253
  );
212
254
  var isError = define(
213
255
  (value) => value instanceof Error || getTag(value) === OBJECT_TAG_ERROR
@@ -406,7 +448,7 @@ function nonEmptyArrayOf(elementGuard) {
406
448
  // src/core/combinators/map.ts
407
449
  function mapOf(keyGuard, valueGuard) {
408
450
  return define(
409
- (input) => isMap(input) && everyMapEntry(input, keyGuard, valueGuard)
451
+ (input) => isMap(input) && everyBrandedMapEntry(input, keyGuard, valueGuard)
410
452
  );
411
453
  }
412
454
 
@@ -460,7 +502,7 @@ function recordOf(keyFunction, valueFunction) {
460
502
  // src/core/combinators/set.ts
461
503
  function setOf(valueGuard) {
462
504
  return define(
463
- (input) => isSet(input) && everySetValue(input, valueGuard)
505
+ (input) => isSet(input) && everyBrandedSetValue(input, valueGuard)
464
506
  );
465
507
  }
466
508
 
package/dist/index.mjs CHANGED
@@ -15,6 +15,8 @@ var hasOwnPropertyKey = (value, key) => Object.hasOwn(value, key);
15
15
  var hasOwnPropertyKeys = (value, keys) => keys.every((key) => hasOwnPropertyKey(value, key));
16
16
 
17
17
  // src/utils/guard-collections.ts
18
+ var mapEntries = Map.prototype.entries;
19
+ var setValues = Set.prototype.values;
18
20
  var everyIterableValue = (values, predicate) => {
19
21
  for (const value of values) {
20
22
  if (!predicate(value)) return false;
@@ -37,10 +39,15 @@ var everyTupleValue = (values, predicates) => {
37
39
  return true;
38
40
  };
39
41
  var everySetValue = (values, predicate) => everyIterableValue(values, predicate);
42
+ var everyBrandedSetValue = (values, predicate) => everyIterableValue(setValues.call(values), predicate);
40
43
  var everyMapEntry = (values, keyPredicate, valuePredicate) => everyKeyValueEntry(
41
44
  values,
42
45
  (key, value) => keyPredicate(key) && valuePredicate(value)
43
46
  );
47
+ var everyBrandedMapEntry = (values, keyPredicate, valuePredicate) => everyKeyValueEntry(
48
+ mapEntries.call(values),
49
+ (key, value) => keyPredicate(key) && valuePredicate(value)
50
+ );
44
51
  var everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => everyIterableValue(
45
52
  Object.keys(values),
46
53
  (key) => keyPredicate(key) && valuePredicate(values[key])
@@ -48,14 +55,6 @@ var everyOwnEnumerableEntry = (values, keyPredicate, valuePredicate) => everyIte
48
55
 
49
56
  // src/utils/object-tags.ts
50
57
  var objectToString = Object.prototype.toString;
51
- var OBJECT_TAG_DATE = "[object Date]";
52
- var OBJECT_TAG_REGEXP = "[object RegExp]";
53
- var OBJECT_TAG_MAP = "[object Map]";
54
- var OBJECT_TAG_SET = "[object Set]";
55
- var OBJECT_TAG_WEAK_MAP = "[object WeakMap]";
56
- var OBJECT_TAG_WEAK_SET = "[object WeakSet]";
57
- var OBJECT_TAG_ARRAY_BUFFER = "[object ArrayBuffer]";
58
- var OBJECT_TAG_DATA_VIEW = "[object DataView]";
59
58
  var OBJECT_TAG_ERROR = "[object Error]";
60
59
  var getTag = (value) => objectToString.call(value);
61
60
 
@@ -63,7 +62,32 @@ var getTag = (value) => objectToString.call(value);
63
62
  var toBooleanPredicates = (predicates) => predicates;
64
63
 
65
64
  // src/core/object.ts
66
- var defineTagGuard = (tag) => define((value) => getTag(value) === tag);
65
+ var BUILTIN_BRAND_SENTINEL = Object.freeze({});
66
+ var getIntrinsicGetter = (prototype, key) => {
67
+ const getter = Object.getOwnPropertyDescriptor(prototype, key)?.get;
68
+ return getter ?? (() => {
69
+ throw new TypeError(`Missing intrinsic getter: ${String(key)}`);
70
+ });
71
+ };
72
+ var defineIntrinsicBrandGuard = (checkBrand) => define((value) => {
73
+ try {
74
+ checkBrand(value);
75
+ return true;
76
+ } catch {
77
+ return false;
78
+ }
79
+ });
80
+ var dateGetTime = Date.prototype.getTime;
81
+ var mapHas = Map.prototype.has;
82
+ var setHas = Set.prototype.has;
83
+ var weakMapHas = WeakMap.prototype.has;
84
+ var weakSetHas = WeakSet.prototype.has;
85
+ var regExpSource = getIntrinsicGetter(RegExp.prototype, "source");
86
+ var arrayBufferByteLength = getIntrinsicGetter(
87
+ ArrayBuffer.prototype,
88
+ "byteLength"
89
+ );
90
+ var dataViewBuffer = getIntrinsicGetter(DataView.prototype, "buffer");
67
91
  var defineOptionalInstanceGuard = (constructor) => constructor === void 0 ? define(() => false) : define(
68
92
  (value) => typeof constructor === "function" && value instanceof constructor
69
93
  );
@@ -83,14 +107,28 @@ var isPlainObject = define((value) => {
83
107
  return proto === null || Object.getPrototypeOf(proto) === null;
84
108
  });
85
109
  var isArray = define(Array.isArray);
86
- var isDate = define(
87
- (value) => getTag(value) === OBJECT_TAG_DATE && !Number.isNaN(value.getTime())
88
- );
89
- var isRegExp = defineTagGuard(OBJECT_TAG_REGEXP);
90
- var isMap = defineTagGuard(OBJECT_TAG_MAP);
91
- var isSet = defineTagGuard(OBJECT_TAG_SET);
92
- var isWeakMap = defineTagGuard(OBJECT_TAG_WEAK_MAP);
93
- var isWeakSet = defineTagGuard(OBJECT_TAG_WEAK_SET);
110
+ var isDate = define((value) => {
111
+ try {
112
+ return !Number.isNaN(dateGetTime.call(value));
113
+ } catch {
114
+ return false;
115
+ }
116
+ });
117
+ var isRegExp = defineIntrinsicBrandGuard(
118
+ (value) => regExpSource.call(value)
119
+ );
120
+ var isMap = defineIntrinsicBrandGuard(
121
+ (value) => mapHas.call(value, BUILTIN_BRAND_SENTINEL)
122
+ );
123
+ var isSet = defineIntrinsicBrandGuard(
124
+ (value) => setHas.call(value, BUILTIN_BRAND_SENTINEL)
125
+ );
126
+ var isWeakMap = defineIntrinsicBrandGuard(
127
+ (value) => weakMapHas.call(value, BUILTIN_BRAND_SENTINEL)
128
+ );
129
+ var isWeakSet = defineIntrinsicBrandGuard(
130
+ (value) => weakSetHas.call(value, BUILTIN_BRAND_SENTINEL)
131
+ );
94
132
  var isPromiseLike = define(
95
133
  (value) => isFunction(readObjectProperty(value, "then"))
96
134
  );
@@ -100,10 +138,14 @@ var isIterable = define(
100
138
  var isAsyncIterable = define(
101
139
  (value) => isFunction(readObjectProperty(value, Symbol.asyncIterator))
102
140
  );
103
- var isArrayBuffer = defineTagGuard(OBJECT_TAG_ARRAY_BUFFER);
104
- var isDataView = defineTagGuard(OBJECT_TAG_DATA_VIEW);
141
+ var isArrayBuffer = defineIntrinsicBrandGuard(
142
+ (value) => arrayBufferByteLength.call(value)
143
+ );
144
+ var isDataView = defineIntrinsicBrandGuard(
145
+ (value) => dataViewBuffer.call(value)
146
+ );
105
147
  var isTypedArray = define(
106
- (value) => ArrayBuffer.isView(value) && getTag(value) !== OBJECT_TAG_DATA_VIEW
148
+ (value) => ArrayBuffer.isView(value) && !isDataView(value)
107
149
  );
108
150
  var isError = define(
109
151
  (value) => value instanceof Error || getTag(value) === OBJECT_TAG_ERROR
@@ -302,7 +344,7 @@ function nonEmptyArrayOf(elementGuard) {
302
344
  // src/core/combinators/map.ts
303
345
  function mapOf(keyGuard, valueGuard) {
304
346
  return define(
305
- (input) => isMap(input) && everyMapEntry(input, keyGuard, valueGuard)
347
+ (input) => isMap(input) && everyBrandedMapEntry(input, keyGuard, valueGuard)
306
348
  );
307
349
  }
308
350
 
@@ -356,7 +398,7 @@ function recordOf(keyFunction, valueFunction) {
356
398
  // src/core/combinators/set.ts
357
399
  function setOf(valueGuard) {
358
400
  return define(
359
- (input) => isSet(input) && everySetValue(input, valueGuard)
401
+ (input) => isSet(input) && everyBrandedSetValue(input, valueGuard)
360
402
  );
361
403
  }
362
404
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-kit",
3
- "version": "1.11.4",
3
+ "version": "1.11.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",