Installations
npm install is-type-of
Developer
node-modules
Developer Guide
Module System
ESM
Min. Node Version
Typescript Support
Yes
Node Version
18.18.2
NPM Version
9.8.1
Statistics
123 Stars
61 Commits
13 Forks
14 Watching
2 Branches
27 Contributors
Updated on 21 Oct 2024
Languages
TypeScript (78.87%)
JavaScript (21.13%)
Total Downloads
Cumulative downloads
Total Downloads
58,066,799
Last day
-11.8%
71,506
Compared to previous day
Last week
2.7%
486,043
Compared to previous week
Last month
10.6%
1,989,011
Compared to previous month
Last year
35.6%
17,499,040
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
is-type-of
Complete type checking for Node
Features
- 🔒 Useful Type Checking,including Primitive, Standard Object, Node Object
- ✨ Typescript Support
- 🚪 Typescript Type Guard Support
Install
1npm install is-type-of
Usage
Use ES Module import
1import is from 'is-type-of'; 2import { isArray } from 'is-type-of'; 3 4isArray([]); // => true 5is.array([]); // => true
Compatible With
1const is = require('is-type-of'); 2 3is.array([1]); // => true 4is.primitive(true); // => true 5is.primitive({}); // => false 6is.generatorFunction(function * () {}); // => true 7is.long(Math.pow(2, 33)); // => true 8is.double(0); // => false
Use Type Guard
1import { isArray } from 'is-type-of'; 2 3function checkArray(arr: string[] | string) { 4 // => parameter) arr: string | string[] 5 if (isArray(arr)) { 6 // => (parameter) arr: string[] 7 arr.forEach(console.log); 8 } 9}
API Document
Primitive
isString
Returns true if val
is string, not String
object.
See Also is.string
isNumber
Returns true if val
is number, not Number
object.
See Also is.number
isBoolean
Returns true if val
is boolean, not Boolean
object.
See Also is.boolean
isBigInt
Returns true if val
is bigint.
See Also is.bigInt
isSymbol
Returns true if val
is symbol.
See Also is.symbol
isUndefined
Returns true if val
is undefined.
See Also is.undefined
isNull
Returns true if val
is null.
See Also is.null
isNullable
Returns true if val
is null or undefined.
See Also is.nullable
isPrimitive
Returns true if val
is primitive.
See Also is.primitive
isInteger
Returns true if val
is integer.
See Also is.integer
isInteger32
Returns true if val
is integer, and between -2 ** 31
and 2 ** 31 - 1
.
See Also is.integer32
isLong
Returns true if val
is integer, and < -2 ** 31
, and > 2 ** 31 - 1
.
See Also is.long
isSafeInteger
Returns true if val
is integer, and between -(2 ** 53 - 1)
and 2 ** 53 - 1
.
See Also is.safeInteger
isDouble
Returns true if val
is Double.
See Also is.double
isNaN
Returns true if val
is NaN.
See Also is.NaN
isFinite
Returns true if val
is finite.
See Also is.finite
Standard Object
API Documentation
isArray
Returns true if val
is array, it won't check items of array.
See Also is.array
isFunction
Returns true if val
is function.
See Also is.function
isGeneratorFunction
Returns true if val
is generator function.
See Also is.generatorFunction
isAsyncFunction
Returns true if val
is async function.
See Also is.asyncFunction
isAsyncGeneratorFunction
Returns true if val
is async generator function.
See Also is.asyncGeneratorFunction
isObject
Returns true if val
is object.
See Also is.object
isClass
Returns true if val
is class.
Note: "class" is supported in ECMAScript 6, and if the code is using some compiler or transpiler, the checking might fail.
See Also is.class
isRegExp
Returns true if val
is regular expression.
See Also is.regExp
isDate
Returns true if val
is instance of Date.
See Also is.date
isError
Returns true if val
is instance of Error.
See Also is.error
isGenerator
Returns true if val
is generator.
See Also is.generator
isPromise
Returns true if val
is promise.
See Also is.promise
isPromiseLike
Returns true if val
is like promise, if the object has then
property, the checking will pass.
See Also is.promiseLike
Node Object
isBuffer
Returns true if val
is buffer.
See Also is.buffer
isStream
Returns true if val
is stream.
See Also is.stream
isReadable
Returns true if val
is readable stream.
See Also is.readable
isWritable
Returns true if val
is write stream.
See Also is.writable
isDuplex
Returns true if val
is duplex stream.
See Also is.duplex
External Object
isLongObject
returns true if val is LongObject
LongObject is from npm package long
See Also is.longObject
Thanks
License
No vulnerabilities found.
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
Found 6/25 approved changesets -- score normalized to 2
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Warn: no topLevel permission defined: .github/workflows/ci.yml:1
- Warn: no topLevel permission defined: .github/workflows/release.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 18 are checked with a SAST tool
Score
4.3
/10
Last Scanned on 2024-11-18
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