Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

isntnt

Package Overview
Dependencies
Maintainers
7
Versions
33
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

isntnt - npm Package Compare versions

Comparing version 2.0.0-beta.2 to 2.0.0-beta.3

dist/esm/lib/generics/map.d.ts

2

dist/esm/lib/generics.d.ts

@@ -10,2 +10,3 @@ export { above } from './generics/above';

export { literal } from './generics/literal';
export { map } from './generics/map';
export { max } from './generics/max';

@@ -20,4 +21,5 @@ export { maybe } from './generics/maybe';

export { record } from './generics/record';
export { set } from './generics/set';
export { shape } from './generics/shape';
export { test } from './generics/test';
export { tuple } from './generics/tuple';

@@ -10,2 +10,3 @@ export { above } from './generics/above';

export { literal } from './generics/literal';
export { map } from './generics/map';
export { max } from './generics/max';

@@ -20,2 +21,3 @@ export { maybe } from './generics/maybe';

export { record } from './generics/record';
export { set } from './generics/set';
export { shape } from './generics/shape';

@@ -22,0 +24,0 @@ export { test } from './generics/test';

2

dist/esm/lib/generics/above.js
import { isNumber } from '../predicates';
export const above = (floor) => ((value) => isNumber(value) && value > floor);
export const above = (floor) => (value) => isNumber(value) && value > floor;
//# sourceMappingURL=above.js.map
import { isArray } from '../predicates/isArray';
export const array = (predicate) => ((value) => isArray(value) && value.every(predicate));
export const array = (predicate) => (value) => isArray(value) && value.every((element) => predicate(element));
//# sourceMappingURL=array.js.map
import { isNumber } from '../predicates';
export const below = (ceiling) => ((value) => isNumber(value) && value < ceiling);
export const below = (ceiling) => (value) => isNumber(value) && value < ceiling;
//# sourceMappingURL=below.js.map

@@ -1,2 +0,2 @@

export const literal = (input) => ((value) => input === value);
export const literal = (input) => (value) => input === value;
//# sourceMappingURL=literal.js.map
import { isNumber } from '../predicates';
export const max = (ceiling) => ((value) => isNumber(value) && value <= ceiling);
export const max = (ceiling) => (value) => isNumber(value) && value <= ceiling;
//# sourceMappingURL=max.js.map
import { isNumber } from '../predicates';
export const min = (floor) => ((value) => isNumber(value) && value >= floor);
export const min = (floor) => (value) => isNumber(value) && value >= floor;
//# sourceMappingURL=min.js.map

@@ -0,1 +1,2 @@

/** @deprecated */
export declare const noneable: <T>(predicate: import("../types").Predicate<T>) => import("../types").Predicate<import("../types").None | T>;
import { maybe } from './maybe';
/** @deprecated */
export const noneable = maybe;
//# sourceMappingURL=noneable.js.map
import { Predicate } from '../types';
export declare const object: <T>(predicate: Predicate<T>) => Predicate<Record<any, T>>;
export declare const object: <T>(predicate: Predicate<T>) => Predicate<Record<PropertyKey, T>>;

@@ -6,6 +6,4 @@ import { isObject } from '../predicates/isObject';

for (const key in value) {
if (Object.hasOwnProperty.call(value, key)) {
if (!predicate(value[key])) {
return false;
}
if (Object.hasOwnProperty.call(value, key) && !predicate(value[key])) {
return false;
}

@@ -12,0 +10,0 @@ }

import { isObject } from '../predicates';
export const record = (keyPredicate, valuePredicate) => ((value) => {
export const record = (keyPredicate, valuePredicate) => (value) => {
const isObjectValue = isObject(value);

@@ -13,3 +13,3 @@ if (isObjectValue) {

return isObjectValue;
});
};
//# sourceMappingURL=record.js.map
import { isString } from '../predicates/isString';
export const test = (expression) => {
const clonedExpression = new RegExp(expression.source, expression.flags);
return ((value) => isString(value) &&
!(clonedExpression.lastIndex = 0) &&
clonedExpression.test(value));
return (value) => isString(value) && !(clonedExpression.lastIndex = 0) && clonedExpression.test(value);
};
//# sourceMappingURL=test.js.map
import { Predicate } from '../types';
declare type BaseTuple = ReadonlyArray<any>;
declare type BaseTuple = ReadonlyArray<unknown>;
declare type TuplePredicates<T extends BaseTuple> = {

@@ -4,0 +4,0 @@ [K in keyof T]: Predicate<T[K]>;

@@ -9,2 +9,9 @@ export { hasLength } from './predicates/hasLength';

export { isDictionary } from './predicates/isDictionary';
export { isEmpty } from './predicates/isEmpty';
export { isEmptyArray } from './predicates/isEmptyArray';
export { isEmptyMap } from './predicates/isEmptyMap';
export { isEmptyObject } from './predicates/isEmptyObject';
export { isEmptyPrimitive } from './predicates/isEmptyPrimitive';
export { isEmptySet } from './predicates/isEmptySet';
export { isEmptyString } from './predicates/isEmptyString';
export { isFalse } from './predicates/isFalse';

@@ -11,0 +18,0 @@ export { isFunction } from './predicates/isFunction';

@@ -9,2 +9,9 @@ export { hasLength } from './predicates/hasLength';

export { isDictionary } from './predicates/isDictionary';
export { isEmpty } from './predicates/isEmpty';
export { isEmptyArray } from './predicates/isEmptyArray';
export { isEmptyMap } from './predicates/isEmptyMap';
export { isEmptyObject } from './predicates/isEmptyObject';
export { isEmptyPrimitive } from './predicates/isEmptyPrimitive';
export { isEmptySet } from './predicates/isEmptySet';
export { isEmptyString } from './predicates/isEmptyString';
export { isFalse } from './predicates/isFalse';

@@ -11,0 +18,0 @@ export { isFunction } from './predicates/isFunction';

@@ -1,2 +0,2 @@

export const isBoolean = ((value) => typeof value === 'boolean');
export const isBoolean = (value) => typeof value === 'boolean';
//# sourceMappingURL=isBoolean.js.map

@@ -1,1 +0,2 @@

export declare const isDate: import("../types").Predicate<Date>;
import { Predicate } from '../types';
export declare const isDate: Predicate<Date>;

@@ -1,2 +0,2 @@

export declare type Dictionary = Record<any, string>;
export declare const isDictionary: <T>(value: T) => value is Extract<T, Dictionary>;
import { Dictionary, Predicate } from '../types';
export declare const isDictionary: Predicate<Dictionary>;

@@ -1,1 +0,2 @@

export declare const isFalse: import("../types").Predicate<false>;
import { Predicate } from '../types';
export declare const isFalse: Predicate<false>;

@@ -1,2 +0,2 @@

export const isFunction = ((value) => typeof value === 'function');
export const isFunction = (value) => typeof value === 'function';
//# sourceMappingURL=isFunction.js.map

@@ -1,2 +0,2 @@

export const isInt = ((value) => typeof value === 'number' && value === Math.floor(value));
export const isInt = (value) => typeof value === 'number' && value === Math.floor(value);
//# sourceMappingURL=isInt.js.map
import { isInt } from './isInt';
const boundary = Math.pow(2, 16) / 2;
export const isInt16 = ((value) => isInt(value) && value >= -boundary && value < boundary);
const INT_16_BOUNDARY = Math.pow(2, 16) / 2;
export const isInt16 = (value) => isInt(value) && value >= -INT_16_BOUNDARY && value < INT_16_BOUNDARY;
//# sourceMappingURL=isInt16.js.map
import { isInt } from './isInt';
const boundary = Math.pow(2, 32) / 2;
export const isInt32 = ((value) => isInt(value) && value >= -boundary && value < boundary);
const INT_32_BOUNDARY = Math.pow(2, 32) / 2;
export const isInt32 = (value) => isInt(value) && value >= -INT_32_BOUNDARY && value < INT_32_BOUNDARY;
//# sourceMappingURL=isInt32.js.map
import { isInt } from './isInt';
const boundary = Math.pow(2, 8) / 2;
export const isInt8 = ((value) => isInt(value) && value >= -boundary && value < boundary);
const INT_8_BOUNDARY = Math.pow(2, 8) / 2;
export const isInt8 = (value) => isInt(value) && value >= -INT_8_BOUNDARY && value < INT_8_BOUNDARY;
//# sourceMappingURL=isInt8.js.map

@@ -1,1 +0,2 @@

export declare const isMap: import("../types").Predicate<Map<unknown, unknown>>;
import { Predicate } from '../types';
export declare const isMap: Predicate<Map<unknown, unknown>>;

@@ -1,2 +0,2 @@

export const isNegative = ((value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) < 0);
export const isNegative = (value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) < 0;
//# sourceMappingURL=isNegative.js.map

@@ -1,2 +0,2 @@

import { None } from '../types';
export declare const isNone: <T>(value: T) => value is Extract<T, None>;
import { None, Predicate } from '../types';
export declare const isNone: Predicate<None>;

@@ -1,1 +0,2 @@

export declare const isNull: import("../types").Predicate<null>;
import { Predicate } from '../types';
export declare const isNull: Predicate<null>;

@@ -1,2 +0,2 @@

export const isNumber = ((value) => typeof value === 'number' && value === value);
export const isNumber = (value) => typeof value === 'number' && value === value;
//# sourceMappingURL=isNumber.js.map

@@ -1,2 +0,2 @@

import { None } from '../types';
export declare const isObjectLike: <T>(value: T) => value is Exclude<T, boolean | None>;
import { None, PredicateType } from '../types';
export declare const isObjectLike: <T>(value: T) => value is PredicateType<Exclude<T, boolean | None>, T>;
import { and } from '../generics/and';
import { at } from '../generics/at';
import { isNone } from './isNone';
import { isObject } from './isObject';
const hasObjectConstructor = at('constructor', (value) => value === Object);
export const isPlainObject = and(isObject, (value) => hasObjectConstructor(Object.getPrototypeOf(value)) && String(value) === '[object Object]');
export const isPlainObject = and(isObject, (value) => {
const prototype = Object.getPrototypeOf(value);
return (isNone(prototype) || (prototype.constructor === Object && String(value) === '[object Object]'));
});
//# sourceMappingURL=isPlainObject.js.map

@@ -1,2 +0,2 @@

export const isPositive = ((value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) > 0);
export const isPositive = (value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) > 0;
//# sourceMappingURL=isPositive.js.map

@@ -1,4 +0,3 @@

import { isNone } from './isNone';
import { isFunction } from './isFunction';
export const isPrimitive = ((value) => isNone(value) || (typeof value !== 'object' && !isFunction(value)));
export const isPrimitive = (value) => value == null || (typeof value !== 'object' && !isFunction(value));
//# sourceMappingURL=isPrimitive.js.map

@@ -1,1 +0,2 @@

export declare const isRegExp: import("../types").Predicate<RegExp>;
import { Predicate } from '../types';
export declare const isRegExp: Predicate<RegExp>;

@@ -1,2 +0,2 @@

import { Serializable } from '../types';
export declare const isSerializable: <U>(value: U) => value is Extract<U, Serializable>;
import { Predicate, Serializable } from '../types';
export declare const isSerializable: Predicate<Serializable>;

@@ -1,6 +0,5 @@

import { or } from '../generics/or';
import { isSerializableArray } from './isSerializableArray';
import { isSerializableObject } from './isSerializableObject';
import { isSerializablePrimitive } from './isSerializablePrimitive';
export const isSerializable = or(isSerializableArray, isSerializableObject, isSerializablePrimitive);
export const isSerializable = (value) => isSerializableArray(value) || isSerializableObject(value) || isSerializablePrimitive(value);
//# sourceMappingURL=isSerializable.js.map
import { isArray } from './isArray';
import { isSerializable } from './isSerializable';
export const isSerializableArray = ((value) => isArray(value) && value.every(isSerializable));
export const isSerializableArray = (value) => isArray(value) && value.every((element) => isSerializable(element));
//# sourceMappingURL=isSerializableArray.js.map
import { isNumber } from './isNumber';
export const isSerializableNumber = ((value) => isNumber(value) && Math.abs(value) !== Infinity);
export const isSerializableNumber = (value) => isNumber(value) && Math.abs(value) !== Infinity;
//# sourceMappingURL=isSerializableNumber.js.map
import { isSerializable } from './isSerializable';
import { isPlainObject } from './isPlainObject';
export const isSerializableObject = (value) => {
const isObjectValue = isPlainObject(value);
if (isObjectValue) {
const valueIsPlainObject = isPlainObject(value);
if (valueIsPlainObject) {
for (const key in value) {
if (Object.hasOwnProperty.call(value, key)) {
if (!isSerializable(value[key])) {
return false;
}
if (Object.hasOwnProperty.call(value, key) && !isSerializable(value[key])) {
return false;
}
}
}
return isObjectValue;
return valueIsPlainObject;
};
//# sourceMappingURL=isSerializableObject.js.map

@@ -1,1 +0,2 @@

export declare const isSet: import("../types").Predicate<Set<unknown>>;
import { Predicate } from '../types';
export declare const isSet: Predicate<Set<unknown>>;

@@ -1,1 +0,2 @@

export declare const isSome: <T>(value: T) => value is Exclude<T, import("../types").None>;
import { Predicate, Some } from '../types';
export declare const isSome: Predicate<Some>;

@@ -1,2 +0,2 @@

export const isString = ((value) => typeof value === 'string');
export const isString = (value) => typeof value === 'string';
//# sourceMappingURL=isString.js.map

@@ -1,1 +0,2 @@

export declare const isSymbol: <T>(value: T) => value is Extract<T, symbol>;
import { Predicate } from '../types';
export declare const isSymbol: Predicate<symbol>;

@@ -1,1 +0,2 @@

export declare const isTrue: import("../types").Predicate<true>;
import { Predicate } from '../types';
export declare const isTrue: Predicate<true>;
import { isInt } from './isInt';
import { isPositive } from './isPositive';
export const isUint = ((value) => isInt(value) && isPositive(value) && value !== Infinity);
export const isUint = (value) => isInt(value) && isPositive(value) && value !== Infinity;
//# sourceMappingURL=isUint.js.map
import { isInt } from './isInt';
import { isPositive } from './isPositive';
const ceiling = Math.pow(2, 16);
export const isUint16 = ((value) => isInt(value) && isPositive(value) && value < ceiling);
const UINT_16_CEILING = Math.pow(2, 16);
export const isUint16 = (value) => isInt(value) && isPositive(value) && value < UINT_16_CEILING;
//# sourceMappingURL=isUint16.js.map
import { isInt } from './isInt';
import { isPositive } from './isPositive';
const ceiling = Math.pow(2, 32);
export const isUint32 = ((value) => isInt(value) && isPositive(value) && value < ceiling);
const UINT_32_CEILING = Math.pow(2, 32);
export const isUint32 = (value) => isInt(value) && isPositive(value) && value < UINT_32_CEILING;
//# sourceMappingURL=isUint32.js.map
import { isInt } from './isInt';
import { isPositive } from './isPositive';
const ceiling = Math.pow(2, 8);
export const isUint8 = ((value) => isInt(value) && isPositive(value) && value < ceiling);
const UINT_8_CEILING = Math.pow(2, 8);
export const isUint8 = (value) => isInt(value) && isPositive(value) && value < UINT_8_CEILING;
//# sourceMappingURL=isUint8.js.map

@@ -1,1 +0,2 @@

export declare const isUndefined: import("../types").Predicate<undefined>;
import { Predicate } from '../types';
export declare const isUndefined: Predicate<undefined>;

@@ -1,1 +0,2 @@

export declare const isWeakMap: import("../types").Predicate<WeakMap<object, unknown>>;
import { Predicate } from '../types';
export declare const isWeakMap: Predicate<WeakMap<any, unknown>>;

@@ -1,5 +0,4 @@

import { at } from '../generics/at';
import { isLength } from './isLength';
import { hasLength } from './hasLength';
/** @deprecated */
export const isWithLength = at('length', isLength);
export const isWithLength = hasLength;
//# sourceMappingURL=isWithLength.js.map

@@ -1,6 +0,7 @@

export declare type Predicate<T> = <U>(value: U) => value is Extract<U, T>;
export declare type PredicateType<T, U> = (Exclude<any, U> extends never ? 1 : 0) extends 1 ? Extract<T, U> : U extends T ? U : T extends U ? T : never;
export declare type Predicate<T> = <U>(value: U) => value is PredicateType<T, U>;
export declare type Static<T extends Predicate<any>> = T extends Predicate<infer R> ? R : never;
export declare type Constructor<T extends object, U extends ReadonlyArray<any> = []> = {
export interface Constructor<T extends object = any, U extends ReadonlyArray<any> = []> {
new (...rest: U): T;
};
}
export declare type Intersect<T> = (T extends any ? (k: T) => void : never) extends (k: infer I) => void ? I : never;

@@ -13,2 +14,3 @@ export declare type Unknown = Some | None;

export declare type Nullable<T> = T | null;
export declare type Dictionary = Record<string, string>;
export declare type PlainObject = Record<string | symbol, unknown>;

@@ -26,1 +28,8 @@ export declare type ArrayLike = {

export declare type Serializable = SerializablePrimitive | SerializableObject | SerializableArray;
export declare type EmptyMap = Map<any, never>;
export declare type EmptySet = Set<never>;
export declare type EmptyArray = Array<never> | ReadonlyArray<never>;
export declare type EmptyObject = Record<any, never>;
export declare type EmptyPrimitive = EmptyString | None;
export declare type EmptyString = '';
export declare type Empty = EmptyPrimitive | EmptyArray | EmptyObject | EmptyMap | EmptySet;

@@ -10,2 +10,3 @@ export { above } from './generics/above';

export { literal } from './generics/literal';
export { map } from './generics/map';
export { max } from './generics/max';

@@ -20,4 +21,5 @@ export { maybe } from './generics/maybe';

export { record } from './generics/record';
export { set } from './generics/set';
export { shape } from './generics/shape';
export { test } from './generics/test';
export { tuple } from './generics/tuple';
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.tuple = exports.test = exports.shape = exports.record = exports.or = exports.optional = exports.object = exports.nullable = exports.noneable = exports.min = exports.maybe = exports.max = exports.literal = exports.instance = exports.has = exports.either = exports.below = exports.at = exports.array = exports.and = exports.above = void 0;
exports.tuple = exports.test = exports.shape = exports.set = exports.record = exports.or = exports.optional = exports.object = exports.nullable = exports.noneable = exports.min = exports.maybe = exports.max = exports.map = exports.literal = exports.instance = exports.has = exports.either = exports.below = exports.at = exports.array = exports.and = exports.above = void 0;
var above_1 = require("./generics/above");

@@ -22,2 +22,4 @@ Object.defineProperty(exports, "above", { enumerable: true, get: function () { return above_1.above; } });

Object.defineProperty(exports, "literal", { enumerable: true, get: function () { return literal_1.literal; } });
var map_1 = require("./generics/map");
Object.defineProperty(exports, "map", { enumerable: true, get: function () { return map_1.map; } });
var max_1 = require("./generics/max");

@@ -41,2 +43,4 @@ Object.defineProperty(exports, "max", { enumerable: true, get: function () { return max_1.max; } });

Object.defineProperty(exports, "record", { enumerable: true, get: function () { return record_1.record; } });
var set_1 = require("./generics/set");
Object.defineProperty(exports, "set", { enumerable: true, get: function () { return set_1.set; } });
var shape_1 = require("./generics/shape");

@@ -43,0 +47,0 @@ Object.defineProperty(exports, "shape", { enumerable: true, get: function () { return shape_1.shape; } });

@@ -5,4 +5,4 @@ "use strict";

const predicates_1 = require("../predicates");
const above = (floor) => ((value) => predicates_1.isNumber(value) && value > floor);
const above = (floor) => (value) => predicates_1.isNumber(value) && value > floor;
exports.above = above;
//# sourceMappingURL=above.js.map

@@ -5,4 +5,4 @@ "use strict";

const isArray_1 = require("../predicates/isArray");
const array = (predicate) => ((value) => isArray_1.isArray(value) && value.every(predicate));
const array = (predicate) => (value) => isArray_1.isArray(value) && value.every((element) => predicate(element));
exports.array = array;
//# sourceMappingURL=array.js.map

@@ -5,4 +5,4 @@ "use strict";

const predicates_1 = require("../predicates");
const below = (ceiling) => ((value) => predicates_1.isNumber(value) && value < ceiling);
const below = (ceiling) => (value) => predicates_1.isNumber(value) && value < ceiling;
exports.below = below;
//# sourceMappingURL=below.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.literal = void 0;
const literal = (input) => ((value) => input === value);
const literal = (input) => (value) => input === value;
exports.literal = literal;
//# sourceMappingURL=literal.js.map

@@ -5,4 +5,4 @@ "use strict";

const predicates_1 = require("../predicates");
const max = (ceiling) => ((value) => predicates_1.isNumber(value) && value <= ceiling);
const max = (ceiling) => (value) => predicates_1.isNumber(value) && value <= ceiling;
exports.max = max;
//# sourceMappingURL=max.js.map

@@ -5,4 +5,4 @@ "use strict";

const predicates_1 = require("../predicates");
const min = (floor) => ((value) => predicates_1.isNumber(value) && value >= floor);
const min = (floor) => (value) => predicates_1.isNumber(value) && value >= floor;
exports.min = min;
//# sourceMappingURL=min.js.map

@@ -0,1 +1,2 @@

/** @deprecated */
export declare const noneable: <T>(predicate: import("../types").Predicate<T>) => import("../types").Predicate<import("../types").None | T>;

@@ -5,3 +5,4 @@ "use strict";

const maybe_1 = require("./maybe");
/** @deprecated */
exports.noneable = maybe_1.maybe;
//# sourceMappingURL=noneable.js.map
import { Predicate } from '../types';
export declare const object: <T>(predicate: Predicate<T>) => Predicate<Record<any, T>>;
export declare const object: <T>(predicate: Predicate<T>) => Predicate<Record<PropertyKey, T>>;

@@ -9,6 +9,4 @@ "use strict";

for (const key in value) {
if (Object.hasOwnProperty.call(value, key)) {
if (!predicate(value[key])) {
return false;
}
if (Object.hasOwnProperty.call(value, key) && !predicate(value[key])) {
return false;
}

@@ -15,0 +13,0 @@ }

@@ -5,3 +5,3 @@ "use strict";

const predicates_1 = require("../predicates");
const record = (keyPredicate, valuePredicate) => ((value) => {
const record = (keyPredicate, valuePredicate) => (value) => {
const isObjectValue = predicates_1.isObject(value);

@@ -17,4 +17,4 @@ if (isObjectValue) {

return isObjectValue;
});
};
exports.record = record;
//# sourceMappingURL=record.js.map

@@ -7,7 +7,5 @@ "use strict";

const clonedExpression = new RegExp(expression.source, expression.flags);
return ((value) => isString_1.isString(value) &&
!(clonedExpression.lastIndex = 0) &&
clonedExpression.test(value));
return (value) => isString_1.isString(value) && !(clonedExpression.lastIndex = 0) && clonedExpression.test(value);
};
exports.test = test;
//# sourceMappingURL=test.js.map
import { Predicate } from '../types';
declare type BaseTuple = ReadonlyArray<any>;
declare type BaseTuple = ReadonlyArray<unknown>;
declare type TuplePredicates<T extends BaseTuple> = {

@@ -4,0 +4,0 @@ [K in keyof T]: Predicate<T[K]>;

@@ -9,2 +9,9 @@ export { hasLength } from './predicates/hasLength';

export { isDictionary } from './predicates/isDictionary';
export { isEmpty } from './predicates/isEmpty';
export { isEmptyArray } from './predicates/isEmptyArray';
export { isEmptyMap } from './predicates/isEmptyMap';
export { isEmptyObject } from './predicates/isEmptyObject';
export { isEmptyPrimitive } from './predicates/isEmptyPrimitive';
export { isEmptySet } from './predicates/isEmptySet';
export { isEmptyString } from './predicates/isEmptyString';
export { isFalse } from './predicates/isFalse';

@@ -11,0 +18,0 @@ export { isFunction } from './predicates/isFunction';

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWithLength = exports.isWeakMap = exports.isUndefined = exports.isUint32 = exports.isUint16 = exports.isUint8 = exports.isUint = exports.isTrue = exports.isSymbol = exports.isString = exports.isSome = exports.isSet = exports.isSerializablePrimitive = exports.isSerializableObject = exports.isSerializableNumber = exports.isSerializableArray = exports.isSerializable = exports.isRegExp = exports.isPrimitive = exports.isPositive = exports.isPlainObject = exports.isObjectLike = exports.isObject = exports.isNumber = exports.isNull = exports.isNone = exports.isNever = exports.isNegative = exports.isMap = exports.isLength = exports.isInt32 = exports.isInt16 = exports.isInt8 = exports.isInt = exports.isFunction = exports.isFalse = exports.isDictionary = exports.isDate = exports.isBoolean = exports.isBigInt = exports.isArrayLike = exports.isArray = exports.isAny = exports.hasLength = void 0;
exports.isWeakMap = exports.isUndefined = exports.isUint32 = exports.isUint16 = exports.isUint8 = exports.isUint = exports.isTrue = exports.isSymbol = exports.isString = exports.isSome = exports.isSet = exports.isSerializablePrimitive = exports.isSerializableObject = exports.isSerializableNumber = exports.isSerializableArray = exports.isSerializable = exports.isRegExp = exports.isPrimitive = exports.isPositive = exports.isPlainObject = exports.isObjectLike = exports.isObject = exports.isNumber = exports.isNull = exports.isNone = exports.isNever = exports.isNegative = exports.isMap = exports.isLength = exports.isInt32 = exports.isInt16 = exports.isInt8 = exports.isInt = exports.isFunction = exports.isFalse = exports.isEmptyString = exports.isEmptySet = exports.isEmptyPrimitive = exports.isEmptyObject = exports.isEmptyMap = exports.isEmptyArray = exports.isEmpty = exports.isDictionary = exports.isDate = exports.isBoolean = exports.isBigInt = exports.isArrayLike = exports.isArray = exports.isAny = exports.hasLength = void 0;
exports.isWithLength = void 0;
var hasLength_1 = require("./predicates/hasLength");

@@ -20,2 +21,16 @@ Object.defineProperty(exports, "hasLength", { enumerable: true, get: function () { return hasLength_1.hasLength; } });

Object.defineProperty(exports, "isDictionary", { enumerable: true, get: function () { return isDictionary_1.isDictionary; } });
var isEmpty_1 = require("./predicates/isEmpty");
Object.defineProperty(exports, "isEmpty", { enumerable: true, get: function () { return isEmpty_1.isEmpty; } });
var isEmptyArray_1 = require("./predicates/isEmptyArray");
Object.defineProperty(exports, "isEmptyArray", { enumerable: true, get: function () { return isEmptyArray_1.isEmptyArray; } });
var isEmptyMap_1 = require("./predicates/isEmptyMap");
Object.defineProperty(exports, "isEmptyMap", { enumerable: true, get: function () { return isEmptyMap_1.isEmptyMap; } });
var isEmptyObject_1 = require("./predicates/isEmptyObject");
Object.defineProperty(exports, "isEmptyObject", { enumerable: true, get: function () { return isEmptyObject_1.isEmptyObject; } });
var isEmptyPrimitive_1 = require("./predicates/isEmptyPrimitive");
Object.defineProperty(exports, "isEmptyPrimitive", { enumerable: true, get: function () { return isEmptyPrimitive_1.isEmptyPrimitive; } });
var isEmptySet_1 = require("./predicates/isEmptySet");
Object.defineProperty(exports, "isEmptySet", { enumerable: true, get: function () { return isEmptySet_1.isEmptySet; } });
var isEmptyString_1 = require("./predicates/isEmptyString");
Object.defineProperty(exports, "isEmptyString", { enumerable: true, get: function () { return isEmptyString_1.isEmptyString; } });
var isFalse_1 = require("./predicates/isFalse");

@@ -22,0 +37,0 @@ Object.defineProperty(exports, "isFalse", { enumerable: true, get: function () { return isFalse_1.isFalse; } });

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isBoolean = void 0;
exports.isBoolean = ((value) => typeof value === 'boolean');
const isBoolean = (value) => typeof value === 'boolean';
exports.isBoolean = isBoolean;
//# sourceMappingURL=isBoolean.js.map

@@ -1,1 +0,2 @@

export declare const isDate: import("../types").Predicate<Date>;
import { Predicate } from '../types';
export declare const isDate: Predicate<Date>;

@@ -1,2 +0,2 @@

export declare type Dictionary = Record<any, string>;
export declare const isDictionary: <T>(value: T) => value is Extract<T, Dictionary>;
import { Dictionary, Predicate } from '../types';
export declare const isDictionary: Predicate<Dictionary>;

@@ -1,1 +0,2 @@

export declare const isFalse: import("../types").Predicate<false>;
import { Predicate } from '../types';
export declare const isFalse: Predicate<false>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isFunction = void 0;
exports.isFunction = ((value) => typeof value === 'function');
const isFunction = (value) => typeof value === 'function';
exports.isFunction = isFunction;
//# sourceMappingURL=isFunction.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isInt = void 0;
exports.isInt = ((value) => typeof value === 'number' && value === Math.floor(value));
const isInt = (value) => typeof value === 'number' && value === Math.floor(value);
exports.isInt = isInt;
//# sourceMappingURL=isInt.js.map

@@ -5,4 +5,5 @@ "use strict";

const isInt_1 = require("./isInt");
const boundary = Math.pow(2, 16) / 2;
exports.isInt16 = ((value) => isInt_1.isInt(value) && value >= -boundary && value < boundary);
const INT_16_BOUNDARY = Math.pow(2, 16) / 2;
const isInt16 = (value) => isInt_1.isInt(value) && value >= -INT_16_BOUNDARY && value < INT_16_BOUNDARY;
exports.isInt16 = isInt16;
//# sourceMappingURL=isInt16.js.map

@@ -5,4 +5,5 @@ "use strict";

const isInt_1 = require("./isInt");
const boundary = Math.pow(2, 32) / 2;
exports.isInt32 = ((value) => isInt_1.isInt(value) && value >= -boundary && value < boundary);
const INT_32_BOUNDARY = Math.pow(2, 32) / 2;
const isInt32 = (value) => isInt_1.isInt(value) && value >= -INT_32_BOUNDARY && value < INT_32_BOUNDARY;
exports.isInt32 = isInt32;
//# sourceMappingURL=isInt32.js.map

@@ -5,4 +5,5 @@ "use strict";

const isInt_1 = require("./isInt");
const boundary = Math.pow(2, 8) / 2;
exports.isInt8 = ((value) => isInt_1.isInt(value) && value >= -boundary && value < boundary);
const INT_8_BOUNDARY = Math.pow(2, 8) / 2;
const isInt8 = (value) => isInt_1.isInt(value) && value >= -INT_8_BOUNDARY && value < INT_8_BOUNDARY;
exports.isInt8 = isInt8;
//# sourceMappingURL=isInt8.js.map

@@ -1,1 +0,2 @@

export declare const isMap: import("../types").Predicate<Map<unknown, unknown>>;
import { Predicate } from '../types';
export declare const isMap: Predicate<Map<unknown, unknown>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNegative = void 0;
exports.isNegative = ((value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) < 0);
const isNegative = (value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) < 0;
exports.isNegative = isNegative;
//# sourceMappingURL=isNegative.js.map

@@ -1,2 +0,2 @@

import { None } from '../types';
export declare const isNone: <T>(value: T) => value is Extract<T, None>;
import { None, Predicate } from '../types';
export declare const isNone: Predicate<None>;

@@ -1,1 +0,2 @@

export declare const isNull: import("../types").Predicate<null>;
import { Predicate } from '../types';
export declare const isNull: Predicate<null>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isNumber = void 0;
exports.isNumber = ((value) => typeof value === 'number' && value === value);
const isNumber = (value) => typeof value === 'number' && value === value;
exports.isNumber = isNumber;
//# sourceMappingURL=isNumber.js.map

@@ -1,2 +0,2 @@

import { None } from '../types';
export declare const isObjectLike: <T>(value: T) => value is Exclude<T, boolean | None>;
import { None, PredicateType } from '../types';
export declare const isObjectLike: <T>(value: T) => value is PredicateType<Exclude<T, boolean | None>, T>;

@@ -5,6 +5,8 @@ "use strict";

const and_1 = require("../generics/and");
const at_1 = require("../generics/at");
const isNone_1 = require("./isNone");
const isObject_1 = require("./isObject");
const hasObjectConstructor = at_1.at('constructor', (value) => value === Object);
exports.isPlainObject = and_1.and(isObject_1.isObject, (value) => hasObjectConstructor(Object.getPrototypeOf(value)) && String(value) === '[object Object]');
exports.isPlainObject = and_1.and(isObject_1.isObject, (value) => {
const prototype = Object.getPrototypeOf(value);
return (isNone_1.isNone(prototype) || (prototype.constructor === Object && String(value) === '[object Object]'));
});
//# sourceMappingURL=isPlainObject.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPositive = void 0;
exports.isPositive = ((value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) > 0);
const isPositive = (value) => typeof value === 'number' && (value === 0 ? Infinity / value : value) > 0;
exports.isPositive = isPositive;
//# sourceMappingURL=isPositive.js.map
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isPrimitive = void 0;
const isNone_1 = require("./isNone");
const isFunction_1 = require("./isFunction");
exports.isPrimitive = ((value) => isNone_1.isNone(value) || (typeof value !== 'object' && !isFunction_1.isFunction(value)));
const isPrimitive = (value) => value == null || (typeof value !== 'object' && !isFunction_1.isFunction(value));
exports.isPrimitive = isPrimitive;
//# sourceMappingURL=isPrimitive.js.map

@@ -1,1 +0,2 @@

export declare const isRegExp: import("../types").Predicate<RegExp>;
import { Predicate } from '../types';
export declare const isRegExp: Predicate<RegExp>;

@@ -1,2 +0,2 @@

import { Serializable } from '../types';
export declare const isSerializable: <U>(value: U) => value is Extract<U, Serializable>;
import { Predicate, Serializable } from '../types';
export declare const isSerializable: Predicate<Serializable>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isSerializable = void 0;
const or_1 = require("../generics/or");
const isSerializableArray_1 = require("./isSerializableArray");
const isSerializableObject_1 = require("./isSerializableObject");
const isSerializablePrimitive_1 = require("./isSerializablePrimitive");
exports.isSerializable = or_1.or(isSerializableArray_1.isSerializableArray, isSerializableObject_1.isSerializableObject, isSerializablePrimitive_1.isSerializablePrimitive);
const isSerializable = (value) => isSerializableArray_1.isSerializableArray(value) || isSerializableObject_1.isSerializableObject(value) || isSerializablePrimitive_1.isSerializablePrimitive(value);
exports.isSerializable = isSerializable;
//# sourceMappingURL=isSerializable.js.map

@@ -6,3 +6,4 @@ "use strict";

const isSerializable_1 = require("./isSerializable");
exports.isSerializableArray = ((value) => isArray_1.isArray(value) && value.every(isSerializable_1.isSerializable));
const isSerializableArray = (value) => isArray_1.isArray(value) && value.every((element) => isSerializable_1.isSerializable(element));
exports.isSerializableArray = isSerializableArray;
//# sourceMappingURL=isSerializableArray.js.map

@@ -5,3 +5,4 @@ "use strict";

const isNumber_1 = require("./isNumber");
exports.isSerializableNumber = ((value) => isNumber_1.isNumber(value) && Math.abs(value) !== Infinity);
const isSerializableNumber = (value) => isNumber_1.isNumber(value) && Math.abs(value) !== Infinity;
exports.isSerializableNumber = isSerializableNumber;
//# sourceMappingURL=isSerializableNumber.js.map

@@ -7,15 +7,13 @@ "use strict";

const isSerializableObject = (value) => {
const isObjectValue = isPlainObject_1.isPlainObject(value);
if (isObjectValue) {
const valueIsPlainObject = isPlainObject_1.isPlainObject(value);
if (valueIsPlainObject) {
for (const key in value) {
if (Object.hasOwnProperty.call(value, key)) {
if (!isSerializable_1.isSerializable(value[key])) {
return false;
}
if (Object.hasOwnProperty.call(value, key) && !isSerializable_1.isSerializable(value[key])) {
return false;
}
}
}
return isObjectValue;
return valueIsPlainObject;
};
exports.isSerializableObject = isSerializableObject;
//# sourceMappingURL=isSerializableObject.js.map

@@ -1,1 +0,2 @@

export declare const isSet: import("../types").Predicate<Set<unknown>>;
import { Predicate } from '../types';
export declare const isSet: Predicate<Set<unknown>>;

@@ -1,1 +0,2 @@

export declare const isSome: <T>(value: T) => value is Exclude<T, import("../types").None>;
import { Predicate, Some } from '../types';
export declare const isSome: Predicate<Some>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isString = void 0;
exports.isString = ((value) => typeof value === 'string');
const isString = (value) => typeof value === 'string';
exports.isString = isString;
//# sourceMappingURL=isString.js.map

@@ -1,1 +0,2 @@

export declare const isSymbol: <T>(value: T) => value is Extract<T, symbol>;
import { Predicate } from '../types';
export declare const isSymbol: Predicate<symbol>;

@@ -1,1 +0,2 @@

export declare const isTrue: import("../types").Predicate<true>;
import { Predicate } from '../types';
export declare const isTrue: Predicate<true>;

@@ -6,3 +6,4 @@ "use strict";

const isPositive_1 = require("./isPositive");
exports.isUint = ((value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value !== Infinity);
const isUint = (value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value !== Infinity;
exports.isUint = isUint;
//# sourceMappingURL=isUint.js.map

@@ -6,4 +6,5 @@ "use strict";

const isPositive_1 = require("./isPositive");
const ceiling = Math.pow(2, 16);
exports.isUint16 = ((value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value < ceiling);
const UINT_16_CEILING = Math.pow(2, 16);
const isUint16 = (value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value < UINT_16_CEILING;
exports.isUint16 = isUint16;
//# sourceMappingURL=isUint16.js.map

@@ -6,4 +6,5 @@ "use strict";

const isPositive_1 = require("./isPositive");
const ceiling = Math.pow(2, 32);
exports.isUint32 = ((value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value < ceiling);
const UINT_32_CEILING = Math.pow(2, 32);
const isUint32 = (value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value < UINT_32_CEILING;
exports.isUint32 = isUint32;
//# sourceMappingURL=isUint32.js.map

@@ -6,4 +6,5 @@ "use strict";

const isPositive_1 = require("./isPositive");
const ceiling = Math.pow(2, 8);
exports.isUint8 = ((value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value < ceiling);
const UINT_8_CEILING = Math.pow(2, 8);
const isUint8 = (value) => isInt_1.isInt(value) && isPositive_1.isPositive(value) && value < UINT_8_CEILING;
exports.isUint8 = isUint8;
//# sourceMappingURL=isUint8.js.map

@@ -1,1 +0,2 @@

export declare const isUndefined: import("../types").Predicate<undefined>;
import { Predicate } from '../types';
export declare const isUndefined: Predicate<undefined>;

@@ -1,1 +0,2 @@

export declare const isWeakMap: import("../types").Predicate<WeakMap<object, unknown>>;
import { Predicate } from '../types';
export declare const isWeakMap: Predicate<WeakMap<any, unknown>>;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.isWithLength = void 0;
const at_1 = require("../generics/at");
const isLength_1 = require("./isLength");
const hasLength_1 = require("./hasLength");
/** @deprecated */
exports.isWithLength = at_1.at('length', isLength_1.isLength);
exports.isWithLength = hasLength_1.hasLength;
//# sourceMappingURL=isWithLength.js.map

@@ -1,6 +0,7 @@

export declare type Predicate<T> = <U>(value: U) => value is Extract<U, T>;
export declare type PredicateType<T, U> = (Exclude<any, U> extends never ? 1 : 0) extends 1 ? Extract<T, U> : U extends T ? U : T extends U ? T : never;
export declare type Predicate<T> = <U>(value: U) => value is PredicateType<T, U>;
export declare type Static<T extends Predicate<any>> = T extends Predicate<infer R> ? R : never;
export declare type Constructor<T extends object, U extends ReadonlyArray<any> = []> = {
export interface Constructor<T extends object = any, U extends ReadonlyArray<any> = []> {
new (...rest: U): T;
};
}
export declare type Intersect<T> = (T extends any ? (k: T) => void : never) extends (k: infer I) => void ? I : never;

@@ -13,2 +14,3 @@ export declare type Unknown = Some | None;

export declare type Nullable<T> = T | null;
export declare type Dictionary = Record<string, string>;
export declare type PlainObject = Record<string | symbol, unknown>;

@@ -26,1 +28,8 @@ export declare type ArrayLike = {

export declare type Serializable = SerializablePrimitive | SerializableObject | SerializableArray;
export declare type EmptyMap = Map<any, never>;
export declare type EmptySet = Set<never>;
export declare type EmptyArray = Array<never> | ReadonlyArray<never>;
export declare type EmptyObject = Record<any, never>;
export declare type EmptyPrimitive = EmptyString | None;
export declare type EmptyString = '';
export declare type Empty = EmptyPrimitive | EmptyArray | EmptyObject | EmptyMap | EmptySet;
{
"name": "isntnt",
"version": "2.0.0-beta.2",
"version": "2.0.0-beta.3",
"description": "A collection of composable JavaScript runtime type predicates with TypeScript type guard declarations",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

@@ -10,2 +10,3 @@ export { above } from './generics/above'

export { literal } from './generics/literal'
export { map } from './generics/map'
export { max } from './generics/max'

@@ -20,4 +21,5 @@ export { maybe } from './generics/maybe'

export { record } from './generics/record'
export { set } from './generics/set'
export { shape } from './generics/shape'
export { test } from './generics/test'
export { tuple } from './generics/tuple'
import { isNumber } from '../predicates'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const above = (floor: number) =>
((value: unknown) => isNumber(value) && value > floor) as Predicate<number>
export const above =
(floor: number): Predicate<number> =>
<T>(value: T): value is PredicateType<number, T> =>
isNumber(value) && value > floor

@@ -1,7 +0,7 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isArray } from '../predicates/isArray'
export const array = <T>(predicate: Predicate<T>) =>
((value: any) => isArray(value) && value.every(predicate)) as Predicate<
Array<T> | ReadonlyArray<T>
>
export const array =
<T>(predicate: Predicate<T>): Predicate<Array<T> | ReadonlyArray<T>> =>
<U>(value: U): value is PredicateType<Array<T> | ReadonlyArray<T>, U> =>
isArray(value) && value.every((element) => predicate(element))
import { isNumber } from '../predicates'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const below = (ceiling: number) =>
((value: any) => isNumber(value) && value < ceiling) as Predicate<number>
export const below =
(ceiling: number): Predicate<number> =>
<T>(value: T): value is PredicateType<number, T> =>
isNumber(value) && value < ceiling

@@ -1,4 +0,6 @@

import { Primitive, Predicate } from '../types'
import { Primitive, Predicate, PredicateType } from '../types'
export const literal = <T extends Primitive>(input: T) =>
((value: any) => input === value) as Predicate<T>
export const literal =
<T extends Primitive>(input: T): Predicate<T> =>
<U>(value: U): value is PredicateType<T, U> =>
input === (value as any)
import { isNumber } from '../predicates'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const max = (ceiling: number): Predicate<number> =>
((value) => isNumber(value) && value <= ceiling) as Predicate<number>
export const max =
(ceiling: number): Predicate<number> =>
<T>(value: T): value is PredicateType<number, T> =>
isNumber(value) && value <= ceiling
import { isNumber } from '../predicates'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const min = (floor: number) =>
((value) => isNumber(value) && value >= floor) as Predicate<number>
export const min =
(floor: number): Predicate<number> =>
<T>(value: T): value is PredicateType<number, T> =>
isNumber(value) && value >= floor
import { maybe } from './maybe'
/** @deprecated */
export const noneable = maybe

@@ -1,12 +0,11 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isObject } from '../predicates/isObject'
export const object = <T>(predicate: Predicate<T>): Predicate<Record<any, T>> => <U>(
value: U,
): value is Extract<U, Record<any, T>> => {
const isObjectValue = isObject(value)
if (isObjectValue) {
for (const key in value) {
if (Object.hasOwnProperty.call(value, key)) {
if (!predicate(value[key])) {
export const object =
<T>(predicate: Predicate<T>): Predicate<Record<PropertyKey, T>> =>
<U>(value: U): value is PredicateType<Record<PropertyKey, T>, U> => {
const isObjectValue = isObject(value)
if (isObjectValue) {
for (const key in value) {
if (Object.hasOwnProperty.call(value, key) && !predicate(value[key])) {
return false

@@ -16,4 +15,3 @@ }

}
return isObjectValue
}
return isObjectValue
}

@@ -1,15 +0,16 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isObject } from '../predicates'
export const record = <K extends PropertyKey, T>(
keyPredicate: Predicate<K>,
valuePredicate: Predicate<T>,
): Predicate<Record<K, T>> =>
((value: unknown): value is Record<K, T> => {
export const record =
<K extends PropertyKey, T>(
keyPredicate: Predicate<K>,
valuePredicate: Predicate<T>,
): Predicate<Record<K, T>> =>
<U>(value: U): value is PredicateType<Record<K, T>, U> => {
const isObjectValue = isObject(value)
if (isObjectValue) {
for (const key in value as object) {
for (const key in value) {
if (
Object.hasOwnProperty.call(value, key) &&
(!keyPredicate(key) || !valuePredicate((value as any)[key]))
(!keyPredicate(key) || !valuePredicate(value[key]))
) {

@@ -21,2 +22,2 @@ return false

return isObjectValue
}) as Predicate<Record<K, T>>
}
import { isString } from '../predicates/isString'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const test = <T extends string = string>(expression: RegExp): Predicate<T> => {
const clonedExpression = new RegExp(expression.source, expression.flags)
return ((value: unknown): value is T =>
isString(value) &&
!(clonedExpression.lastIndex = 0) &&
clonedExpression.test(value)) as Predicate<T>
return <U>(value: U): value is PredicateType<T, U> =>
isString(value) && !(clonedExpression.lastIndex = 0) && clonedExpression.test(value)
}

@@ -1,5 +0,5 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isArray } from '../predicates/isArray'
type BaseTuple = ReadonlyArray<any>
type BaseTuple = ReadonlyArray<unknown>

@@ -10,14 +10,14 @@ type TuplePredicates<T extends BaseTuple> = { [K in keyof T]: Predicate<T[K]> }

export const tuple = <T extends BaseTuple>(
...predicates: TuplePredicates<T>
): Predicate<Tuple<T>> => <U>(value: U): value is Extract<U, T> => {
const isArrayOfLength = isArray(value) && value.length === predicates.length
if (isArrayOfLength) {
for (let i = 0; i < predicates.length; ++i) {
if (!predicates[i]((value as any)[i])) {
return false
export const tuple =
<T extends BaseTuple>(...predicates: TuplePredicates<T>): Predicate<Tuple<T>> =>
<U>(value: U): value is PredicateType<T, U> => {
const isArrayOfLength = isArray(value) && value.length === predicates.length
if (isArrayOfLength) {
for (let i = 0; i < predicates.length; ++i) {
if (!predicates[i]((value as any)[i])) {
return false
}
}
}
return isArrayOfLength
}
return isArrayOfLength
}

@@ -9,2 +9,9 @@ export { hasLength } from './predicates/hasLength'

export { isDictionary } from './predicates/isDictionary'
export { isEmpty } from './predicates/isEmpty'
export { isEmptyArray } from './predicates/isEmptyArray'
export { isEmptyMap } from './predicates/isEmptyMap'
export { isEmptyObject } from './predicates/isEmptyObject'
export { isEmptyPrimitive } from './predicates/isEmptyPrimitive'
export { isEmptySet } from './predicates/isEmptySet'
export { isEmptyString } from './predicates/isEmptyString'
export { isFalse } from './predicates/isFalse'

@@ -11,0 +18,0 @@ export { isFunction } from './predicates/isFunction'

@@ -1,3 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isBoolean = ((value: any) => typeof value === 'boolean') as Predicate<boolean>
export const isBoolean: Predicate<boolean> = <T>(value: T): value is PredicateType<boolean, T> =>
typeof value === 'boolean'
import { instance } from '../generics/instance'
import { Predicate } from '../types'
export const isDate = instance(Date)
export const isDate: Predicate<Date> = instance(Date)
import { object } from '../generics/object'
import { Dictionary, Predicate } from '../types'
import { isString } from './isString'
export type Dictionary = Record<any, string>
export const isDictionary = object(isString) as <T>(value: T) => value is Extract<T, Dictionary>
export const isDictionary: Predicate<Dictionary> = object(isString)
import { literal } from '../generics/literal'
import { Predicate } from '../types'
export const isFalse = literal(false)
export const isFalse: Predicate<false> = literal(false)

@@ -1,3 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isFunction = ((value) => typeof value === 'function') as Predicate<Function>
export const isFunction: Predicate<Function> = <U>(value: U): value is PredicateType<Function, U> =>
typeof value === 'function'

@@ -1,4 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isInt: Predicate<number> = ((value: unknown) =>
typeof value === 'number' && value === Math.floor(value)) as Predicate<number>
export const isInt: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
typeof value === 'number' && value === Math.floor(value)

@@ -1,7 +0,7 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isInt } from './isInt'
const boundary = Math.pow(2, 16) / 2
const INT_16_BOUNDARY = Math.pow(2, 16) / 2
export const isInt16 = ((value: unknown) =>
isInt(value) && value >= -boundary && value < boundary) as Predicate<number>
export const isInt16: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && value >= -INT_16_BOUNDARY && value < INT_16_BOUNDARY

@@ -1,7 +0,7 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isInt } from './isInt'
const boundary = Math.pow(2, 32) / 2
const INT_32_BOUNDARY = Math.pow(2, 32) / 2
export const isInt32 = ((value: unknown) =>
isInt(value) && value >= -boundary && value < boundary) as Predicate<number>
export const isInt32: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && value >= -INT_32_BOUNDARY && value < INT_32_BOUNDARY

@@ -1,7 +0,7 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isInt } from './isInt'
const boundary = Math.pow(2, 8) / 2
const INT_8_BOUNDARY = Math.pow(2, 8) / 2
export const isInt8 = ((value: unknown) =>
isInt(value) && value >= -boundary && value < boundary) as Predicate<number>
export const isInt8: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && value >= -INT_8_BOUNDARY && value < INT_8_BOUNDARY
import { instance } from '../generics/instance'
import { Predicate } from '../types'
export const isMap = instance(Map)
export const isMap: Predicate<Map<unknown, unknown>> = instance(Map)

@@ -1,4 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isNegative = ((value) =>
typeof value === 'number' && (value === 0 ? Infinity / value : value) < 0) as Predicate<number>
export const isNegative: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
typeof value === 'number' && (value === 0 ? Infinity / value : value) < 0

@@ -1,4 +0,5 @@

import { None } from '../types'
import { None, Predicate, PredicateType } from '../types'
import { isSome } from './isSome'
export const isNone = <T>(value: T): value is Extract<T, None> => !isSome(value)
export const isNone: Predicate<None> = <T>(value: T): value is PredicateType<None, T> =>
!isSome(value)
import { literal } from '../generics/literal'
import { Predicate } from '../types'
export const isNull = literal(null)
export const isNull: Predicate<null> = literal(null)

@@ -1,4 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isNumber = ((value) =>
typeof value === 'number' && value === value) as Predicate<number>
export const isNumber: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
typeof value === 'number' && value === value
import { and } from '../generics/and'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isSome } from './isSome'
export const isObject = and(
export const isObject: Predicate<object> = and(
isSome,
(value: unknown): value is any => typeof value === 'object',
) as Predicate<object>
<T>(value: T): value is PredicateType<object, T> => typeof value === 'object',
)

@@ -1,6 +0,6 @@

import { None } from '../types'
import { None, PredicateType } from '../types'
import { isBoolean } from './isBoolean'
import { isSome } from './isSome'
export const isObjectLike = <T>(value: T): value is Exclude<T, None | boolean> =>
export const isObjectLike = <T>(value: T): value is PredicateType<Exclude<T, None | boolean>, T> =>
isSome(value) && !isBoolean(value)

@@ -13,4 +13,4 @@ import { isPlainObject } from '../predicates'

test('returns false for an object without a prototype', () => {
expect(isPlainObject(Object.create(null))).toBe(false)
test('returns true for an object without a prototype', () => {
expect(isPlainObject(Object.create(null))).toBe(true)
})

@@ -17,0 +17,0 @@

import { and } from '../generics/and'
import { at } from '../generics/at'
import { PlainObject, Predicate } from '../types'
import { PlainObject, Predicate, PredicateType } from '../types'
import { isNone } from './isNone'
import { isObject } from './isObject'
const hasObjectConstructor: Predicate<{ constructor: ObjectConstructor }> = at(
'constructor',
(value: any): value is any => value === Object,
export const isPlainObject: Predicate<PlainObject> = and(
isObject,
<U>(value: U): value is PredicateType<PlainObject, U> => {
const prototype = Object.getPrototypeOf(value) as Object | null
return (
isNone(prototype) || (prototype.constructor === Object && String(value) === '[object Object]')
)
},
)
export const isPlainObject = and(
isObject,
(value: unknown): value is any =>
hasObjectConstructor(Object.getPrototypeOf(value)) && String(value) === '[object Object]',
) as Predicate<PlainObject>

@@ -1,4 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isPositive = ((value: unknown) =>
typeof value === 'number' && (value === 0 ? Infinity / value : value) > 0) as Predicate<number>
export const isPositive: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
typeof value === 'number' && (value === 0 ? Infinity / value : value) > 0

@@ -1,6 +0,7 @@

import { Predicate, Primitive } from '../types'
import { isNone } from './isNone'
import { Predicate, PredicateType, Primitive } from '../types'
import { isFunction } from './isFunction'
export const isPrimitive = ((value: any) =>
isNone(value) || (typeof value !== 'object' && !isFunction(value))) as Predicate<Primitive>
export const isPrimitive: Predicate<Primitive> = <T>(
value: T,
): value is PredicateType<Primitive, T> =>
value == null || (typeof value !== 'object' && !isFunction(value))
import { instance } from '../generics/instance'
import { Predicate } from '../types'
export const isRegExp = instance(RegExp)
export const isRegExp: Predicate<RegExp> = instance(RegExp)

@@ -1,3 +0,2 @@

import { Serializable } from '../types'
import { or } from '../generics/or'
import { Predicate, PredicateType, Serializable } from '../types'
import { isSerializableArray } from './isSerializableArray'

@@ -7,6 +6,5 @@ import { isSerializableObject } from './isSerializableObject'

export const isSerializable = or(
isSerializableArray,
isSerializableObject,
isSerializablePrimitive,
) as <U>(value: U) => value is Extract<U, Serializable>
export const isSerializable: Predicate<Serializable> = <T>(
value: T,
): value is PredicateType<Serializable, T> =>
isSerializableArray(value) || isSerializableObject(value) || isSerializablePrimitive(value)

@@ -1,6 +0,8 @@

import { Predicate, SerializableArray } from '../types'
import { Predicate, PredicateType, SerializableArray } from '../types'
import { isArray } from './isArray'
import { isSerializable } from './isSerializable'
export const isSerializableArray = ((value) =>
isArray(value) && value.every(isSerializable)) as Predicate<SerializableArray>
export const isSerializableArray: Predicate<SerializableArray> = <U>(
value: U,
): value is PredicateType<SerializableArray, U> =>
isArray(value) && value.every((element) => isSerializable(element))

@@ -1,5 +0,6 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isNumber } from './isNumber'
export const isSerializableNumber = ((value) =>
isNumber(value) && Math.abs(value) !== Infinity) as Predicate<number>
export const isSerializableNumber: Predicate<number> = <T>(
value: T,
): value is PredicateType<number, T> => isNumber(value) && Math.abs(value) !== Infinity

@@ -8,8 +8,9 @@ import { isSerializableObject } from '../predicates'

it('returns true for a plain object value', () => {
it('returns true for an empty object', () => {
expect(isSerializableObject({})).toBe(true)
expect(isSerializableObject(Object.create(null))).toBe(true)
})
it('returns true for a serializable object value', () => {
expect(isSerializableObject({ foo: 12, bar: [42, null, 'abc'] })).toBe(true)
expect(isSerializableObject({ a: 12, b: [42, null, 'abc'] })).toBe(true)
})

@@ -25,5 +26,4 @@

it('returns false for any value that is not a plain object', () => {
it('returns false for any value that is not an object', () => {
expect(isSerializableObject(true)).toBe(false)
expect(isSerializableObject(Object.create(null))).toBe(false)
expect(isSerializableObject([])).toBe(false)

@@ -30,0 +30,0 @@ expect(isSerializableObject(/abc/)).toBe(false)

@@ -1,2 +0,2 @@

import { SerializableObject, Predicate } from '../types'
import { SerializableObject, Predicate, PredicateType } from '../types'
import { isSerializable } from './isSerializable'

@@ -7,14 +7,13 @@ import { isPlainObject } from './isPlainObject'

value: T,
): value is Extract<T, SerializableObject> => {
const isObjectValue = isPlainObject(value)
if (isObjectValue) {
for (const key in value as any) {
if (Object.hasOwnProperty.call(value, key)) {
if (!isSerializable((value as any)[key])) {
return false
}
): value is PredicateType<SerializableObject, T> => {
const valueIsPlainObject = isPlainObject(value)
if (valueIsPlainObject) {
for (const key in value) {
if (Object.hasOwnProperty.call(value, key) && !isSerializable(value[key])) {
return false
}
}
}
return isObjectValue
return valueIsPlainObject
}

@@ -1,2 +0,2 @@

import { Predicate, SerializablePrimitive } from '../types'
import { Predicate, PredicateType, SerializablePrimitive } from '../types'
import { isBoolean } from './isBoolean'

@@ -9,3 +9,3 @@ import { isNull } from './isNull'

value: T,
): value is Extract<T, SerializablePrimitive> =>
): value is PredicateType<SerializablePrimitive, T> =>
isNull(value) || isString(value) || isSerializableNumber(value) || isBoolean(value)
import { instance } from '../generics/instance'
import { Predicate } from '../types'
export const isSet = instance(Set)
export const isSet: Predicate<Set<unknown>> = instance(Set)

@@ -1,3 +0,4 @@

import { Some } from '../types'
import { Predicate, PredicateType, Some } from '../types'
export const isSome = <T>(value: T): value is Some<T> => value != null && value === value
export const isSome: Predicate<Some> = <T>(value: T): value is PredicateType<Some, T> =>
value != null && value === value

@@ -1,3 +0,4 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
export const isString = ((value) => typeof value === 'string') as Predicate<string>
export const isString: Predicate<string> = <T>(value: T): value is PredicateType<string, T> =>
typeof value === 'string'

@@ -1,1 +0,4 @@

export const isSymbol = <T>(value: T): value is Extract<T, symbol> => typeof value === 'symbol'
import { Predicate, PredicateType } from '../types'
export const isSymbol: Predicate<symbol> = <T>(value: T): value is PredicateType<symbol, T> =>
typeof value === 'symbol'
import { literal } from '../generics/literal'
import { Predicate } from '../types'
export const isTrue = literal(true)
export const isTrue: Predicate<true> = literal(true)

@@ -1,6 +0,6 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isInt } from './isInt'
import { isPositive } from './isPositive'
export const isUint = ((value: unknown): value is number =>
isInt(value) && isPositive(value) && value !== Infinity) as Predicate<number>
export const isUint: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && isPositive(value) && value !== Infinity

@@ -1,8 +0,8 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isInt } from './isInt'
import { isPositive } from './isPositive'
const ceiling = Math.pow(2, 16)
const UINT_16_CEILING = Math.pow(2, 16)
export const isUint16 = ((value: unknown): value is number =>
isInt(value) && isPositive(value) && value < ceiling) as Predicate<number>
export const isUint16: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && isPositive(value) && value < UINT_16_CEILING
import { isInt } from './isInt'
import { isPositive } from './isPositive'
import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
const ceiling = Math.pow(2, 32)
const UINT_32_CEILING = Math.pow(2, 32)
export const isUint32 = ((value) =>
isInt(value) && isPositive(value) && value < ceiling) as Predicate<number>
export const isUint32: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && isPositive(value) && value < UINT_32_CEILING

@@ -1,8 +0,8 @@

import { Predicate } from '../types'
import { Predicate, PredicateType } from '../types'
import { isInt } from './isInt'
import { isPositive } from './isPositive'
const ceiling = Math.pow(2, 8)
const UINT_8_CEILING = Math.pow(2, 8)
export const isUint8 = ((value: unknown): value is number =>
isInt(value) && isPositive(value) && value < ceiling) as Predicate<number>
export const isUint8: Predicate<number> = <T>(value: T): value is PredicateType<number, T> =>
isInt(value) && isPositive(value) && value < UINT_8_CEILING
import { literal } from '../generics/literal'
import { Predicate } from '../types'
export const isUndefined = literal(undefined)
export const isUndefined: Predicate<undefined> = literal(undefined)
import { instance } from '../generics/instance'
import { Predicate } from '../types'
export const isWeakMap = instance(WeakMap)
export const isWeakMap: Predicate<WeakMap<any, unknown>> = instance(WeakMap)

@@ -1,5 +0,4 @@

import { at } from '../generics/at'
import { isLength } from './isLength'
import { hasLength } from './hasLength'
/** @deprecated */
export const isWithLength = at('length', isLength)
export const isWithLength = hasLength

@@ -1,6 +0,14 @@

export type Predicate<T> = <U>(value: U) => value is Extract<U, T>
export type PredicateType<T, U> = (Exclude<any, U> extends never ? 1 : 0) extends 1
? Extract<T, U>
: U extends T
? U
: T extends U
? T
: never
export type Predicate<T> = <U>(value: U) => value is PredicateType<T, U>
export type Static<T extends Predicate<any>> = T extends Predicate<infer R> ? R : never
export type Constructor<T extends object, U extends ReadonlyArray<any> = []> = {
export interface Constructor<T extends object = any, U extends ReadonlyArray<any> = []> {
new (...rest: U): T

@@ -25,2 +33,4 @@ }

export type Dictionary = Record<string, string>
export type PlainObject = Record<string | symbol, unknown>

@@ -38,1 +48,10 @@

export type Serializable = SerializablePrimitive | SerializableObject | SerializableArray
export type EmptyMap = Map<any, never>
export type EmptySet = Set<never>
export type EmptyArray = Array<never> | ReadonlyArray<never>
export type EmptyObject = Record<any, never>
export type EmptyPrimitive = EmptyString | None
export type EmptyString = ''
export type Empty = EmptyPrimitive | EmptyArray | EmptyObject | EmptyMap | EmptySet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc