ast-is-empty 3.0.5 → 3.0.11
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/LICENSE +1 -1
- package/README.md +4 -5
- package/dist/ast-is-empty.esm.js +2 -47
- package/dist/ast-is-empty.umd.js +2 -2
- package/examples/_quickTake.js +1 -0
- package/package.json +24 -79
- package/types/index.d.ts +0 -0
- package/examples/api.json +0 -1
package/LICENSE
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
MIT License
|
|
2
2
|
|
|
3
|
-
Copyright (c) 2010-
|
|
3
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
4
4
|
|
|
5
5
|
Permission is hereby granted, free of charge, to any person obtaining
|
|
6
6
|
a copy of this software and associated documentation files (the
|
package/README.md
CHANGED
|
@@ -26,18 +26,17 @@
|
|
|
26
26
|
|
|
27
27
|
## Install
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
The latest version is **ESM only**: Node 12+ is needed to use it and it must be `import`ed instead of `require`d. If your project is not on ESM yet and you want to use `require`, use an older version of this program, `2.1.0`.
|
|
30
30
|
|
|
31
31
|
```bash
|
|
32
32
|
npm i ast-is-empty
|
|
33
33
|
```
|
|
34
34
|
|
|
35
|
-
If you need a legacy version which works with `require`, use version 2.1.0
|
|
36
|
-
|
|
37
35
|
## Quick Take
|
|
38
36
|
|
|
39
37
|
```js
|
|
40
38
|
import { strict as assert } from "assert";
|
|
39
|
+
|
|
41
40
|
import { isEmpty } from "ast-is-empty";
|
|
42
41
|
|
|
43
42
|
assert.equal(
|
|
@@ -74,7 +73,7 @@ assert.equal(
|
|
|
74
73
|
|
|
75
74
|
## Documentation
|
|
76
75
|
|
|
77
|
-
Please [visit codsen.com](https://codsen.com/os/ast-is-empty/) for a full description of the API
|
|
76
|
+
Please [visit codsen.com](https://codsen.com/os/ast-is-empty/) for a full description of the API.
|
|
78
77
|
|
|
79
78
|
## Contributing
|
|
80
79
|
|
|
@@ -84,6 +83,6 @@ To report bugs or request features or assistance, [raise an issue](https://githu
|
|
|
84
83
|
|
|
85
84
|
MIT License
|
|
86
85
|
|
|
87
|
-
Copyright (c) 2010-
|
|
86
|
+
Copyright (c) 2010-2022 Roy Revelt and other contributors
|
|
88
87
|
|
|
89
88
|
<img src="https://codsen.com/images/png-codsen-ok.png" width="98" alt="ok" align="center"> <img src="https://codsen.com/images/png-codsen-1.png" width="148" alt="codsen" align="center"> <img src="https://codsen.com/images/png-codsen-star-small.png" width="32" alt="star" align="center">
|
package/dist/ast-is-empty.esm.js
CHANGED
|
@@ -1,55 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-is-empty
|
|
3
3
|
* @fileoverview Find out, is nested array/object/string/AST tree is empty
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-is-empty/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
import
|
|
11
|
-
|
|
12
|
-
var version$1 = "3.0.5";
|
|
13
|
-
|
|
14
|
-
const version = version$1;
|
|
15
|
-
function isEmpty(input) {
|
|
16
|
-
let i;
|
|
17
|
-
let len;
|
|
18
|
-
let res = true;
|
|
19
|
-
if (Array.isArray(input)) {
|
|
20
|
-
if (input.length === 0) {
|
|
21
|
-
return true;
|
|
22
|
-
}
|
|
23
|
-
for (i = 0, len = input.length; i < len; i++) {
|
|
24
|
-
res = isEmpty(input[i]);
|
|
25
|
-
if (res === null) {
|
|
26
|
-
return null;
|
|
27
|
-
}
|
|
28
|
-
if (!res) {
|
|
29
|
-
return false;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
} else if (isObj(input)) {
|
|
33
|
-
if (Object.keys(input).length === 0) {
|
|
34
|
-
return true;
|
|
35
|
-
}
|
|
36
|
-
for (i = 0, len = Object.keys(input).length; i < len; i++) {
|
|
37
|
-
res = isEmpty(input[Object.keys(input)[i]]);
|
|
38
|
-
if (res === null) {
|
|
39
|
-
return null;
|
|
40
|
-
}
|
|
41
|
-
if (!res) {
|
|
42
|
-
return false;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
} else if (typeof input === "string") {
|
|
46
|
-
if (input.length !== 0) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
} else {
|
|
50
|
-
return null;
|
|
51
|
-
}
|
|
52
|
-
return res;
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
export { isEmpty, version };
|
|
10
|
+
import o from"lodash.isplainobject";var n="3.0.11";var d=n;function l(e){let t,r,s=!0;if(Array.isArray(e)){if(e.length===0)return!0;for(t=0,r=e.length;t<r;t++){if(s=l(e[t]),s===null)return null;if(!s)return!1}}else if(o(e)){if(Object.keys(e).length===0)return!0;for(t=0,r=Object.keys(e).length;t<r;t++){if(s=l(e[Object.keys(e)[t]]),s===null)return null;if(!s)return!1}}else if(typeof e=="string"){if(e.length!==0)return!1}else return null;return s}export{l as isEmpty,d as version};
|
package/dist/ast-is-empty.umd.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @name ast-is-empty
|
|
3
3
|
* @fileoverview Find out, is nested array/object/string/AST tree is empty
|
|
4
|
-
* @version 3.0.
|
|
4
|
+
* @version 3.0.11
|
|
5
5
|
* @author Roy Revelt, Codsen Ltd
|
|
6
6
|
* @license MIT
|
|
7
7
|
* {@link https://codsen.com/os/ast-is-empty/}
|
|
8
8
|
*/
|
|
9
9
|
|
|
10
|
-
|
|
10
|
+
var astIsEmpty=(()=>{var m=Object.create;var o=Object.defineProperty;var b=Object.getOwnPropertyDescriptor;var j=Object.getOwnPropertyNames;var g=Object.getPrototypeOf,h=Object.prototype.hasOwnProperty;var c=e=>o(e,"__esModule",{value:!0});var O=(e,t)=>()=>(t||e((t={exports:{}}).exports,t),t.exports),v=(e,t)=>{for(var r in t)o(e,r,{get:t[r],enumerable:!0})},l=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let s of j(t))!h.call(e,s)&&(r||s!=="default")&&o(e,s,{get:()=>t[s],enumerable:!(n=b(t,s))||n.enumerable});return e},x=(e,t)=>l(c(o(e!=null?m(g(e)):{},"default",!t&&e&&e.__esModule?{get:()=>e.default,enumerable:!0}:{value:e,enumerable:!0})),e),k=(e=>(t,r)=>e&&e.get(t)||(r=l(c({}),t,1),e&&e.set(t,r),r))(typeof WeakMap!="undefined"?new WeakMap:0);var y=O((V,u)=>{var P="[object Object]";function S(e){var t=!1;if(e!=null&&typeof e.toString!="function")try{t=!!(e+"")}catch(r){}return t}function w(e,t){return function(r){return e(t(r))}}var T=Function.prototype,a=Object.prototype,p=T.toString,A=a.hasOwnProperty,C=p.call(Object),D=a.toString,E=w(Object.getPrototypeOf,Object);function F(e){return!!e&&typeof e=="object"}function R(e){if(!F(e)||D.call(e)!=P||S(e))return!1;var t=E(e);if(t===null)return!0;var r=A.call(t,"constructor")&&t.constructor;return typeof r=="function"&&r instanceof r&&p.call(r)==C}u.exports=R});var L={};v(L,{isEmpty:()=>i,version:()=>I});var f=x(y(),1);var d="3.0.11";var I=d;function i(e){let t,r,n=!0;if(Array.isArray(e)){if(e.length===0)return!0;for(t=0,r=e.length;t<r;t++){if(n=i(e[t]),n===null)return null;if(!n)return!1}}else if((0,f.default)(e)){if(Object.keys(e).length===0)return!0;for(t=0,r=Object.keys(e).length;t<r;t++){if(n=i(e[Object.keys(e)[t]]),n===null)return null;if(!n)return!1}}else if(typeof e=="string"){if(e.length!==0)return!1}else return null;return n}return k(L);})();
|
package/examples/_quickTake.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "ast-is-empty",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.11",
|
|
4
4
|
"description": "Find out, is nested array/object/string/AST tree is empty",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"array",
|
|
@@ -44,97 +44,42 @@
|
|
|
44
44
|
},
|
|
45
45
|
"types": "types/index.d.ts",
|
|
46
46
|
"scripts": {
|
|
47
|
-
"build": "
|
|
48
|
-
"
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"
|
|
57
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"
|
|
60
|
-
"
|
|
61
|
-
"tap": "tap",
|
|
62
|
-
"pretest": "npm run build",
|
|
63
|
-
"test": "npm run lint && npm run unittest && npm run test:examples && npm run clean_cov && npm run format",
|
|
64
|
-
"test:examples": "../../scripts/test-examples.js && npm run lect && npm run prettier",
|
|
65
|
-
"tsc": "tsc",
|
|
66
|
-
"unittest": "tap --no-only --output-file=testStats.md --reporter=terse && tsc -p tsconfig.json --noEmit && npm run clean_cov && npm run perf"
|
|
47
|
+
"build": "node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
48
|
+
"dev": "DEV=true node '../../ops/scripts/esbuild.js' && yarn run dts",
|
|
49
|
+
"dts": "rollup -c && yarn run prettier 'types/index.d.ts' --write",
|
|
50
|
+
"examples": "node '../../ops/scripts/run-examples.js'",
|
|
51
|
+
"lect": "node '../../ops/lect/lect.js'",
|
|
52
|
+
"letspublish": "yarn publish || :",
|
|
53
|
+
"lint": "eslint . --fix",
|
|
54
|
+
"perf": "node perf/check.js",
|
|
55
|
+
"prepare": "echo 'ready'",
|
|
56
|
+
"prettier": "prettier",
|
|
57
|
+
"prettier:format": "prettier --write '**/*.{ts,tsx,md}' --no-error-on-unmatched-pattern",
|
|
58
|
+
"pretest": "yarn run lect && yarn run build",
|
|
59
|
+
"test": "c8 yarn run unit && yarn run examples && yarn run lint",
|
|
60
|
+
"unit": "uvu test"
|
|
67
61
|
},
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
"--no-warnings",
|
|
76
|
-
"--experimental-loader",
|
|
77
|
-
"@istanbuljs/esm-loader-hook"
|
|
62
|
+
"engines": {
|
|
63
|
+
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
|
|
64
|
+
},
|
|
65
|
+
"c8": {
|
|
66
|
+
"check-coverage": true,
|
|
67
|
+
"exclude": [
|
|
68
|
+
"**/test/**/*.*"
|
|
78
69
|
],
|
|
79
|
-
"
|
|
70
|
+
"lines": 100
|
|
80
71
|
},
|
|
81
72
|
"lect": {
|
|
82
73
|
"licence": {
|
|
83
74
|
"extras": [
|
|
84
75
|
""
|
|
85
76
|
]
|
|
86
|
-
},
|
|
87
|
-
"req": "{ isEmpty }",
|
|
88
|
-
"various": {
|
|
89
|
-
"devDependencies": [
|
|
90
|
-
"@types/lodash.isplainobject"
|
|
91
|
-
]
|
|
92
77
|
}
|
|
93
78
|
},
|
|
94
79
|
"dependencies": {
|
|
95
|
-
"@babel/runtime": "^7.16.0",
|
|
96
80
|
"lodash.isplainobject": "^4.0.6"
|
|
97
81
|
},
|
|
98
82
|
"devDependencies": {
|
|
99
|
-
"@
|
|
100
|
-
"@babel/core": "^7.16.0",
|
|
101
|
-
"@babel/node": "^7.16.0",
|
|
102
|
-
"@babel/plugin-external-helpers": "^7.16.0",
|
|
103
|
-
"@babel/plugin-proposal-class-properties": "^7.16.0",
|
|
104
|
-
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.16.0",
|
|
105
|
-
"@babel/plugin-proposal-object-rest-spread": "^7.16.0",
|
|
106
|
-
"@babel/plugin-proposal-optional-chaining": "^7.16.0",
|
|
107
|
-
"@babel/plugin-transform-runtime": "^7.16.0",
|
|
108
|
-
"@babel/preset-env": "^7.16.0",
|
|
109
|
-
"@babel/preset-typescript": "^7.16.0",
|
|
110
|
-
"@babel/register": "^7.16.0",
|
|
111
|
-
"@istanbuljs/esm-loader-hook": "^0.1.2",
|
|
112
|
-
"@rollup/plugin-babel": "^5.3.0",
|
|
113
|
-
"@rollup/plugin-commonjs": "^21.0.1",
|
|
114
|
-
"@rollup/plugin-json": "^4.1.0",
|
|
115
|
-
"@rollup/plugin-node-resolve": "^13.0.6",
|
|
116
|
-
"@rollup/plugin-strip": "^2.1.0",
|
|
117
|
-
"@rollup/plugin-typescript": "^8.3.0",
|
|
118
|
-
"@types/lodash.isplainobject": "^4.0.6",
|
|
119
|
-
"@types/node": "^16.11.6",
|
|
120
|
-
"@types/tap": "^15.0.5",
|
|
121
|
-
"@typescript-eslint/eslint-plugin": "^5.3.0",
|
|
122
|
-
"@typescript-eslint/parser": "^5.3.0",
|
|
123
|
-
"core-js": "^3.19.1",
|
|
124
|
-
"cross-env": "^7.0.3",
|
|
125
|
-
"eslint": "^8.2.0",
|
|
126
|
-
"lect": "^0.18.5",
|
|
127
|
-
"rollup": "^2.59.0",
|
|
128
|
-
"rollup-plugin-ascii": "^0.0.3",
|
|
129
|
-
"rollup-plugin-banner": "^0.2.1",
|
|
130
|
-
"rollup-plugin-cleanup": "^3.2.1",
|
|
131
|
-
"rollup-plugin-dts": "^4.0.1",
|
|
132
|
-
"rollup-plugin-terser": "^7.0.2",
|
|
133
|
-
"tap": "^15.0.10",
|
|
134
|
-
"tslib": "^2.3.1",
|
|
135
|
-
"typescript": "^4.4.4"
|
|
136
|
-
},
|
|
137
|
-
"engines": {
|
|
138
|
-
"node": ">=12"
|
|
83
|
+
"@types/lodash.isplainobject": "^4.0.6"
|
|
139
84
|
}
|
|
140
85
|
}
|
package/types/index.d.ts
CHANGED
|
File without changes
|
package/examples/api.json
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"_quickTake.js":{"title":"Quick Take","content":"import { strict as assert } from \"assert\";\nimport { isEmpty } from \"ast-is-empty\";\n\nassert.equal(\n isEmpty({\n a: \"\",\n }),\n true\n);\n\nassert.equal(\n isEmpty({\n a: [\"\"],\n b: {\n c: {\n d: \"\",\n },\n },\n }),\n true\n);\n\nassert.equal(\n isEmpty([\n {\n a: [\"\"],\n b: { c: { d: \"\" } },\n },\n \"\",\n [\"\", \"\", \"\"],\n ]),\n true\n);"}}
|