Gathering detailed insights and metrics for typical
Gathering detailed insights and metrics for typical
Gathering detailed insights and metrics for typical
Gathering detailed insights and metrics for typical
Isomorphic, functional type-checking for Javascript
npm install typical
Typescript
Module System
Min. Node Version
Node Version
NPM Version
JavaScript (100%)
Total Downloads
794,569,227
Last Day
352,013
Last Week
5,663,088
Last Month
24,266,282
Last Year
246,998,273
MIT License
23 Stars
108 Commits
4 Forks
1 Watchers
2 Branches
4 Contributors
Updated on Feb 10, 2025
Minified
Minified + Gzipped
Latest Version
7.3.0
Package Id
typical@7.3.0
Unpacked Size
28.97 kB
Size
4.61 kB
File Count
6
NPM Version
10.9.0
Node Version
23.1.0
Published on
Nov 12, 2024
Cumulative downloads
Total Downloads
Last Day
8.3%
352,013
Compared to previous day
Last Week
-9.3%
5,663,088
Compared to previous week
Last Month
5.2%
24,266,282
Compared to previous month
Last Year
28.7%
246,998,273
Compared to previous year
Isomorphic, functional type-checking for Javascript.
Example
1import t from 'typical' 2const allDefined = array.every(t.isDefined)
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
boolean
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 |
Example
1> t.isNumber(0) 2true 3> t.isNumber(1) 4true 5> t.isNumber(1.1) 6true 7> t.isNumber(0xff) 8true 9> t.isNumber(0644) 10true 11> t.isNumber(6.2e5) 12true 13> t.isNumber(NaN) 14false 15> t.isNumber(Infinity) 16true
boolean
Returns true if input is a finite number. Identical to isNumber
beside excluding infinity.
Kind: static method of typical
Param | Type | Description |
---|---|---|
n | * | The input to test |
Example
1> t.isFiniteNumber(0) 2true 3> t.isFiniteNumber(1) 4true 5> t.isFiniteNumber(1.1) 6true 7> t.isFiniteNumber(0xff) 8true 9> t.isFiniteNumber(0644) 10true 11> t.isFiniteNumber(6.2e5) 12true 13> t.isFiniteNumber(NaN) 14false 15> t.isFiniteNumber(Infinity) 16false
boolean
A plain object is a simple object literal, it is not an instance of a class. Returns true if the input typeof
is object
and directly decends from Object
.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
Example
1> t.isPlainObject({ something: 'one' }) 2true 3> t.isPlainObject(new Date()) 4false 5> t.isPlainObject([ 0, 1 ]) 6false 7> t.isPlainObject(/test/) 8false 9> t.isPlainObject(1) 10false 11> t.isPlainObject('one') 12false 13> t.isPlainObject(null) 14false 15> t.isPlainObject((function * () {})()) 16false 17> t.isPlainObject(function * () {}) 18false
boolean
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.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
Example
1function sum(x, y){
2 console.log(t.isArrayLike(arguments))
3 // prints `true`
4}
boolean
Returns true if the typeof input is 'object'
but not null.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is defined.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is undefined.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is null.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is not one of undefined
, null
, or NaN
.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is an ES2015 class
.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input is a string, number, symbol, boolean, null or undefined value.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input is a Promise.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input is an iterable (Map
, Set
, Array
, Generator etc.).
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
Example
1> t.isIterable('string') 2true 3> t.isIterable(new Map()) 4true 5> t.isIterable([]) 6true 7> t.isIterable((function * () {})()) 8true 9> t.isIterable(Promise.resolve()) 10false 11> t.isIterable(Promise) 12false 13> t.isIterable(true) 14false 15> t.isIterable({}) 16false 17> t.isIterable(0) 18false 19> t.isIterable(1.1) 20false 21> t.isIterable(NaN) 22false 23> t.isIterable(Infinity) 24false 25> t.isIterable(function () {}) 26false 27> t.isIterable(Date) 28false 29> t.isIterable() 30false 31> t.isIterable({ then: function () {} }) 32false
boolean
Returns true if the input value is a string. The equivalent of typeof input === 'string'
for use in funcitonal contexts.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is a function. The equivalent of typeof input === 'function'
for use in funcitonal contexts.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
boolean
Returns true if the input value is an async function or method.
Kind: static method of typical
Param | Type | Description |
---|---|---|
input | * | The input to test |
Example
1> t.isAsyncFunction(function () {}) 2false 3> t.isAsyncFunction(new Function()) 4false 5> t.isAsyncFunction(() => {}) 6false 7> t.isAsyncFunction(async function () {}) 8true 9> const AsyncFunction = async function () {}.constructor 10> t.isAsyncFunction(new AsyncFunction()) 11true 12> t.isAsyncFunction(async () => {}) 13true 14> class Command { async execute () {} } 15> t.isAsyncFunction(new Command().execute) 16true
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:
1import t from 'typical' 2import { isNumber } from 'typical'
CommonJS:
1const t = require('typical') 2const { isNumber } = require('typical')
Within a modern browser ECMAScript Module:
1import t from './node_modules/typical/index.js'
© 2014-25 Lloyd Brookes <opensource@75lb.com>.
Test suite by test-runner. Documented by jsdoc-to-markdown.
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
Reason
Found 1/25 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
dependency not pinned by hash detected -- score normalized to 0
Details
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
security policy file not detected
Details
Reason
branch protection not enabled on development/release branches
Details
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
Score
Last Scanned on 2025-06-30
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More