Comparing version 3.9.1 to 3.10.0
@@ -53,2 +53,11 @@ 'use strict'; | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is {}} | ||
*/ | ||
function isEmptyObject(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) | ||
@@ -299,2 +308,3 @@ * | ||
exports.isDate = isDate; | ||
exports.isEmptyObject = isEmptyObject; | ||
exports.isEmptyString = isEmptyString; | ||
@@ -301,0 +311,0 @@ exports.isError = isError; |
@@ -49,2 +49,11 @@ /** | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is {}} | ||
*/ | ||
function isEmptyObject(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) | ||
@@ -289,2 +298,2 @@ * | ||
export { getType, isAnyObject, isArray, isBlob, isBoolean, isDate, isEmptyString, isError, isFile, 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, isEmptyObject, isEmptyString, isError, isFile, isFullString, isFunction, isMap, isNaNValue, isNull, isNullOrUndefined, isNumber, isObject, isObjectLike, isPlainObject, isPrimitive, isPromise, isRegExp, isSet, isString, isSymbol, isType, isUndefined, isWeakMap, isWeakSet }; |
{ | ||
"name": "is-what", | ||
"sideEffects": false, | ||
"version": "3.9.1", | ||
"version": "3.10.0", | ||
"description": "JS type check (TypeScript supported) functions like `isPlainObject() isArray()` etc. A simple & small integration.", | ||
@@ -6,0 +6,0 @@ "main": "dist/index.cjs.js", |
@@ -53,2 +53,12 @@ /** | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is {}} | ||
*/ | ||
export function isEmptyObject (payload: any): payload is {} { | ||
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) | ||
@@ -55,0 +65,0 @@ * |
@@ -30,2 +30,3 @@ import test from 'ava' | ||
isNaNValue, | ||
isEmptyObject, | ||
} from '../src/index' | ||
@@ -93,2 +94,19 @@ | ||
test('isEmptyObject', t => { | ||
t.is(isEmptyObject({}), true) | ||
t.is(isEmptyObject(new Object()), true) | ||
t.is(isEmptyObject('{}'), false) | ||
t.is(isEmptyObject('{}'), false) | ||
t.is(isEmptyObject(null), false) | ||
t.is(isEmptyObject(new Date()), false) | ||
t.is(isEmptyObject(new Error('')), false) | ||
t.is(isEmptyObject(new Date()), false) | ||
t.is(isEmptyObject(Symbol()), false) | ||
t.is(isEmptyObject(new Map()), false) | ||
t.is(isEmptyObject(new WeakMap()), false) | ||
t.is(isEmptyObject(new Set()), false) | ||
t.is(isEmptyObject(new WeakSet()), false) | ||
}) | ||
test('NaN tests', t => { | ||
@@ -95,0 +113,0 @@ t.is(isNaNValue(NaN), true) |
@@ -41,2 +41,9 @@ /** | ||
/** | ||
* Returns whether the payload is a an empty object (excluding special classes or objects with other prototypes) | ||
* | ||
* @param {*} payload | ||
* @returns {payload is {}} | ||
*/ | ||
export declare function isEmptyObject(payload: any): payload is {}; | ||
/** | ||
* Returns whether the payload is an any kind of object (including special classes or objects with different prototypes) | ||
@@ -43,0 +50,0 @@ * |
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
57447
1653