is-type-of
Advanced tools
Comparing version 1.4.0 to 2.0.0
{ | ||
"name": "is-type-of", | ||
"version": "1.4.0", | ||
"version": "2.0.0", | ||
"description": "complete type checking for node", | ||
"main": "index.js", | ||
"main": "dist/index.js", | ||
"typings": "dist/index.d.ts", | ||
"files": [ | ||
"dist" | ||
], | ||
"scripts": { | ||
"test": "tsd && egg-bin test", | ||
"ci": "tsd && egg-bin cov", | ||
"lint": "echo 'ignore'" | ||
"prepublishOnly": "npm run tsc:clean && npm run tsc:prod", | ||
"tsc": "tsc -b ./tsconfig.json", | ||
"tsc:prod": "tsc -b ./tsconfig.prod.json", | ||
"tsc:clean": "tsc -b --clean", | ||
"test": "egg-bin test", | ||
"ci": "npm run lint && egg-bin cov", | ||
"lint": "eslint . --ext .ts" | ||
}, | ||
@@ -15,6 +23,5 @@ "repository": { | ||
}, | ||
"files": [ | ||
"index.js", | ||
"index.d.ts" | ||
], | ||
"node": { | ||
"engines": ">= 16.0.0" | ||
}, | ||
"keywords": [ | ||
@@ -32,8 +39,5 @@ "typeof", | ||
"homepage": "https://github.com/node-modules/is-type-of", | ||
"dependencies": { | ||
"core-util-is": "^1.0.2", | ||
"is-class-hotfix": "~0.0.6", | ||
"isstream": "~0.1.2" | ||
}, | ||
"devDependencies": { | ||
"@eggjs/tsconfig": "^1.3.3", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^18.16.3", | ||
@@ -43,6 +47,9 @@ "beautify-benchmark": "^0.2.4", | ||
"egg-bin": "^6.4.0", | ||
"eslint": "^8.45.0", | ||
"eslint-config-egg": "^12.2.1", | ||
"long": "^3.2.0", | ||
"semver": "^5.4.1", | ||
"tsd": "^0.28.1" | ||
"ts-expect": "^1.3.0", | ||
"typescript": "^5.1.6" | ||
} | ||
} |
272
README.md
is-type-of | ||
========== | ||
complete type checking for node, extend [core-util-is](https://github.com/isaacs/core-util-is) | ||
Complete type checking for Node | ||
dependencies: | ||
## Features | ||
- [core-util-is](https://github.com/isaacs/core-util-is) | ||
- [is-stream](https://github.com/rvagg/isstream) | ||
- [is-class](https://github.com/miguelmota/is-class) | ||
- 🔒 Usefull Type Checking,including Primitive, Standard Object, Node Object | ||
- ✨ Typescript Support | ||
- 🚪 Typescript Type Guard Support | ||
@@ -18,7 +18,19 @@ ## Install | ||
## Example | ||
## Usage | ||
Use ES Module import | ||
```typescript | ||
import is from 'is-type-of'; | ||
import { isArray } from 'is-type-of'; | ||
isArray([]); // => true | ||
is.array(); // => true | ||
``` | ||
var is = require('is-type-of'); | ||
Compatible With | ||
```javascript | ||
const is = require('is-type-of'); | ||
is.array([1]); // => true | ||
@@ -32,76 +44,250 @@ is.primitive(true); // => true | ||
## API | ||
Use Type Guard | ||
### From [core-util-is](https://github.com/isaacs/core-util-is) | ||
```typescript | ||
import { isArray } from 'is-type-of'; | ||
#### is.array(arr) | ||
function checkArray(arr: string[] | string) { | ||
// => parameter) arr: string | string[] | ||
if (isArray(arr)) { | ||
// => (parameter) arr: string[] | ||
arr.forEach(console.log); | ||
} | ||
} | ||
``` | ||
#### is.boolean(bool) | ||
#### is.null(null) | ||
## API Document | ||
#### is.nullOrUndefined(null) | ||
### Primitive | ||
#### is.number(num) | ||
#### isString | ||
#### is.string(str) | ||
Returns true if `val` is string, not `String` object. | ||
#### is.symbol(sym) | ||
See Also `is.string` | ||
#### is.undefined(undef) | ||
#### isNumber | ||
#### is.regExp(reg) | ||
Returns true if `val` is number, not `Number` object. | ||
#### is.object(obj) | ||
See Also `is.number` | ||
#### is.date(date) | ||
#### isBoolean | ||
#### is.error(err) | ||
Returns true if `val` is boolean, not `Boolean` object. | ||
#### is.function(fn) | ||
See Also `is.boolean` | ||
#### is.primitive(prim) | ||
#### isBigInt | ||
#### is.buffer(buf) | ||
Returns true if `val` is bigint. | ||
### from [is-stream](https://github.com/rvagg/isstream) | ||
See Also `is.bigInt` | ||
#### is.stream(stream) | ||
#### isSymbol | ||
#### is.readableStream(readable) | ||
Returns true if `val` is symbol. | ||
#### is.writableStream(writable) | ||
See Also `is.symbol` | ||
#### is.duplexStream(duplex) | ||
#### isUndefined | ||
### from [is-class](https://github.com/miguelmota/is-class) | ||
Returns true if `val` is undefined. | ||
#### is.class(obj) | ||
See Also `is.undefined` | ||
### Extend API | ||
#### isNull | ||
#### is.finite(num) | ||
Returns true if `val` is null. | ||
#### is.NaN(NaN) | ||
See Also `is.null` | ||
#### is.generator(gen) | ||
#### isNullable | ||
#### is.generatorFunction(fn) | ||
Returns true if `val` is null or undefined. | ||
#### is.promise(fn) | ||
See Also `is.nullable` | ||
#### is.int(int) | ||
#### isPrimitive | ||
#### is.double(double) | ||
Returns true if `val` is primitive. | ||
#### is.int32(int) | ||
See Also `is.primitive` | ||
#### is.long(long) | ||
#### isInteger | ||
#### is.Long(Long) | ||
Returns true if `val` is integer. | ||
* Support [Long](https://github.com/dcodeIO/Long.js) instance. | ||
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](https://github.com/dcodeIO/long.js) | ||
See Also `is.longObject` | ||
## Thanks | ||
- [core-util-is](https://github.com/isaacs/core-util-is) | ||
- [is-stream](https://github.com/rvagg/isstream) | ||
- [is-class](https://github.com/miguelmota/is-class) | ||
## License | ||
MIT |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50260
0
17
1152
292
12
1
- Removedcore-util-is@^1.0.2
- Removedis-class-hotfix@~0.0.6
- Removedisstream@~0.1.2
- Removedcore-util-is@1.0.3(transitive)
- Removedis-class-hotfix@0.0.6(transitive)
- Removedisstream@0.1.2(transitive)