Socket
Socket
Sign inDemoInstall

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.2 to 3.11.3

1

.eslintrc.js

@@ -16,3 +16,4 @@ // npm i -D @typescript-eslint/eslint-plugin @typescript-eslint/parser eslint eslint-config-prettier eslint-plugin-tree-shaking

'tree-shaking/no-side-effects-in-initialization': 'error',
'@typescript-eslint/explicit-module-boundary-types': 'off'
},
}

5

dist/index.cjs.js

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

/**
* Returns whether the payload is a function
* Returns whether the payload is a function (regular or async)
*

@@ -90,3 +90,4 @@ * @param {*} payload

function isFunction(payload) {
return getType(payload) === 'Function';
var type = getType(payload);
return type === 'Function' || type === 'AsyncFunction';
}

@@ -93,0 +94,0 @@ /**

@@ -79,3 +79,3 @@ /**

/**
* Returns whether the payload is a function
* Returns whether the payload is a function (regular or async)
*

@@ -86,3 +86,4 @@ * @param {*} payload

function isFunction(payload) {
return getType(payload) === 'Function';
var type = getType(payload);
return type === 'Function' || type === 'AsyncFunction';
}

@@ -89,0 +90,0 @@ /**

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

@@ -50,21 +50,21 @@ "main": "dist/index.cjs.js",

"devDependencies": {
"@babel/core": "^7.11.5",
"@babel/core": "^7.12.3",
"@types/babel-core": "^6.25.6",
"@types/jest": "^26.0.12",
"@typescript-eslint/eslint-plugin": "^4.0.1",
"@typescript-eslint/parser": "^4.0.1",
"ava": "^3.12.1",
"@types/jest": "^26.0.15",
"@typescript-eslint/eslint-plugin": "^4.6.1",
"@typescript-eslint/parser": "^4.6.1",
"ava": "^3.13.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.3.0",
"babel-jest": "^26.6.3",
"babel-preset-env": "^1.7.0",
"eslint": "^7.8.1",
"eslint-config-prettier": "^6.11.0",
"eslint": "^7.12.1",
"eslint-config-prettier": "^6.15.0",
"eslint-plugin-tree-shaking": "^1.8.0",
"jest": "^26.4.2",
"jest": "^26.6.3",
"regenerator-runtime": "^0.13.7",
"rollup": "^2.26.9",
"rollup-plugin-typescript2": "^0.27.2",
"rollup": "^2.33.1",
"rollup-plugin-typescript2": "^0.29.0",
"tsconfig-paths": "^3.9.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.2"
"typescript": "^4.0.5"
},

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

export type AnyFunction = (...args: any[]) => any
export type AnyAsyncFunction = (...args: any[]) => Promise<any>
export type AnyClass = new (...args: any[]) => any

@@ -89,3 +90,3 @@

/**
* Returns whether the payload is a function
* Returns whether the payload is a function (regular or async)
*

@@ -96,3 +97,4 @@ * @param {*} payload

export function isFunction (payload: any): payload is AnyFunction {
return getType(payload) === 'Function'
const type = getType(payload)
return type === 'Function' || type === 'AsyncFunction'
}

@@ -99,0 +101,0 @@

@@ -44,6 +44,2 @@ import test from 'ava'

t.is(isObject(new Object()), true)
t.is(
isFunction(_ => {}),
true
)
t.is(isArray([]), true)

@@ -80,3 +76,2 @@ t.is(isArray(new Array()), true)

t.is(isObject(NaN), false)
t.is(isFunction(NaN), false)
t.is(isArray(NaN), false)

@@ -96,2 +91,13 @@ t.is(isString(NaN), false)

test('isFunction', t => {
t.is(isFunction(NaN), false)
t.is(isFunction(() => {}), true)
t.is(isFunction(function () {}), true)
t.is(isFunction(async () => {}), true)
t.is(isFunction(async function () {}), true)
const _ = { fn: () => {}, method () {} }
t.is(isFunction(_.fn), true)
t.is(isFunction(_.method), true)
})
test('isEmptyObject', t => {

@@ -141,3 +147,3 @@ t.is(isEmptyObject({}), true)

t.is(
isNaNValue(_ => {}),
isNaNValue(() => {}),
false

@@ -184,3 +190,3 @@ )

t.is(
isPrimitive(_ => {}),
isPrimitive(() => {}),
false

@@ -195,7 +201,10 @@ )

test('Generic isType', t => {
// -----------------------------
// This is correct old fashion syntax for classes, if this is missing
function MyClass () {}
// This is correct old fashion syntax for classes, if this is missing
MyClass.prototype.constructor = MyClass
class MyOtherClass {}
// @ts-ignore
const myClass = new MyClass()
// -----------------------------
class MyOtherClass { constructor() {} }
// this is expected behaviour

@@ -213,3 +222,3 @@ t.is(isType('', String), true)

t.is(
isType(_ => {}, Function),
isType(() => {}, Function),
true

@@ -238,8 +247,11 @@ )

test('isObject vs isAnyObject', t => {
// -----------------------------
// This is correct old fashion syntax for classes, if this is missing
function MyClass () {}
// This is correct old fashion syntax for classes, if this is missing
MyClass.prototype.constructor = MyClass
// @ts-ignore
const myClass = new MyClass()
class MyClass2 {}
const myClass2 = new MyClass()
// -----------------------------
class MyClass2 { constructor() {} }
const myClass2 = new MyClass2()
const mySpecialObject = {}

@@ -246,0 +258,0 @@ Object.setPrototypeOf(mySpecialObject, {

{
"compilerOptions": {
"baseUrl": ".",
"strict": true,
"declaration": true,

@@ -5,0 +6,0 @@ "declarationDir": "./types/"

export declare type AnyFunction = (...args: any[]) => any;
export declare type AnyAsyncFunction = (...args: any[]) => Promise<any>;
export declare type AnyClass = new (...args: any[]) => any;

@@ -65,3 +66,3 @@ /**

/**
* Returns whether the payload is a function
* Returns whether the payload is a function (regular or async)
*

@@ -68,0 +69,0 @@ * @param {*} payload

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