Skip to content package
typical v7.3.0 Isomorphic, functional type-checking for Javascript
node >=12.17 0 deps esm cjs open source
overview readme
license MIT
deps 0
unpacked 29.0 kB
files 6
node >=12.17 $ npm install typical@7.3.0n npmREADME GitHub-flavored package documentation.
downloads Across all versions, last 30 days.
14,376,010 weekly -3.6%
58,846,664 in 30 days
Oct 16 → Nov 14 hover or arrows
compatibility Runtime metadata.
keywords Tagged topics.
type checking check value valid is detect number object plainobject array like
install size Estimated unpacked size across 1 packages.
28.6 kB
Includes dependencies.
versions Latest published Oct 23, 2026
maintainers Registry package owners.
typical Isomorphic, functional type-checking for Javascript.
import t from 'typical'
const allDefined = array. every (t.isDefined) copy
t.isNumber(n) ⇒ boolean Returns true if input is a number (including infinity). It is a more reasonable alternative to typeof n which returns number for NaN.
Kind : static method of typical
Returns : boolean - true if input is a number
Param Type Description n *The input to test
> t. isNumber ( 0 )
true
> t. isNumber ( 1 )
true
> t. isNumber ( 1.1 )
true
> t. isNumber ( 0xff )
true
> t. isNumber ( 0644 )
true
> t. isNumber ( 6.2e5 )
true
> t. isNumber (NaN)
false
> t. isNumber (Infinity)
true copy
t.isFiniteNumber(n) ⇒ boolean Returns true if input is a finite number. Identical to isNumber beside excluding infinity.
Param Type Description n *The input to test
> t. isFiniteNumber ( 0 )
true
> t. isFiniteNumber ( 1 )
true
> t. isFiniteNumber ( 1.1 )
true
> t. isFiniteNumber ( 0xff )
true
> t. isFiniteNumber ( 0644 )
true
> t. isFiniteNumber ( 6.2e5 )
true
> t. isFiniteNumber (NaN)
false
> t. isFiniteNumber (Infinity)
false copy
A plain object is a simple object literal not an instance of a class. Returns true if the input typeof is object and is not null plus either has a prototype of Object.prototype or null.
Param Type Description input *The input to test
> t. isPlainObject ({ something: 'one' }) // object literal
true
> t. isPlainObject (Object. create (null)) // null-prototype plain object
true
> t. isPlainObject ({ something: 'one' })
true
> t. isPlainObject ( new Date ())
false
> t. isPlainObject ([ 0 , 1 ])
false
> t. isPlainObject ( /test/ )
false
> t. isPlainObject ( 1 )
false
> t. isPlainObject ( 'one' )
false
> t. isPlainObject (null)
false
> t. isPlainObject (( function * () {})())
false
> t. isPlainObject ( function * () {})
false copy
An array-like value has all the properties of an array yet is not an array instance. An example is the arguments object. Returns true`` if the input value is an object, not null`` and has a length property set with a numeric value.
Param Type Description input *The input to test
function sum (x, y){
console. log (t. isArrayLike ( arguments ))
// prints `true`
} copy
Returns true if the typeof input is 'object' but not null.
Param Type Description input *The input to test
Returns true if the input value is defined.
Param Type Description input *The input to test
Returns true if the input value is undefined.
Param Type Description input *The input to test
Returns true if the input value is null.
Param Type Description input *The input to test
Returns true if the input value is not one of undefined, null, or NaN.
Param Type Description input *The input to test
Returns true if the input value is an ES2015 class.
Param Type Description input *The input to test
Returns true if the input is a string, number, symbol, boolean, null or undefined value.
Param Type Description input *The input to test
Returns true if the input is a Promise.
Param Type Description input *The input to test
Returns true if the input is an iterable (Map, Set, Array, Generator etc.).
Param Type Description input *The input to test
> t. isIterable ( 'string' )
true
> t. isIterable ( new Map ())
true
> t. isIterable ([])
true
> t. isIterable (( function * () {})())
true
> t. isIterable ( Promise . resolve ())
false
> t. isIterable ( Promise )
false
> t. isIterable ( true )
false
> t. isIterable ({})
false
> t. isIterable ( 0 )
false
> t. isIterable ( 1.1 )
false
> t. isIterable (NaN)
false
> t. isIterable (Infinity)
false
> t. isIterable ( function () {})
false
> t. isIterable (Date)
false
> t. isIterable ()
false
> t. isIterable ({ then : function () {} })
false copy
Returns true if the input value is a string. The equivalent of typeof input === 'string' for use in funcitonal contexts.
Param Type Description input *The input to test
Returns true if the input value is a function. The equivalent of typeof input === 'function' for use in funcitonal contexts.
Param Type Description input *The input to test
Returns true if the input value is an async function or method.
Param Type Description input *The input to test
> t. isAsyncFunction ( function () {})
false
> t. isAsyncFunction ( new Function ())
false
> t. isAsyncFunction (() => {})
false
> t. isAsyncFunction ( async function () {})
true
> const AsyncFunction = async function () {}.constructor
> t. isAsyncFunction ( new AsyncFunction ())
true
> t. isAsyncFunction ( async () => {})
true
> class Command { async execute () {} }
> t. isAsyncFunction ( new Command ().execute)
true copy
Load anywhere This library is compatible with Node.js, the Web and any style of module loader. It can be loaded anywhere, natively without transpilation.
Within a Node.js ECMAScript Module:
import t from 'typical'
import { isNumber } from 'typical' copy const t = require ( 'typical' )
const { isNumber } = require ( 'typical' ) copy Within a modern browser ECMAScript Module:
import t from './node_modules/typical/index.js' copy