is-object-empty2 1.0.7 → 1.0.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +15 -3
- package/index.js +5 -1
- package/package.json +7 -1
package/README.md
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
<img src="https://img.shields.io/badge/License-MIT-yellow.svg">
|
|
6
6
|
</p>
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
* ✨ Simple yet robust NPM package that checks if a value is a plain empty object in `JavaScript` and `TypeScript`.
|
|
9
|
+
* ♻️ Works seamlessly with `CommonJS`, `ESM` and `TypeScript`
|
|
9
10
|
|
|
10
11
|
- Returns `true` **only** for plain objects with no own enumerable properties (`{}` or `Object.create(null)`).
|
|
11
12
|
- Returns `false` for `Arrays`, `null`, `undefined`, `functions`, `symbols`, `BigInt`, objects with keys or object with at least one own enumerable property (string or symbol)
|
|
@@ -29,7 +30,7 @@ $ npm i is-object-empty2
|
|
|
29
30
|
- Returns `true` only for empty objects (`{}`), and `false` for arrays, null, undefined, or objects with keys.
|
|
30
31
|
- See examples below
|
|
31
32
|
|
|
32
|
-
|
|
33
|
+
## CommonJS
|
|
33
34
|
```javascript
|
|
34
35
|
const isObjectEmpty2 = require('is-object-empty2');
|
|
35
36
|
|
|
@@ -40,7 +41,18 @@ console.log(isObjectEmpty2(null)); // false
|
|
|
40
41
|
console.log(isObjectEmpty2(undefined)); // false
|
|
41
42
|
```
|
|
42
43
|
|
|
43
|
-
|
|
44
|
+
## ESM
|
|
45
|
+
```javascript
|
|
46
|
+
import isObjectEmpty2 from 'is-object-empty2';
|
|
47
|
+
|
|
48
|
+
console.log(isObjectEmpty2({})); // true
|
|
49
|
+
console.log(isObjectEmpty2({ a: 1 })); // false
|
|
50
|
+
console.log(isObjectEmpty2([])); // false
|
|
51
|
+
console.log(isObjectEmpty2(null)); // false
|
|
52
|
+
console.log(isObjectEmpty2(undefined)); // false
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## TypeScript
|
|
44
56
|
```javascript
|
|
45
57
|
import isObjectEmpty2 = require('is-object-empty2');
|
|
46
58
|
|
package/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* is-object-empty2 - 📦 Tiny utility to check if a value is a plain empty object in JavaScript and TypeScript
|
|
3
|
-
* @version: v1.0.
|
|
3
|
+
* @version: v1.0.8
|
|
4
4
|
* @link: https://github.com/tutyamxx/is-object-empty2
|
|
5
5
|
* @license: MIT
|
|
6
6
|
**/
|
|
@@ -27,4 +27,8 @@ const isObjectEmpty2 = obj => (!!obj && typeof obj === 'object')
|
|
|
27
27
|
&& !(Object.keys(obj)?.length ?? 0)
|
|
28
28
|
&& !(Object.getOwnPropertySymbols(obj)?.some(s => Object.getOwnPropertyDescriptor(obj, s)?.enumerable) ?? false);
|
|
29
29
|
|
|
30
|
+
// --| CommonJS export
|
|
30
31
|
module.exports = isObjectEmpty2;
|
|
32
|
+
|
|
33
|
+
// --| ESM default export for `import` statements
|
|
34
|
+
module.exports.default = isObjectEmpty2;
|
package/package.json
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "is-object-empty2",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.8",
|
|
4
4
|
"description": "📦 Tiny utility to check if a value is a plain empty object in JavaScript or TypeScript",
|
|
5
5
|
"main": "index.js",
|
|
6
|
+
"module": "index.js",
|
|
6
7
|
"types": "index.d.ts",
|
|
8
|
+
"exports": {
|
|
9
|
+
"require": "./index.js",
|
|
10
|
+
"import": "./index.js",
|
|
11
|
+
"types": "./index.d.ts"
|
|
12
|
+
},
|
|
7
13
|
"scripts": {
|
|
8
14
|
"test": "jest --verbose"
|
|
9
15
|
},
|