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.12.0 to 3.13.0

6

dist/index.cjs.js

@@ -293,4 +293,5 @@ 'use strict';

*/
function isNullOrUndefined(payload) {
return isNull(payload) || isUndefined(payload);
var isNullOrUndefined = isOneOf(isNull, isUndefined);
function isOneOf(a, b, c, d, e) {
return function (value) { return a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value)); };
}

@@ -341,2 +342,3 @@ /**

exports.isObjectLike = isObjectLike;
exports.isOneOf = isOneOf;
exports.isPlainObject = isPlainObject;

@@ -343,0 +345,0 @@ exports.isPrimitive = isPrimitive;

@@ -289,4 +289,5 @@ /**

*/
function isNullOrUndefined(payload) {
return isNull(payload) || isUndefined(payload);
var isNullOrUndefined = isOneOf(isNull, isUndefined);
function isOneOf(a, b, c, d, e) {
return function (value) { return a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value)); };
}

@@ -316,2 +317,2 @@ /**

export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullString, isFunction, isMap, isNaNValue, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullString, isFunction, isMap, isNaNValue, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isOneOf, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet };
{
"name": "is-what",
"sideEffects": false,
"version": "3.12.0",
"version": "3.13.0",
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.",

@@ -48,23 +48,22 @@ "main": "dist/index.cjs.js",

"homepage": "https://github.com/mesqueeb/is-what#readme",
"dependencies": {},
"devDependencies": {
"@babel/core": "^7.12.3",
"@babel/core": "^7.12.17",
"@types/babel-core": "^6.25.6",
"@types/jest": "^26.0.15",
"@typescript-eslint/eslint-plugin": "^4.7.0",
"@typescript-eslint/parser": "^4.7.0",
"ava": "^3.13.0",
"@types/jest": "^26.0.20",
"@typescript-eslint/eslint-plugin": "^4.15.1",
"@typescript-eslint/parser": "^4.15.1",
"ava": "^3.15.0",
"babel-core": "^7.0.0-bridge.0",
"babel-jest": "^26.6.3",
"babel-preset-env": "^1.7.0",
"eslint": "^7.13.0",
"eslint-config-prettier": "^6.15.0",
"eslint": "^7.20.0",
"eslint-config-prettier": "^7.2.0",
"eslint-plugin-tree-shaking": "^1.8.0",
"jest": "^26.6.3",
"regenerator-runtime": "^0.13.7",
"rollup": "^2.33.1",
"rollup-plugin-typescript2": "^0.29.0",
"rollup": "^2.39.0",
"rollup-plugin-typescript2": "^0.30.0",
"ts-node": "^9.1.1",
"tsconfig-paths": "^3.9.0",
"ts-node": "^9.0.0",
"typescript": "^4.0.5"
"typescript": "^4.1.5"
},

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

@@ -5,2 +5,4 @@ export type AnyFunction = (...args: any[]) => any

type TypeGuard<A, B extends A> = (payload: A) => payload is B;
/**

@@ -327,4 +329,10 @@ * Returns the object type of the given payload

*/
export function isNullOrUndefined (payload: any): payload is null | undefined {
return isNull(payload) || isUndefined(payload)
export const isNullOrUndefined = isOneOf(isNull, isUndefined);
export function isOneOf<A, B extends A, C extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>): TypeGuard<A, B | C>;
export function isOneOf<A, B extends A, C extends A, D extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>): TypeGuard<A, B | C | D>;
export function isOneOf<A, B extends A, C extends A, D extends A, E extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>): TypeGuard<A, B | C | D | E>;
export function isOneOf<A, B extends A, C extends A, D extends A, E extends A, F extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>, e: TypeGuard<A, F>): TypeGuard<A, B | C | D | E | F>;
export function isOneOf(a: AnyFunction, b: AnyFunction, c?: AnyFunction, d?: AnyFunction, e?: AnyFunction): (value: unknown) => boolean {
return (value) => a(value) || b(value) || (!!c && c(value)) || (!!d && d(value)) || (!!e && e(value));
}

@@ -331,0 +339,0 @@

@@ -33,2 +33,3 @@ import test from 'ava'

isEmptyObject,
isOneOf,
} from '../src/index'

@@ -317,2 +318,26 @@

test('isOneOf', t => {
t.is(isOneOf(isString, isNumber)('_'), true)
t.is(isOneOf(isString, isNumber)(1), true)
t.is(isOneOf(isString, isNumber)(undefined), false)
t.is(isOneOf(isString, isNumber, isBoolean)('_'), true)
t.is(isOneOf(isString, isNumber, isBoolean)(1), true)
t.is(isOneOf(isString, isNumber, isBoolean)(true), true)
t.is(isOneOf(isString, isNumber, isBoolean)(undefined), false)
t.is(isOneOf(isString, isNumber, isBoolean, isArray)('_'), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray)(1), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray)(true), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray)([]), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray)(undefined), false)
t.is(isOneOf(isString, isNumber, isBoolean, isArray, isPlainObject)('_'), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray, isPlainObject)(1), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray, isPlainObject)(true), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray, isPlainObject)([]), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray, isPlainObject)({}), true)
t.is(isOneOf(isString, isNumber, isBoolean, isArray, isPlainObject)(undefined), false)
})
test('type related tests', t => {

@@ -319,0 +344,0 @@ t.pass()

export declare type AnyFunction = (...args: any[]) => any;
export declare type AnyAsyncFunction = (...args: any[]) => Promise<any>;
export declare type AnyClass = new (...args: any[]) => any;
declare type TypeGuard<A, B extends A> = (payload: A) => payload is B;
/**

@@ -227,3 +228,7 @@ * Returns the object type of the given payload

*/
export declare function isNullOrUndefined(payload: any): payload is null | undefined;
export declare const isNullOrUndefined: TypeGuard<any, null | undefined>;
export declare function isOneOf<A, B extends A, C extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>): TypeGuard<A, B | C>;
export declare function isOneOf<A, B extends A, C extends A, D extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>): TypeGuard<A, B | C | D>;
export declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>): TypeGuard<A, B | C | D | E>;
export declare function isOneOf<A, B extends A, C extends A, D extends A, E extends A, F extends A>(a: TypeGuard<A, B>, b: TypeGuard<A, C>, c: TypeGuard<A, D>, d: TypeGuard<A, E>, e: TypeGuard<A, F>): TypeGuard<A, B | C | D | E | F>;
/**

@@ -241,1 +246,2 @@ * Does a generic check to check that the given payload is of a given type.

export declare function isType<T extends AnyFunction | AnyClass>(payload: any, type: T): payload is T;
export {};
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