Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

is-what

Package Overview
Dependencies
Maintainers
1
Versions
71
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

is-what - npm Package Compare versions

Comparing version 3.11.0 to 3.11.2

build.js

30

dist/index.cjs.js

@@ -36,3 +36,3 @@ 'use strict';

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/

@@ -48,3 +48,3 @@ function isPlainObject(payload) {

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/

@@ -58,3 +58,3 @@ function isObject(payload) {

* @param {*} payload
* @returns {payload is {}}
* @returns {payload is { [K in any]: never }}
*/

@@ -68,3 +68,3 @@ function isEmptyObject(payload) {

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/

@@ -90,3 +90,3 @@ function isAnyObject(payload) {

* @param {*} payload
* @returns {payload is Function}
* @returns {payload is AnyFunction}
*/

@@ -99,4 +99,4 @@ function isFunction(payload) {

*
* @param {*} payload
* @returns {payload is undefined}
* @param {any} payload
* @returns {payload is any[]}
*/

@@ -143,5 +143,5 @@ function isArray(payload) {

/**
* Returns whether the payload is a number
* Returns whether the payload is a number (but not NaN)
*
* This will return false for NaN
* This will return `false` for `NaN`!!
*

@@ -176,3 +176,3 @@ * @param {*} payload

* @param {*} payload
* @returns {payload is Map}
* @returns {payload is Map<any, any>}
*/

@@ -186,3 +186,3 @@ function isMap(payload) {

* @param {*} payload
* @returns {payload is WeakMap}
* @returns {payload is WeakMap<any, any>}
*/

@@ -196,3 +196,3 @@ function isWeakMap(payload) {

* @param {*} payload
* @returns {payload is Set}
* @returns {payload is Set<any>}
*/

@@ -206,3 +206,3 @@ function isSet(payload) {

* @param {*} payload
* @returns {payload is WeakSet}
* @returns {payload is WeakSet<any>}
*/

@@ -252,3 +252,3 @@ function isWeakSet(payload) {

* @param {*} payload
* @returns {payload is Promise}
* @returns {payload is Promise<any>}
*/

@@ -268,3 +268,3 @@ function isPromise(payload) {

/**
* Returns whether the payload is `NaN` but also a `number`
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
*

@@ -271,0 +271,0 @@ * @param {*} payload

@@ -32,3 +32,3 @@ /**

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/

@@ -44,3 +44,3 @@ function isPlainObject(payload) {

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/

@@ -54,3 +54,3 @@ function isObject(payload) {

* @param {*} payload
* @returns {payload is {}}
* @returns {payload is { [K in any]: never }}
*/

@@ -64,3 +64,3 @@ function isEmptyObject(payload) {

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/

@@ -86,3 +86,3 @@ function isAnyObject(payload) {

* @param {*} payload
* @returns {payload is Function}
* @returns {payload is AnyFunction}
*/

@@ -95,4 +95,4 @@ function isFunction(payload) {

*
* @param {*} payload
* @returns {payload is undefined}
* @param {any} payload
* @returns {payload is any[]}
*/

@@ -139,5 +139,5 @@ function isArray(payload) {

/**
* Returns whether the payload is a number
* Returns whether the payload is a number (but not NaN)
*
* This will return false for NaN
* This will return `false` for `NaN`!!
*

@@ -172,3 +172,3 @@ * @param {*} payload

* @param {*} payload
* @returns {payload is Map}
* @returns {payload is Map<any, any>}
*/

@@ -182,3 +182,3 @@ function isMap(payload) {

* @param {*} payload
* @returns {payload is WeakMap}
* @returns {payload is WeakMap<any, any>}
*/

@@ -192,3 +192,3 @@ function isWeakMap(payload) {

* @param {*} payload
* @returns {payload is Set}
* @returns {payload is Set<any>}
*/

@@ -202,3 +202,3 @@ function isSet(payload) {

* @param {*} payload
* @returns {payload is WeakSet}
* @returns {payload is WeakSet<any>}
*/

@@ -248,3 +248,3 @@ function isWeakSet(payload) {

* @param {*} payload
* @returns {payload is Promise}
* @returns {payload is Promise<any>}
*/

@@ -264,3 +264,3 @@ function isPromise(payload) {

/**
* Returns whether the payload is `NaN` but also a `number`
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
*

@@ -267,0 +267,0 @@ * @param {*} payload

{
"name": "is-what",
"sideEffects": false,
"version": "3.11.0",
"version": "3.11.2",
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",

@@ -10,8 +10,8 @@ "main": "dist/index.cjs.js",

"scripts": {
"ava": "ava",
"test": "jest",
"test-w": "jest --watchAll",
"test": "ava",
"jest": "jest",
"jest-w": "jest --watchAll",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"rollup": "rollup -c ./build/rollup.js",
"build": "npm run lint && npm run rollup && npm run test"
"rollup": "rollup -c ./build.js",
"build": "rm -rf types && rm -rf dist && npm run lint && npm run rollup && npm run test && npm run jest"
},

@@ -51,21 +51,21 @@ "repository": {

"devDependencies": {
"@babel/core": "^7.11.0",
"@babel/core": "^7.11.5",
"@types/babel-core": "^6.25.6",
"@types/jest": "^25.2.3",
"@typescript-eslint/eslint-plugin": "^2.34.0",
"@typescript-eslint/parser": "^2.34.0",
"ava": "^3.11.0",
"@types/jest": "^26.0.12",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"ava": "^3.12.1",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^25.5.1",
"babel-jest": "^26.3.0",
"babel-preset-env": "^1.7.0",
"eslint": "^6.8.0",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint-plugin-tree-shaking": "^1.8.0",
"jest": "^25.5.4",
"jest": "^26.4.2",
"regenerator-runtime": "^0.13.7",
"rollup": "^1.32.1",
"rollup-plugin-typescript2": "^0.27.1",
"rollup": "^2.26.9",
"rollup-plugin-typescript2": "^0.27.2",
"tsconfig-paths": "^3.9.0",
"ts-node": "^8.10.2",
"typescript": "^3.9.7"
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
},

@@ -72,0 +72,0 @@ "ava": {

# is What? 🙉
Very simple &amp; small JS type check functions. It's fully TypeScript supported!
```

@@ -7,3 +9,3 @@ npm i is-what

Very simple &amp; small JS type check functions. It's fully TypeScript supported!
Or for deno available at: `"deno.land/x/is_what"`

@@ -114,3 +116,3 @@ ## Motivation

```TypeScript
```ts
function isNumber (payload: any): payload is number {

@@ -132,3 +134,3 @@ // return boolean

```TypeScript
```ts
function isPlainObject (payload: any): payload is {[key: string]: any}

@@ -145,3 +147,3 @@ function isAnyObject (payload: any): payload is {[key: string]: any}

```TypeScript
```ts
import { isObjectLike } from 'is-what'

@@ -156,3 +158,3 @@ // usage examples:

```TypeScript
```ts
function isObjectLike<T extends object> (payload: any): payload is T {

@@ -159,0 +161,0 @@ return isAnyObject(payload)

@@ -0,1 +1,4 @@

export type AnyFunction = (...args: any[]) => any
export type AnyClass = new (...args: any[]) => any
/**

@@ -35,5 +38,5 @@ * Returns the object type of the given payload

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/
export function isPlainObject (payload: any): payload is { [key: string]: any } {
export function isPlainObject (payload: any): payload is Record<string, any> {
if (getType(payload) !== 'Object') return false

@@ -47,5 +50,5 @@ return payload.constructor === Object && Object.getPrototypeOf(payload) === Object.prototype

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/
export function isObject (payload: any): payload is { [key: string]: any } {
export function isObject (payload: any): payload is Record<string, any> {
return isPlainObject(payload)

@@ -58,5 +61,5 @@ }

* @param {*} payload
* @returns {payload is {}}
* @returns {payload is { [K in any]: never }}
*/
export function isEmptyObject (payload: any): payload is {} {
export function isEmptyObject (payload: any): payload is { [K in any]: never } {
return isPlainObject(payload) && Object.keys(payload).length === 0

@@ -69,5 +72,5 @@ }

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/
export function isAnyObject (payload: any): payload is { [key: string]: any } {
export function isAnyObject (payload: any): payload is Record<string, any> {
return getType(payload) === 'Object'

@@ -85,3 +88,3 @@ }

*/
export function isObjectLike<T extends object> (payload: any): payload is T {
export function isObjectLike<T extends Record<string, any>> (payload: any): payload is T {
return isAnyObject(payload)

@@ -94,5 +97,5 @@ }

* @param {*} payload
* @returns {payload is Function}
* @returns {payload is AnyFunction}
*/
export function isFunction (payload: any): payload is Function {
export function isFunction (payload: any): payload is AnyFunction {
return getType(payload) === 'Function'

@@ -104,4 +107,4 @@ }

*
* @param {*} payload
* @returns {payload is undefined}
* @param {any} payload
* @returns {payload is any[]}
*/

@@ -153,5 +156,5 @@ export function isArray (payload: any): payload is any[] {

/**
* Returns whether the payload is a number
* Returns whether the payload is a number (but not NaN)
*
* This will return false for NaN
* This will return `false` for `NaN`!!
*

@@ -189,3 +192,3 @@ * @param {*} payload

* @param {*} payload
* @returns {payload is Map}
* @returns {payload is Map<any, any>}
*/

@@ -200,3 +203,3 @@ export function isMap (payload: any): payload is Map<any, any> {

* @param {*} payload
* @returns {payload is WeakMap}
* @returns {payload is WeakMap<any, any>}
*/

@@ -211,3 +214,3 @@ export function isWeakMap (payload: any): payload is WeakMap<any, any> {

* @param {*} payload
* @returns {payload is Set}
* @returns {payload is Set<any>}
*/

@@ -222,3 +225,3 @@ export function isSet (payload: any): payload is Set<any> {

* @param {*} payload
* @returns {payload is WeakSet}
* @returns {payload is WeakSet<any>}
*/

@@ -273,3 +276,3 @@ export function isWeakSet (payload: any): payload is WeakSet<any> {

* @param {*} payload
* @returns {payload is Promise}
* @returns {payload is Promise<any>}
*/

@@ -291,3 +294,3 @@ export function isPromise (payload: any): payload is Promise<any> {

/**
* Returns whether the payload is `NaN` but also a `number`
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
*

@@ -341,3 +344,3 @@ * @param {*} payload

*/
export function isType<T extends Function> (payload: any, type: T): payload is T {
export function isType<T extends AnyFunction | AnyClass> (payload: any, type: T): payload is T {
if (!(type instanceof Function)) {

@@ -344,0 +347,0 @@ throw new TypeError('Type must be a function')

@@ -279,1 +279,32 @@ import test from 'ava'

})
test('type related tests', t => {
t.pass()
// const fn: string | ((k: number) => string) = (p) => 'a'
// if (!isFunction(fn)) {
// fn
// }
// const a: Record<string, number> = {}
// a[fn(1)] = fn(2)
// const myArray: string | string[] = ['a', 'b']
// if (!isArray(myArray)) {
// myArray
// }
// const a: Record<string, number> = {}
// a[myArray[1]] = myArray[0]
// const myArray: string | any[] = [1, 2, 'a', 'b']
// if (!isArray(myArray)) {
// myArray
// }
// const a: Record<string, number> = {}
// a[myArray[1]] = myArray[0]
})

@@ -0,1 +1,3 @@

export declare type AnyFunction = (...args: any[]) => any;
export declare type AnyClass = new (...args: any[]) => any;
/**

@@ -26,7 +28,5 @@ * Returns the object type of the given payload

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/
export declare function isPlainObject(payload: any): payload is {
[key: string]: any;
};
export declare function isPlainObject(payload: any): payload is Record<string, any>;
/**

@@ -36,7 +36,5 @@ * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes)

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/
export declare function isObject(payload: any): payload is {
[key: string]: any;
};
export declare function isObject(payload: any): payload is Record<string, any>;
/**

@@ -46,5 +44,7 @@ * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes)

* @param {*} payload
* @returns {payload is {}}
* @returns {payload is { [K in any]: never }}
*/
export declare function isEmptyObject(payload: any): payload is {};
export declare function isEmptyObject(payload: any): payload is {
[K in any]: never;
};
/**

@@ -54,7 +54,5 @@ * Returns whether the payload is an any kind of object (including special classes or objects with different prototypes)

* @param {*} payload
* @returns {payload is {[key: string]: any}}
* @returns {payload is Record<string, any>}
*/
export declare function isAnyObject(payload: any): payload is {
[key: string]: any;
};
export declare function isAnyObject(payload: any): payload is Record<string, any>;
/**

@@ -69,3 +67,3 @@ * Returns whether the payload is an object like a type passed in < >

*/
export declare function isObjectLike<T extends object>(payload: any): payload is T;
export declare function isObjectLike<T extends Record<string, any>>(payload: any): payload is T;
/**

@@ -75,10 +73,10 @@ * Returns whether the payload is a function

* @param {*} payload
* @returns {payload is Function}
* @returns {payload is AnyFunction}
*/
export declare function isFunction(payload: any): payload is Function;
export declare function isFunction(payload: any): payload is AnyFunction;
/**
* Returns whether the payload is an array
*
* @param {*} payload
* @returns {payload is undefined}
* @param {any} payload
* @returns {payload is any[]}
*/

@@ -115,5 +113,5 @@ export declare function isArray(payload: any): payload is any[];

/**
* Returns whether the payload is a number
* Returns whether the payload is a number (but not NaN)
*
* This will return false for NaN
* This will return `false` for `NaN`!!
*

@@ -142,3 +140,3 @@ * @param {*} payload

* @param {*} payload
* @returns {payload is Map}
* @returns {payload is Map<any, any>}
*/

@@ -150,3 +148,3 @@ export declare function isMap(payload: any): payload is Map<any, any>;

* @param {*} payload
* @returns {payload is WeakMap}
* @returns {payload is WeakMap<any, any>}
*/

@@ -158,3 +156,3 @@ export declare function isWeakMap(payload: any): payload is WeakMap<any, any>;

* @param {*} payload
* @returns {payload is Set}
* @returns {payload is Set<any>}
*/

@@ -166,3 +164,3 @@ export declare function isSet(payload: any): payload is Set<any>;

* @param {*} payload
* @returns {payload is WeakSet}
* @returns {payload is WeakSet<any>}
*/

@@ -202,3 +200,3 @@ export declare function isWeakSet(payload: any): payload is WeakSet<any>;

* @param {*} payload
* @returns {payload is Promise}
* @returns {payload is Promise<any>}
*/

@@ -214,3 +212,3 @@ export declare function isPromise(payload: any): payload is Promise<any>;

/**
* Returns whether the payload is `NaN` but also a `number`
* Returns whether the payload is literally the value `NaN` (it's `NaN` and also a `number`)
*

@@ -246,2 +244,2 @@ * @param {*} payload

*/
export declare function isType<T extends Function>(payload: any, type: T): payload is T;
export declare function isType<T extends AnyFunction | AnyClass>(payload: any, type: T): payload is T;

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc