@thi.ng/checks

  • Version 3.1.5
  • Published
  • 49.6 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 50+ type, feature & value checks

Index

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 isArrayLike

                              isArrayLike: (x: any) => x is ArrayLike<any>;

                                function isASCII

                                isASCII: (x: string) => boolean;
                                • Returns true iff all chars are in ASCII range [0x00 .. 0x7f]

                                  Parameter x

                                function isAsyncIterable

                                isAsyncIterable: (x: any) => x is AsyncIterable<any>;

                                  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: (x: any) => x is Function;

                                                        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

                                                                See Also

                                                              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: (x: any) => x is Iterable<any>;

                                                                      function isMap

                                                                      isMap: (x: any) => x is Map<any, any>;

                                                                        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: (x: any) => x is Iterable<any>;

                                                                                  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 (or null).

                                                                                              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: (x: any) => x is Promise<any>;

                                                                                                function isPromiseLike

                                                                                                isPromiseLike: (x: any) => x is Promise<any>;

                                                                                                  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

                                                                                                  function isRegExp

                                                                                                  isRegExp: (x: any) => x is RegExp;

                                                                                                    function isSafari

                                                                                                    isSafari: () => boolean;

                                                                                                      function isSet

                                                                                                      isSet: (x: any) => x is Set<any>;

                                                                                                        function isString

                                                                                                        isString: (x: any) => x is string;

                                                                                                          function isSymbol

                                                                                                          isSymbol: (x: any) => x is Symbol;

                                                                                                            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;

                                                                                                                            Package Files (66)

                                                                                                                            Dependencies (1)

                                                                                                                            Dev Dependencies (7)

                                                                                                                            Peer Dependencies (0)

                                                                                                                            No peer dependencies.

                                                                                                                            Badge

                                                                                                                            To add a badge like this onejsDocs.io badgeto 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>