typechecker
- Version 9.3.0
- Published
- 106 kB
- 1 dependency
- Artistic-2.0 license
Install
npm i typecheckeryarn add typecheckerpnpm add typecheckerOverview
Utilities to get and check variable types (isString, isPlainObject, isRegExp, etc)
Index
Variables
Functions
- getObjectType()
- getType()
- isArguments()
- isArray()
- isAsyncFunction()
- isBoolean()
- isClass()
- isConventionalClass()
- isDate()
- isEmptyArray()
- isEmptyKeys()
- isEmptyMap()
- isEmptyPlainObject()
- isEmptyWeakMap()
- isError()
- isFunction()
- isMap()
- isNativeClass()
- isNull()
- isNullish()
- isNumber()
- isObject()
- isPlainObject()
- isRegExp()
- isString()
- isSyncFunction()
- isUndefined()
- isWeakMap()
Interfaces
Type Aliases
Variables
Functions
function getObjectType
getObjectType: (value?: any) => string;Get the object type string
function getType
getType: (value: any, customTypeMap?: TypeMap) => string | null;function isArguments
isArguments: { (value: IArguments): true; (value?: Any): false; (value?: any): value is IArguments;};Checks to see if a value is an arguments object
function isArray
isArray: { (value: AnyArray): true; ( value?: | string | number | bigint | boolean | symbol | void | object | PlainObject | AnyMap | AnyWeakMap ): false; (value?: any): value is AnyArray;};Checks to see if a value is an array
function isAsyncFunction
isAsyncFunction: { (value: Function): boolean; (value?: Any): false; (value?: any): value is Function;};Checks to see if a value is an asynchronous function
function isBoolean
isBoolean: { (value: AnyBoolean): true; ( value?: | string | number | bigint | symbol | void | object | PlainObject | AnyArray | AnyMap | AnyWeakMap ): false; (value?: any): value is AnyBoolean;};Checks to see if a value is a boolean
function isClass
isClass: { (value: NativeClass): true; (value: Function): boolean; (value?: Any): false; (value?: any): value is Function | NativeClass;};Is Class
function isConventionalClass
isConventionalClass: { (value: NativeClass): false; (value: Function): boolean; (value?: Any): false; (value?: any): value is Function;};Is Conventional Class Looks for function with capital first letter MyClass First letter is the 9th character If changed, isClass must also be updated
function isDate
isDate: { (value: Date): true; (value?: Any): false; (value?: any): value is Date;};Checks to see if a value is a date
function isEmptyArray
isEmptyArray: { (value: EmptyArray): true; (value: AnyArray): false; ( value?: | string | number | bigint | boolean | symbol | void | object | PlainObject | AnyMap | AnyWeakMap ): never; (value?: any): value is [];};Is empty array
Throws
if the value was not an array
function isEmptyKeys
isEmptyKeys: { (value: EmptyArray): true; (value: AnyArray): false; (value: object): boolean; (value?: any): false;};Is empty keys
function isEmptyMap
isEmptyMap: { (value: AnyMap): boolean; ( value?: | string | number | bigint | boolean | symbol | void | object | PlainObject | AnyArray | AnyWeakMap ): never; (value?: any): value is AnyMap;};Is empty map
Throws
if the value was not a Map
function isEmptyPlainObject
isEmptyPlainObject: { (value: PlainObject): boolean; ( value?: | string | number | bigint | boolean | symbol | void | object | AnyArray | AnyMap | AnyWeakMap ): never; (value?: any): value is PlainObject;};Is empty plain object
Throws
if the value was not a plain object
function isEmptyWeakMap
isEmptyWeakMap: { (value: AnyMap): never; (value: AnyWeakMap): boolean; ( value?: | string | number | bigint | boolean | symbol | void | object | PlainObject | AnyArray ): never; (value?: any): value is AnyWeakMap;};Is empty weak map
Throws
if the value was not a WeakMap
function isError
isError: { (value: Error): true; (value?: Any): false; (value?: any): value is Error;};Checks to see if a value is an error
function isFunction
isFunction: { (value: Function): true; (value?: Any): false; (value?: any): value is Function;};Checks to see if a value is a function
function isMap
isMap: { (value: AnyMap): true; ( value?: | string | number | bigint | boolean | symbol | void | object | PlainObject | AnyArray | AnyWeakMap ): false; (value?: any): value is AnyMap;};Checks to see if a value is a Map
function isNativeClass
isNativeClass: { (value: NativeClass): true; (value?: Any): false; (value?: any): value is NativeClass;};Is ES6+ class
function isNull
isNull: { (value: null): true; (value?: Any): false; (value?: any): value is null;};Checks to see if a value is null
function isNullish
isNullish: { (value?: Nullish): true; (value?: Any): false; (value?: any): value is null;};Checks to see if a value is nullish
function isNumber
isNumber: { (value: AnyNumber): true; ( value?: | string | bigint | boolean | symbol | void | object | PlainObject | AnyArray | AnyMap | AnyWeakMap ): false; (value?: any): value is AnyNumber;};Checks to see if a value is a number
function isObject
isObject: { (value: NonNullishObject): true; (value?: string | number | bigint | boolean | symbol | void): false; (value?: any): value is object;};Checks to see if a value is an object
function isPlainObject
isPlainObject: { (value: PlainObject): true; ( value?: | string | number | bigint | boolean | symbol | void | object | AnyArray | AnyMap | AnyWeakMap ): false; (value?: any): value is PlainObject;};Checks to see if a value is an object and only an object
function isRegExp
isRegExp: { (value: RegExp): true; (value?: Any): false; (value?: any): value is RegExp;};Checks to see if a value is an regex
function isString
isString: { (value: AnyString): true; ( value?: | number | bigint | boolean | symbol | void | object | PlainObject | AnyArray | AnyMap | AnyWeakMap ): false; (value?: any): value is AnyString;};Checks to see if a value is a string
function isSyncFunction
isSyncFunction: { (value: Function): boolean; (value?: Any): false; (value?: any): value is Function;};Checks to see if a value is a function but not an asynchronous function
function isUndefined
isUndefined: { (value?: undefined): true; (value?: Any): false; (value?: any): value is undefined;};Checks to see if a value is undefined
function isWeakMap
isWeakMap: { (value: AnyMap): false; (value: AnyWeakMap): true; ( value?: | string | number | bigint | boolean | symbol | void | object | PlainObject | AnyArray ): false; (value?: any): value is AnyWeakMap;};Checks to see if a value is a WeakMap
Interfaces
interface TypeMap
interface TypeMap {}The interface for a type mapping (key => function) to use for getType. export * The key represents the name of the type. The function represents the . The map should be ordered by testing preference, with more specific tests first. If a test returns true, it is selected, and the key is returned as the type.
index signature
[type: string]: TypeTester;Type Aliases
type Any
type Any = | boolean | number | bigint | string | null | undefined | void | symbol | object | PlainObject | AnyArray | AnyMap | AnyWeakMap;type AnyArray
type AnyArray = any[];type AnyBoolean
type AnyBoolean = boolean | Boolean;type AnyFunction
type AnyFunction = Function;type AnyMap
type AnyMap = Map<any, any>;type AnyNumber
type AnyNumber = number | Number;type AnyString
type AnyString = string | String;type AnyWeakMap
type AnyWeakMap = WeakMap<WeakKey, any>;type EmptyArray
type EmptyArray = [];type NativeClass
type NativeClass = abstract new (...args: any) => any;type NonNullishObject
type NonNullishObject = object;type Nullish
type Nullish = undefined | null;type PlainObject
type PlainObject = Record<any, {}>;type TypeTester
type TypeTester = (value: any) => boolean;Determines if the passed value is of a specific type
Package Files (1)
Dependencies (1)
Dev Dependencies (16)
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/typechecker.
- Markdown[](https://www.jsdocs.io/package/typechecker)
- HTML<a href="https://www.jsdocs.io/package/typechecker"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>
- Updated .
Package analyzed in 3669 ms. - Missing or incorrect documentation? Open an issue for this package.
