@pacote/is-plain-object
Advanced tools
Comparing version 1.0.0 to 1.0.1
{ | ||
"name": "@pacote/is-plain-object", | ||
"description": "Checks whether the provided object is a plain JavaScript object.", | ||
"version": "1.0.0", | ||
"version": "1.0.1", | ||
"license": "MIT", | ||
@@ -28,3 +28,3 @@ "author": { | ||
"scripts": {}, | ||
"gitHead": "5d3d25330dc6056b3a075c54bf061a8aeae63767" | ||
"gitHead": "3f1744b74c8297cecfb7a40c48755fdc5b2f485d" | ||
} |
@@ -21,21 +21,23 @@ # @pacote/is-plain-object | ||
isPlainObject({}) // true | ||
isPlainObject({ an: 'object' }) // true | ||
// These return true: | ||
isPlainObject({}) | ||
isPlainObject({ an: 'object' }) | ||
isPlainObject(undefined) // false | ||
isPlainObject(null) // false | ||
isPlainObject(false) // false | ||
isPlainObject(true) // false | ||
isPlainObject(NaN) // false | ||
isPlainObject(Infinity) // false | ||
isPlainObject(0) // false | ||
isPlainObject('string') // false | ||
isPlainObject([]) // false | ||
isPlainObject(new ArrayBuffer(0)) // false | ||
isPlainObject(new Date()) // false | ||
isPlainObject(new Map()) // false | ||
isPlainObject(new Promise()) // false | ||
isPlainObject(new Set()) // false | ||
isPlainObject(new WeakMap()) // false | ||
isPlainObject(new WeakSet()) // false | ||
// All of these return false: | ||
isPlainObject(undefined) | ||
isPlainObject(null) | ||
isPlainObject(false) | ||
isPlainObject(true) | ||
isPlainObject(NaN) | ||
isPlainObject(Infinity) | ||
isPlainObject(0) | ||
isPlainObject('string') | ||
isPlainObject([]) | ||
isPlainObject(new ArrayBuffer(0)) | ||
isPlainObject(new Date()) | ||
isPlainObject(new Map()) | ||
isPlainObject(new Promise()) | ||
isPlainObject(new Set()) | ||
isPlainObject(new WeakMap()) | ||
isPlainObject(new WeakSet()) | ||
``` | ||
@@ -42,0 +44,0 @@ |
@@ -74,40 +74,6 @@ import { | ||
test('false for array instances', () => { | ||
expect(isPlainObject(new Float32Array(0))).toBe(false) | ||
expect(isPlainObject(new Float64Array(0))).toBe(false) | ||
expect(isPlainObject(new Int16Array(0))).toBe(false) | ||
expect(isPlainObject(new Int16Array(0))).toBe(false) | ||
expect(isPlainObject(new Int32Array(0))).toBe(false) | ||
expect(isPlainObject(new Int32Array(0))).toBe(false) | ||
expect(isPlainObject(new Int8Array(0))).toBe(false) | ||
expect(isPlainObject(new Uint16Array(0))).toBe(false) | ||
expect(isPlainObject(new Uint32Array(0))).toBe(false) | ||
expect(isPlainObject(new Uint8Array(0))).toBe(false) | ||
expect(isPlainObject(new Uint8ClampedArray(0))).toBe(false) | ||
}) | ||
test('false for instances of Symbol', () => { | ||
test('false for Symbols', () => { | ||
expect(isPlainObject(Symbol())).toBe(false) | ||
}) | ||
test('false for instances of Map', () => { | ||
expect(isPlainObject(new Set())).toBe(false) | ||
}) | ||
test('false for instances of WeakMap', () => { | ||
expect(isPlainObject(new WeakSet())).toBe(false) | ||
}) | ||
test('false for instances of Map', () => { | ||
expect(isPlainObject(new Map())).toBe(false) | ||
}) | ||
test('false for instances of WeakMap', () => { | ||
expect(isPlainObject(new WeakMap())).toBe(false) | ||
}) | ||
test('false for instances of Date', () => { | ||
expect(isPlainObject(new Date())).toBe(false) | ||
}) | ||
test('false for instances of RegExp', () => { | ||
@@ -118,8 +84,26 @@ expect(isPlainObject(/a/)).toBe(false) | ||
test('false for instances of ArrayBuffer', () => { | ||
expect(isPlainObject(new ArrayBuffer(0))).toBe(false) | ||
test('false for Promises', () => { | ||
expect(isPlainObject(Promise.resolve())).toBe(false) | ||
}) | ||
test('false for promises', () => { | ||
expect(isPlainObject(new Promise(() => null))).toBe(false) | ||
test.each([ | ||
['ArrayBuffer', ArrayBuffer], | ||
['Date', Date], | ||
['Float32Array', Float32Array], | ||
['Float64Array', Float64Array], | ||
['Int16Array', Int16Array], | ||
['Int16Array', Int16Array], | ||
['Int32Array', Int32Array], | ||
['Int32Array', Int32Array], | ||
['Int8Array', Int8Array], | ||
['Map', Map], | ||
['Set', Set], | ||
['Uint16Array', Uint16Array], | ||
['Uint32Array', Uint32Array], | ||
['Uint8Array', Uint8Array], | ||
['Uint8ClampedArray', Uint8ClampedArray], | ||
['WeakMap', WeakMap], | ||
['WeakSet', WeakSet] | ||
])('false for instances of %s', (_, ArrayClass) => { | ||
expect(isPlainObject(new ArrayClass())).toBe(false) | ||
}) |
51
8105
152