Comparing version 3.14.0 to 3.14.1
@@ -36,3 +36,3 @@ 'use strict'; | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
@@ -48,3 +48,3 @@ function isPlainObject(payload) { | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
@@ -64,6 +64,15 @@ function isObject(payload) { | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is PlainObject} | ||
*/ | ||
function isFullObject(payload) { | ||
return isPlainObject(payload) && Object.keys(payload).length > 0; | ||
} | ||
/** | ||
* Returns whether the payload is an any kind of object (including special classes or objects with different prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
@@ -337,2 +346,3 @@ function isAnyObject(payload) { | ||
exports.isFullArray = isFullArray; | ||
exports.isFullObject = isFullObject; | ||
exports.isFullString = isFullString; | ||
@@ -339,0 +349,0 @@ exports.isFunction = isFunction; |
@@ -32,3 +32,3 @@ /** | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
@@ -44,3 +44,3 @@ function isPlainObject(payload) { | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
@@ -60,6 +60,15 @@ function isObject(payload) { | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is PlainObject} | ||
*/ | ||
function isFullObject(payload) { | ||
return isPlainObject(payload) && Object.keys(payload).length > 0; | ||
} | ||
/** | ||
* Returns whether the payload is an any kind of object (including special classes or objects with different prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
@@ -321,2 +330,2 @@ function isAnyObject(payload) { | ||
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 }; | ||
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyArray, isEmptyObject, isEmptyString, isError, isFile, isFullArray, isFullObject, 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.14.0", | ||
"version": "3.14.1", | ||
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.", | ||
@@ -15,3 +15,4 @@ "main": "dist/index.cjs.js", | ||
"rollup": "rollup -c ./build.js", | ||
"build": "rimraf types && rimraf dist && npm run lint && npm run rollup && npm run test && npm run jest" | ||
"build": "rimraf types && rimraf dist && npm run lint && npm run rollup && npm run test && npm run jest", | ||
"release": "npm run build && np" | ||
}, | ||
@@ -63,2 +64,3 @@ "repository": { | ||
"jest": "^26.6.3", | ||
"np": "^7.4.0", | ||
"prettier": "^2.2.1", | ||
@@ -81,3 +83,7 @@ "regenerator-runtime": "^0.13.7", | ||
] | ||
}, | ||
"np": { | ||
"yarn": false, | ||
"branch": "production" | ||
} | ||
} |
@@ -34,2 +34,3 @@ import test from 'ava' | ||
isOneOf, | ||
isFullObject, | ||
} from '../src/index' | ||
@@ -46,4 +47,9 @@ | ||
t.is(isObject({}), true) | ||
t.is(isEmptyObject({}), true) | ||
t.is(isFullObject({0: ''}), true) | ||
t.is(isFullObject({'': ''}), true) | ||
t.is(isObject(new Object()), true) | ||
t.is(isArray([]), true) | ||
t.is(isEmptyArray([]), true) | ||
t.is(isFullArray(['']), true) | ||
t.is(isArray(new Array()), true) | ||
@@ -127,3 +133,3 @@ t.is(isString(''), true) | ||
t.is(isEmptyArray(new Array(0)), true) | ||
t.is(isEmptyArray(new Array(1)), false) | ||
@@ -147,7 +153,7 @@ t.is(isEmptyArray([undefined]), false) | ||
t.is(isFullArray(['']), true) | ||
t.is(isFullArray([]), false) | ||
t.is(isFullArray(new Array()), false) | ||
t.is(isFullArray(new Array(0)), false) | ||
t.is(isFullArray(null), false) | ||
@@ -353,3 +359,3 @@ t.is(isFullArray(new Date()), false) | ||
// const a: Record<string, number> = {} | ||
// a[fn(1)] = fn(2) | ||
@@ -363,3 +369,3 @@ | ||
// const a: Record<string, number> = {} | ||
// a[myArray[1]] = myArray[0] | ||
@@ -373,5 +379,5 @@ | ||
// const a: Record<string, number> = {} | ||
// a[myArray[1]] = myArray[0] | ||
}) |
export declare type AnyFunction = (...args: any[]) => any; | ||
export declare type AnyAsyncFunction = (...args: any[]) => Promise<any>; | ||
export declare type AnyClass = new (...args: any[]) => any; | ||
export declare type PlainObject = Record<string | number | symbol, any>; | ||
declare type TypeGuard<A, B extends A> = (payload: A) => payload is B; | ||
@@ -30,5 +31,5 @@ /** | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
export declare function isPlainObject(payload: any): payload is Record<string, any>; | ||
export declare function isPlainObject(payload: any): payload is PlainObject; | ||
/** | ||
@@ -38,5 +39,5 @@ * Returns whether the payload is a plain JavaScript object (excluding special classes or objects with other prototypes) | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
export declare function isObject(payload: any): payload is Record<string, any>; | ||
export declare function isObject(payload: any): payload is PlainObject; | ||
/** | ||
@@ -52,8 +53,15 @@ * Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is PlainObject} | ||
*/ | ||
export declare function isFullObject(payload: any): payload is PlainObject; | ||
/** | ||
* Returns whether the payload is an any kind of object (including special classes or objects with different prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is Record<string, any>} | ||
* @returns {payload is PlainObject} | ||
*/ | ||
export declare function isAnyObject(payload: any): payload is Record<string, any>; | ||
export declare function isAnyObject(payload: any): payload is PlainObject; | ||
/** | ||
@@ -68,3 +76,3 @@ * Returns whether the payload is an object like a type passed in < > | ||
*/ | ||
export declare function isObjectLike<T extends Record<string, any>>(payload: any): payload is T; | ||
export declare function isObjectLike<T extends PlainObject>(payload: any): payload is T; | ||
/** | ||
@@ -71,0 +79,0 @@ * Returns whether the payload is a function (regular or async) |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
62310
1753
22