@thi.ng/checks
- Version 3.6.19
- Published
- 59.9 kB
- 1 dependency
- Apache-2.0 license
Install
npm i @thi.ng/checks
yarn add @thi.ng/checks
pnpm add @thi.ng/checks
Overview
Collection of 70+ type, feature & value checks
Index
Functions
- exists()
- existsAndNotNull()
- hasBigInt()
- hasCrypto()
- hasMaxLength()
- hasMinLength()
- hasPerformance()
- hasWASM()
- hasWebGL()
- hasWebSocket()
- implementsFunction()
- isAlpha()
- isAlphaNum()
- isArray()
- isArrayBufferLike()
- isArrayBufferView()
- isArrayLike()
- isASCII()
- isAsyncIterable()
- isBigInt()
- isBlob()
- isBoolean()
- isChrome()
- isDataURL()
- isDate()
- isEven()
- isFalse()
- isFile()
- isFirefox()
- isFloatString()
- isFunction()
- isGenerator()
- isHex()
- isHexColor()
- isIE()
- isIllegalKey()
- isInRange()
- isInt32()
- isIntString()
- isIterable()
- isMap()
- isMobile()
- isNaN()
- isNegative()
- isNil()
- isNode()
- isNotStringAndIterable()
- isNull()
- isNumber()
- isNumeric()
- isNumericFloat()
- isNumericInt()
- isObject()
- isOdd()
- isPlainObject()
- isPositive()
- isPrimitive()
- isPrintableASCII()
- isPromise()
- isPromiseLike()
- isProtoPath()
- isRegExp()
- isSafari()
- isSet()
- isString()
- isSymbol()
- isTouchEvent()
- isTransferable()
- isTrue()
- isTypedArray()
- isUint32()
- isUndefined()
- isUUID()
- isUUIDv4()
- isZero()
Type Aliases
Functions
function exists
exists: <T>(t: T) => t is T;
function existsAndNotNull
existsAndNotNull: <T>(x: T) => x is T;
function hasBigInt
hasBigInt: () => boolean;
function hasCrypto
hasCrypto: () => boolean;
function hasMaxLength
hasMaxLength: (len: number, x: ArrayLike<any>) => boolean;
function hasMinLength
hasMinLength: (len: number, x: ArrayLike<any>) => boolean;
function hasPerformance
hasPerformance: () => boolean;
function hasWASM
hasWASM: () => boolean;
function hasWebGL
hasWebGL: () => boolean;
function hasWebSocket
hasWebSocket: () => boolean;
function implementsFunction
implementsFunction: <T = any, K extends keyof T = any>( x: any, fn: K) => x is Pick<T, K>;
function isAlpha
isAlpha: (x: string) => boolean;
function isAlphaNum
isAlphaNum: (x: string) => boolean;
function isArray
isArray: (arg: any) => arg is any[];
function isArrayBufferLike
isArrayBufferLike: (x: any) => x is ArrayBufferLike;
function isArrayBufferView
isArrayBufferView: (x: any) => x is ArrayBufferView;
function isArrayLike
isArrayLike: <T = any>(x: any) => x is ArrayLike<T>;
function isASCII
isASCII: (x: string) => boolean;
Returns true iff all chars are in ASCII range [0x00 .. 0x7f]
Parameter x
function isAsyncIterable
isAsyncIterable: <T = any>(x: any) => x is AsyncIterable<T>;
function isBigInt
isBigInt: (x: any) => x is bigint;
function isBlob
isBlob: (x: any) => x is Blob;
function isBoolean
isBoolean: (x: any) => x is boolean;
function isChrome
isChrome: () => boolean;
function isDataURL
isDataURL: (x: string) => boolean;
function isDate
isDate: (x: any) => x is Date;
function isEven
isEven: (x: number) => boolean;
function isFalse
isFalse: (x: any) => x is false;
function isFile
isFile: (x: any) => x is File;
function isFirefox
isFirefox: () => boolean;
function isFloatString
isFloatString: (x: string) => boolean;
function isFunction
isFunction: <T extends Function>(x: any) => x is T;
function isGenerator
isGenerator: <T = any>(x: any) => x is Generator<T, any, unknown>;
Returns true if
x
is an instantiated ES6 generator (i.e. it isIterable and implementsFunctionnext
).Parameter x
function isHex
isHex: (x: string) => boolean;
function isHexColor
isHexColor: (x: any) => x is string;
function isIE
isIE: () => boolean;
function isIllegalKey
isIllegalKey: (x: any) => boolean;
Returns true, if given
x
is an illegal object key as per ILLEGAL_KEYS.Parameter x
Remarks
Also see isProtoPath for more details
function isInRange
isInRange: (min: number, max: number, x: number) => boolean;
function isInt32
isInt32: (x: any) => x is number;
function isIntString
isIntString: (x: string) => boolean;
function isIterable
isIterable: <T = any>(x: any) => x is Iterable<T>;
function isMap
isMap: <K = any, V = any>(x: any) => x is Map<K, V>;
function isMobile
isMobile: () => boolean;
function isNaN
isNaN: (x: any) => boolean;
function isNegative
isNegative: (x: any) => x is number;
function isNil
isNil: (x: any) => x is null;
Checks if x is null or undefined.
function isNode
isNode: () => boolean;
function isNotStringAndIterable
isNotStringAndIterable: <T = any>(x: any) => x is Iterable<T>;
function isNull
isNull: (x: any) => x is null;
function isNumber
isNumber: (x: any) => x is number;
function isNumeric
isNumeric: (x: string) => boolean;
function isNumericFloat
isNumericFloat: (x: string) => boolean;
Returns true if given string only contains an integer or floating point number, optionally in scientific notiation (e.g.
-123.45e-6
).Parameter x
function isNumericInt
isNumericInt: (x: string) => boolean;
Returns true if given string contains only digits, and optionally, a sign prefix.
Parameter x
function isObject
isObject: (x: any) => x is Object;
function isOdd
isOdd: (x: number) => boolean;
function isPlainObject
isPlainObject: (x: any) => x is Record<string, any>;
Similar to isObject, but also checks if prototype is that of
Object
(ornull
).Parameter x
function isPositive
isPositive: (x: any) => x is number;
function isPrimitive
isPrimitive: (x: any) => x is string | number | boolean;
Returns true if
x
is a string, number or boolean.Parameter x
function isPrintableASCII
isPrintableASCII: (x: string) => boolean;
Returns true iff all chars are in printable ASCII range [0x20 .. 0x7e]
Parameter x
function isPromise
isPromise: <T = any>(x: any) => x is Promise<T>;
function isPromiseLike
isPromiseLike: <T = any>(x: any) => x is Promise<T>;
function isProtoPath
isProtoPath: (path: string | number | readonly (string | number)[]) => boolean;
Returns true if given
path
contains any ILLEGAL_KEYS, i.e. could be used to poison the prototype chain of an object.Parameter path
Remarks
If given an array, each item is considered a single sub-path property and will be checked as is. If given a string it will be split using "." as delimiter and each item checked as is (same way array paths are handled).
Original discussion here, implementation updated to be more encompassing: https://github.com/thi-ng/umbrella/pull/273
Also see isIllegalKey.
function isRegExp
isRegExp: (x: any) => x is RegExp;
function isSafari
isSafari: () => boolean;
function isSet
isSet: <T = any>(x: any) => x is Set<T>;
function isString
isString: (x: any) => x is string;
function isSymbol
isSymbol: (x: any) => x is Symbol;
function isTouchEvent
isTouchEvent: (e: Event) => e is TouchEvent;
On Firefox
TouchEvent
is undefined if the hardware doesn't support touch. Therefore this predicate checks for that first before verifying ife
is indeed aTouchEvent
.Parameter e
function isTransferable
isTransferable: (x: any) => boolean;
function isTrue
isTrue: (x: any) => x is boolean;
function isTypedArray
isTypedArray: (x: any) => x is TypedArray;
function isUint32
isUint32: (x: any) => x is number;
function isUndefined
isUndefined: (x: any) => x is undefined;
function isUUID
isUUID: (x: string) => boolean;
function isUUIDv4
isUUIDv4: (x: string) => boolean;
function isZero
isZero: (x: any) => x is 0;
Type Aliases
type TypedArray
type TypedArray = | Float32Array | Float64Array | Int8Array | Int16Array | Int32Array | Uint8Array | Uint8ClampedArray | Uint16Array | Uint32Array;
Package Files (71)
- exists-not-null.d.ts
- exists.d.ts
- has-bigint.d.ts
- has-crypto.d.ts
- has-max-length.d.ts
- has-min-length.d.ts
- has-performance.d.ts
- has-wasm.d.ts
- has-webgl.d.ts
- has-websocket.d.ts
- implements-function.d.ts
- index.d.ts
- is-alphanum.d.ts
- is-array.d.ts
- is-arraybufferlike.d.ts
- is-arraybufferview.d.ts
- is-arraylike.d.ts
- is-ascii.d.ts
- is-async-iterable.d.ts
- is-bigint.d.ts
- is-blob.d.ts
- is-boolean.d.ts
- is-chrome.d.ts
- is-data-url.d.ts
- is-date.d.ts
- is-even.d.ts
- is-false.d.ts
- is-file.d.ts
- is-firefox.d.ts
- is-float-string.d.ts
- is-function.d.ts
- is-generator.d.ts
- is-hex-color.d.ts
- is-hex.d.ts
- is-ie.d.ts
- is-in-range.d.ts
- is-int-string.d.ts
- is-int32.d.ts
- is-iterable.d.ts
- is-map.d.ts
- is-mobile.d.ts
- is-nan.d.ts
- is-negative.d.ts
- is-nil.d.ts
- is-node.d.ts
- is-not-string-iterable.d.ts
- is-null.d.ts
- is-number.d.ts
- is-numeric.d.ts
- is-object.d.ts
- is-odd.d.ts
- is-plain-object.d.ts
- is-positive.d.ts
- is-primitive.d.ts
- is-promise.d.ts
- is-promiselike.d.ts
- is-proto-path.d.ts
- is-regexp.d.ts
- is-safari.d.ts
- is-set.d.ts
- is-string.d.ts
- is-symbol.d.ts
- is-touch-event.d.ts
- is-transferable.d.ts
- is-true.d.ts
- is-typedarray.d.ts
- is-uint32.d.ts
- is-undefined.d.ts
- is-uuid.d.ts
- is-uuid4.d.ts
- is-zero.d.ts
Dependencies (1)
Dev Dependencies (5)
Peer Dependencies (0)
No peer dependencies.
Badge
To add a badge like this oneto your package's README, use the codes available below.
You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@thi.ng/checks
.
- Markdown[![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@thi.ng/checks)
- HTML<a href="https://www.jsdocs.io/package/@thi.ng/checks"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 1990 ms. - Missing or incorrect documentation? Open an issue for this package.