is-kit 1.14.0 → 1.14.1

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/index.d.mts CHANGED
@@ -566,9 +566,8 @@ declare const isNull: Predicate<null>;
566
566
  * isNil(null); // true
567
567
  * isNil(undefined); // true
568
568
  * isNil(0); // false
569
- * @see or
570
569
  */
571
- declare const isNil: Guard<null | undefined>;
570
+ declare const isNil: (value: unknown) => value is null | undefined;
572
571
  /**
573
572
  * Checks whether a value is neither `null` nor `undefined`.
574
573
  *
package/dist/index.d.ts CHANGED
@@ -566,9 +566,8 @@ declare const isNull: Predicate<null>;
566
566
  * isNil(null); // true
567
567
  * isNil(undefined); // true
568
568
  * isNil(0); // false
569
- * @see or
570
569
  */
571
- declare const isNil: Guard<null | undefined>;
570
+ declare const isNil: (value: unknown) => value is null | undefined;
572
571
  /**
573
572
  * Checks whether a value is neither `null` nor `undefined`.
574
573
  *
package/dist/index.js CHANGED
@@ -154,6 +154,10 @@ var arrayBufferByteLength = getIntrinsicGetter(
154
154
  "byteLength"
155
155
  );
156
156
  var dataViewBuffer = getIntrinsicGetter(DataView.prototype, "buffer");
157
+ var typedArrayName = Object.getOwnPropertyDescriptor(
158
+ Object.getPrototypeOf(Uint8Array.prototype),
159
+ Symbol.toStringTag
160
+ )?.get;
157
161
  var defineOptionalInstanceGuard = (constructor) => constructor === void 0 ? define(() => false) : define(
158
162
  (value) => typeof constructor === "function" && value instanceof constructor
159
163
  );
@@ -211,7 +215,7 @@ var isDataView = defineIntrinsicBrandGuard(
211
215
  (value) => dataViewBuffer.call(value)
212
216
  );
213
217
  var isTypedArray = define(
214
- (value) => ArrayBuffer.isView(value) && !isDataView(value)
218
+ (value) => typedArrayName?.call(value) !== void 0
215
219
  );
216
220
  var isError = define(
217
221
  (value) => value instanceof Error || getTag(value) === OBJECT_TAG_ERROR
@@ -321,22 +325,20 @@ function not(fn) {
321
325
  }
322
326
 
323
327
  // src/core/nullish.ts
324
- var allowWhen = (acceptedValue, predicate) => (value) => acceptedValue(value) || predicate(value);
325
- var requireWhen = (rejectedValue, predicate) => (value) => !rejectedValue(value) && predicate(value);
326
328
  function nullable(fn) {
327
- return allowWhen((value) => value === null, fn);
329
+ return (value) => value === null || fn(value);
328
330
  }
329
331
  function nonNull(fn) {
330
- return requireWhen((value) => value === null, fn);
332
+ return (value) => value !== null && fn(value);
331
333
  }
332
334
  function nullish(fn) {
333
- return allowWhen((value) => value == null, fn);
335
+ return (value) => value === null || value === void 0 || fn(value);
334
336
  }
335
337
  function optional(fn) {
336
- return allowWhen((value) => value === void 0, fn);
338
+ return (value) => value === void 0 || fn(value);
337
339
  }
338
340
  function required(fn) {
339
- return requireWhen((value) => value === void 0, fn);
341
+ return (value) => value !== void 0 && fn(value);
340
342
  }
341
343
 
342
344
  // src/core/parse.ts
@@ -391,8 +393,8 @@ var isBigInt = define((value) => typeof value === "bigint");
391
393
  var isSymbol = define((value) => typeof value === "symbol");
392
394
  var isUndefined = define((value) => value === void 0);
393
395
  var isNull = define((value) => value === null);
394
- var isNil = or(isNull, isUndefined);
395
- var isNotNil = (value) => !isNil(value);
396
+ var isNil = (value) => value === null || value === void 0;
397
+ var isNotNil = (value) => value !== null && value !== void 0;
396
398
  var isPrimitive = or(
397
399
  isString,
398
400
  isNumberPrimitive,
package/dist/index.mjs CHANGED
@@ -46,6 +46,10 @@ var arrayBufferByteLength = getIntrinsicGetter(
46
46
  "byteLength"
47
47
  );
48
48
  var dataViewBuffer = getIntrinsicGetter(DataView.prototype, "buffer");
49
+ var typedArrayName = Object.getOwnPropertyDescriptor(
50
+ Object.getPrototypeOf(Uint8Array.prototype),
51
+ Symbol.toStringTag
52
+ )?.get;
49
53
  var defineOptionalInstanceGuard = (constructor) => constructor === void 0 ? define(() => false) : define(
50
54
  (value) => typeof constructor === "function" && value instanceof constructor
51
55
  );
@@ -103,7 +107,7 @@ var isDataView = defineIntrinsicBrandGuard(
103
107
  (value) => dataViewBuffer.call(value)
104
108
  );
105
109
  var isTypedArray = define(
106
- (value) => ArrayBuffer.isView(value) && !isDataView(value)
110
+ (value) => typedArrayName?.call(value) !== void 0
107
111
  );
108
112
  var isError = define(
109
113
  (value) => value instanceof Error || getTag(value) === OBJECT_TAG_ERROR
@@ -213,22 +217,20 @@ function not(fn) {
213
217
  }
214
218
 
215
219
  // src/core/nullish.ts
216
- var allowWhen = (acceptedValue, predicate) => (value) => acceptedValue(value) || predicate(value);
217
- var requireWhen = (rejectedValue, predicate) => (value) => !rejectedValue(value) && predicate(value);
218
220
  function nullable(fn) {
219
- return allowWhen((value) => value === null, fn);
221
+ return (value) => value === null || fn(value);
220
222
  }
221
223
  function nonNull(fn) {
222
- return requireWhen((value) => value === null, fn);
224
+ return (value) => value !== null && fn(value);
223
225
  }
224
226
  function nullish(fn) {
225
- return allowWhen((value) => value == null, fn);
227
+ return (value) => value === null || value === void 0 || fn(value);
226
228
  }
227
229
  function optional(fn) {
228
- return allowWhen((value) => value === void 0, fn);
230
+ return (value) => value === void 0 || fn(value);
229
231
  }
230
232
  function required(fn) {
231
- return requireWhen((value) => value === void 0, fn);
233
+ return (value) => value !== void 0 && fn(value);
232
234
  }
233
235
 
234
236
  // src/core/parse.ts
@@ -283,8 +285,8 @@ var isBigInt = define((value) => typeof value === "bigint");
283
285
  var isSymbol = define((value) => typeof value === "symbol");
284
286
  var isUndefined = define((value) => value === void 0);
285
287
  var isNull = define((value) => value === null);
286
- var isNil = or(isNull, isUndefined);
287
- var isNotNil = (value) => !isNil(value);
288
+ var isNil = (value) => value === null || value === void 0;
289
+ var isNotNil = (value) => value !== null && value !== void 0;
288
290
  var isPrimitive = or(
289
291
  isString,
290
292
  isNumberPrimitive,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "is-kit",
3
- "version": "1.14.0",
3
+ "version": "1.14.1",
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",