posthtml-ast-is-empty
Advanced tools
Comparing version 3.1.0 to 4.0.0
@@ -8,2 +8,6 @@ # Change Log | ||
## [4.0.0] - 2018-05-26 | ||
Deprecating it, use [ast-is-empty](https://bitbucket.org/codsen/ast-is-empty/) | ||
## [3.1.0] - 2018-05-26 | ||
@@ -13,6 +17,6 @@ | ||
* ✨ Set up [Prettier](https://prettier.io) on a custom ESLint rule set. | ||
* ✨ Removed `package.lock` and `.editorconfig` | ||
* ✨ Wired Rollup to remove comments from non-dev builds. This means we can now leave the `console.log`s in the source code — there's no need to comment-out `console.log` statements or care about them not spilling into production. Now it's done automatically. | ||
* ✨ Unit tests are pointing at ES modules build, which means that code coverage is correct now, without Babel functions being missed. This is important because now code coverage is real again and now there are no excuses not to perfect it. | ||
- ✨ Set up [Prettier](https://prettier.io) on a custom ESLint rule set. | ||
- ✨ Removed `package.lock` and `.editorconfig` | ||
- ✨ Wired Rollup to remove comments from non-dev builds. This means we can now leave the `console.log`s in the source code — there's no need to comment-out `console.log` statements or care about them not spilling into production. Now it's done automatically. | ||
- ✨ Unit tests are pointing at ES modules build, which means that code coverage is correct now, without Babel functions being missed. This is important because now code coverage is real again and now there are no excuses not to perfect it. | ||
@@ -23,4 +27,4 @@ ## [3.0.0] - 2017-12-09 | ||
* ✨ Rebased in ES Modules. Now with help of Rollup we're generating 3 builds: CommonJS, UMD and ES Modules. | ||
* ✨ Dropped JS Standards and tapped raw ESLint on `airbnb-base` preset, with only exception - semicolons off. | ||
- ✨ Rebased in ES Modules. Now with help of Rollup we're generating 3 builds: CommonJS, UMD and ES Modules. | ||
- ✨ Dropped JS Standards and tapped raw ESLint on `airbnb-base` preset, with only exception - semicolons off. | ||
@@ -33,3 +37,3 @@ API hasn't changed, but bumping semver major just in case. | ||
* Slight API change. Now, when a strange thing (function, null, undefined) is encountered anywhere in the input, including somewhere nested deeply within array/object tree, **library doesn't throw** anymore, but returns **null**. This is to make it more developer-friendly. Null will be completely acceptable value in the IF statements and you can freely use this library on those strange cases. | ||
- Slight API change. Now, when a strange thing (function, null, undefined) is encountered anywhere in the input, including somewhere nested deeply within array/object tree, **library doesn't throw** anymore, but returns **null**. This is to make it more developer-friendly. Null will be completely acceptable value in the IF statements and you can freely use this library on those strange cases. | ||
@@ -36,0 +40,0 @@ There should be no impact for normal use, if you work with parsed HTML AST's — there won't be any functions anyway! |
178
package.json
{ | ||
"name": "posthtml-ast-is-empty", | ||
"version": "3.1.0", | ||
"description": "Find out, is nested array/object/string/AST tree is empty", | ||
"version": "4.0.0", | ||
"description": "DEPRECATED. Use ast-is-empty instead.", | ||
"license": "MIT", | ||
@@ -13,8 +13,5 @@ "engines": { | ||
"type": "git", | ||
"url": "git+https://github.com/codsen/posthtml-ast-is-empty.git" | ||
"url": "https://bitbucket.org/codsen/posthtml-ast-is-empty.git" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/codsen/posthtml-ast-is-empty/issues" | ||
}, | ||
"homepage": "https://github.com/codsen/posthtml-ast-is-empty#readme", | ||
"homepage": "https://bitbucket.org/codsen/posthtml-ast-is-empty/", | ||
"author": { | ||
@@ -25,167 +22,4 @@ "email": "roy@codsen.com", | ||
}, | ||
"main": "dist/posthtml-ast-is-empty.cjs.js", | ||
"module": "dist/posthtml-ast-is-empty.esm.js", | ||
"browser": "dist/posthtml-ast-is-empty.umd.js", | ||
"scripts": { | ||
"build": "rollup -c", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"dev": "rollup -c --dev --silent", | ||
"format": "prettier '*.{js,ts,css,less,scss,vue,gql,md}' --write && ./node_modules/.bin/eslint src/*.js test/*.js --fix", | ||
"precommit": "npm run format && npm test", | ||
"prepare": "npm run build", | ||
"pretest": "npm run build", | ||
"test": "./node_modules/.bin/eslint src/*.js test/*.js && nyc --require esm --reporter=html --reporter=text ava" | ||
}, | ||
"ava": { | ||
"compileEnhancements": false, | ||
"require": [ | ||
"esm" | ||
], | ||
"verbose": true | ||
}, | ||
"clinton": { | ||
"rules": { | ||
"xo": 0 | ||
} | ||
}, | ||
"esm": { | ||
"await": true, | ||
"cjs": true | ||
}, | ||
"keywords": [ | ||
"ast", | ||
"posthtml", | ||
"tree", | ||
"is", | ||
"empty", | ||
"contains", | ||
"only", | ||
"blank", | ||
"no", | ||
"array", | ||
"nested", | ||
"object", | ||
"string", | ||
"posthtml-tree", | ||
"posthtmltree", | ||
"html", | ||
"xml", | ||
"parser", | ||
"parsed" | ||
], | ||
"lect": { | ||
"babelrc": { | ||
"override": false, | ||
"set": false | ||
}, | ||
"badges": { | ||
"contributors": true, | ||
"cov": true, | ||
"deps": true, | ||
"deps2d": true, | ||
"dev": true, | ||
"downloads": true, | ||
"license": true, | ||
"node": true, | ||
"npm": true, | ||
"overall": true, | ||
"runkit": true, | ||
"travis": true, | ||
"vulnerabilities": true | ||
}, | ||
"contribution_types": [ | ||
"Blogposts", | ||
"Bug reports", | ||
"Code", | ||
"Design", | ||
"Documentation", | ||
"Event Organizing", | ||
"Examples", | ||
"Financial", | ||
"Funding Finding", | ||
"Ideas, Planning, & Feedback", | ||
"Infrastructure (Hosting, Build-Tools, etc)", | ||
"Plugin/utility libraries", | ||
"Answering Questions", | ||
"Reviewed Pull Requests", | ||
"Talks", | ||
"Tests", | ||
"Tools", | ||
"Translation", | ||
"Tutorials", | ||
"Videos" | ||
], | ||
"contributors": [ | ||
{ | ||
"contribution": [ | ||
"Code", | ||
"Documentation", | ||
"Tests" | ||
], | ||
"username": "revelt" | ||
} | ||
], | ||
"eslintrc": { | ||
"add": [], | ||
"remove": [] | ||
}, | ||
"files": { | ||
"delete": [], | ||
"write_hard": [ | ||
{ | ||
"contents": "", | ||
"name": "" | ||
} | ||
], | ||
"write_soft": [ | ||
{ | ||
"contents": "", | ||
"name": "" | ||
} | ||
] | ||
}, | ||
"header": { | ||
"dontQuoteDescription": false, | ||
"rightFloatedBadge": [] | ||
}, | ||
"licence": { | ||
"extras": [] | ||
}, | ||
"npmignore": { | ||
"badFiles": [], | ||
"badFolders": [], | ||
"goodFiles": [], | ||
"goodFolders": [] | ||
}, | ||
"various": { | ||
"back_to_top": { | ||
"enabled": true, | ||
"label": "" | ||
}, | ||
"devDependencies": [] | ||
} | ||
}, | ||
"dependencies": { | ||
"lodash.isplainobject": "*" | ||
}, | ||
"devDependencies": { | ||
"ava": "latest", | ||
"babel-preset-env": "latest", | ||
"coveralls": "latest", | ||
"eslint": "^4.19.1", | ||
"eslint-config-prettier": "^2.9.0", | ||
"eslint-plugin-ava": "^4.5.1", | ||
"eslint-plugin-import": "^2.12.0", | ||
"eslint-plugin-prettier": "^2.6.0", | ||
"esm": "latest", | ||
"husky": "latest", | ||
"nyc": "latest", | ||
"prettier": "latest", | ||
"rollup": "^0.59.1", | ||
"rollup-plugin-babel": "^3.0.4", | ||
"rollup-plugin-commonjs": "^9.1.3", | ||
"rollup-plugin-node-resolve": "^3.3.0", | ||
"rollup-plugin-strip": "^1.1.1", | ||
"rollup-plugin-uglify": "^4.0.0" | ||
} | ||
"dependencies": {}, | ||
"devDependencies": {} | ||
} |
154
readme.md
# posthtml-ast-is-empty | ||
> Find out, is nested array/object/string/AST tree is empty | ||
<span style="text-align: center; background-color: #ff6565; padding: 20px; display: block;"><strong>DEPRECATED</strong><br><br>Use <a href="https://bitbucket.org/codsen/ast-is-empty">ast-is-empty</a> instead.<br>2018-06-16</span> | ||
[![Minimum Node version required][node-img]][node-url] | ||
[![Build Status][travis-img]][travis-url] | ||
[![Coverage][cov-img]][cov-url] | ||
[![bitHound Overall Score][overall-img]][overall-url] | ||
[![bitHound Dependencies][deps-img]][deps-url] | ||
[![View dependencies as 2D chart][deps2d-img]][deps2d-url] | ||
[![bitHound Dev Dependencies][dev-img]][dev-url] | ||
[![Known Vulnerabilities][vulnerabilities-img]][vulnerabilities-url] | ||
[![Downloads/Month][downloads-img]][downloads-url] | ||
[![Test in browser][runkit-img]][runkit-url] | ||
[![Code style: prettier][prettier-img]][prettier-url] | ||
[![MIT License][license-img]][license-url] | ||
> This is not a PostHTML plugin but a regular JS library. It is meant to work with anything, including nested array/object trees, like parsed HTML, that is, AST (abstract syntax trees) that come out of the PostHTML-parser. Hence the name, `posthtml-ast-`. | ||
## Table of Contents | ||
<!-- prettier-ignore-start --> | ||
<!-- START doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE --> | ||
- [Install](#install) | ||
- [Rationale](#rationale) | ||
- [API](#api) | ||
- [Contributing](#contributing) | ||
- [Licence](#licence) | ||
<!-- END doctoc generated TOC please keep comment here to allow auto update --> | ||
<!-- prettier-ignore-end --> | ||
## Install | ||
```bash | ||
npm i posthtml-ast-is-empty | ||
``` | ||
```js | ||
// consume as CommonJS require: | ||
const isEmpty = require("posthtml-ast-is-empty"); | ||
// or as a ES Module: | ||
import isEmpty from "posthtml-ast-is-empty"; | ||
// then, for example, feed a parsed HTML tree into it: | ||
console.log(isEmpty(htmlAstObj)); | ||
``` | ||
Here's what you'll get: | ||
| Type | Key in `package.json` | Path | Size | | ||
| ------------------------------------------------------------------------------------------------------- | --------------------- | ----------------------------------- | ---------- | | ||
| Main export - **CommonJS version**, transpiled to ES5, contains `require` and `module.exports` | `main` | `dist/posthtml-ast-is-empty.cjs.js` | 1 KB | | ||
| **ES module** build that Webpack/Rollup understands. Untranspiled ES6 code with `import`/`export`. | `module` | `dist/posthtml-ast-is-empty.esm.js` | 875 B | | ||
| **UMD build** for browsers, transpiled, minified, containing `iife`'s and has all dependencies baked-in | `browser` | `dist/posthtml-ast-is-empty.umd.js` | 1 KB | | ||
**[⬆ back to top](#)** | ||
## Rationale | ||
Imagine, that you have a nested array which contains plain objects, arrays and strings. Huge tree. This library can tell if it consists of only empty things. | ||
These are empty things, for example: | ||
```js | ||
{ | ||
a: ""; | ||
} | ||
``` | ||
or | ||
```js | ||
{ | ||
a: [""]; | ||
b: { | ||
c: { | ||
d: ""; | ||
} | ||
} | ||
} | ||
``` | ||
or | ||
```js | ||
[ | ||
{ | ||
a: [''] | ||
b: {c: {d: ''}} | ||
}, | ||
'', | ||
['', '', ''] | ||
] | ||
``` | ||
Here's how we judge if things _are empty_: | ||
* Plain object is empty if each of its keys has empty string or a nested tree of _empty things_ (arrays/plain objects/strings) **OR** if it has no keys | ||
* Array is empty if each of its elements has empty string or a nested tree of _empty things_(arrays/plain objects/strings) **OR** if it has no elements | ||
* A string is empty if it's equal to `''`. | ||
Functions are not considered to be empty and this library will return `null` if it encounters one anywhere within the `input`. Same with as `undefined` or `null` inputs. | ||
**[⬆ back to top](#)** | ||
## API | ||
Anything-in, Boolean-out. | ||
```js | ||
isEmpty( | ||
input // AST tree, or object or array or whatever. Can be deeply-nested. | ||
); | ||
// => true||false | ||
``` | ||
## Contributing | ||
* If you **want a new feature** in this package or you would like us to change some of its functionality, raise an [issue on this repo](https://github.com/codsen/posthtml-ast-is-empty/issues). | ||
* If you tried to use this library but it misbehaves, or **you need advice setting it up**, and its readme doesn't make sense, just document it and raise an [issue on this repo](https://github.com/codsen/posthtml-ast-is-empty/issues). | ||
* If you would like to **add or change some features**, just fork it, hack away, and file a pull request. We'll do our best to merge it quickly. _Prettier_ is enabled, so you don't need to worry about the code style. | ||
**[⬆ back to top](#)** | ||
## Licence | ||
@@ -137,26 +10,1 @@ | ||
Copyright © 2018 Codsen Ltd, Roy Revelt | ||
[node-img]: https://img.shields.io/node/v/posthtml-ast-is-empty.svg?style=flat-square&label=works%20on%20node | ||
[node-url]: https://www.npmjs.com/package/posthtml-ast-is-empty | ||
[travis-img]: https://img.shields.io/travis/codsen/posthtml-ast-is-empty.svg?style=flat-square | ||
[travis-url]: https://travis-ci.org/codsen/posthtml-ast-is-empty | ||
[cov-img]: https://coveralls.io/repos/github/codsen/posthtml-ast-is-empty/badge.svg?style=flat-square?branch=master | ||
[cov-url]: https://coveralls.io/github/codsen/posthtml-ast-is-empty?branch=master | ||
[overall-img]: https://img.shields.io/bithound/code/github/codsen/posthtml-ast-is-empty.svg?style=flat-square | ||
[overall-url]: https://www.bithound.io/github/codsen/posthtml-ast-is-empty | ||
[deps-img]: https://img.shields.io/bithound/dependencies/github/codsen/posthtml-ast-is-empty.svg?style=flat-square | ||
[deps-url]: https://www.bithound.io/github/codsen/posthtml-ast-is-empty/master/dependencies/npm | ||
[deps2d-img]: https://img.shields.io/badge/deps%20in%202D-see_here-08f0fd.svg?style=flat-square | ||
[deps2d-url]: http://npm.anvaka.com/#/view/2d/posthtml-ast-is-empty | ||
[dev-img]: https://img.shields.io/bithound/devDependencies/github/codsen/posthtml-ast-is-empty.svg?style=flat-square | ||
[dev-url]: https://www.bithound.io/github/codsen/posthtml-ast-is-empty/master/dependencies/npm | ||
[vulnerabilities-img]: https://snyk.io/test/github/codsen/posthtml-ast-is-empty/badge.svg?style=flat-square | ||
[vulnerabilities-url]: https://snyk.io/test/github/codsen/posthtml-ast-is-empty | ||
[downloads-img]: https://img.shields.io/npm/dm/posthtml-ast-is-empty.svg?style=flat-square | ||
[downloads-url]: https://npmcharts.com/compare/posthtml-ast-is-empty | ||
[runkit-img]: https://img.shields.io/badge/runkit-test_in_browser-a853ff.svg?style=flat-square | ||
[runkit-url]: https://npm.runkit.com/posthtml-ast-is-empty | ||
[prettier-img]: https://img.shields.io/badge/code_style-prettier-ff69b4.svg?style=flat-square | ||
[prettier-url]: https://github.com/prettier/prettier | ||
[license-img]: https://img.shields.io/npm/l/posthtml-ast-is-empty.svg?style=flat-square | ||
[license-url]: https://github.com/codsen/posthtml-ast-is-empty/blob/master/license.md |
Empty package
Supply chain riskPackage does not contain any code. It may be removed, is name squatting, or the result of a faulty package publish.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
No bug tracker
MaintenancePackage does not have a linked bug tracker in package.json.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
Wildcard dependency
QualityPackage has a dependency with a floating version range. This can cause issues if the dependency publishes a new major version.
Found 1 instance in 1 package
No website
QualityPackage does not have a website.
Found 1 instance in 1 package
0
0
1
4070
4
0
10
2
- Removedlodash.isplainobject@*
- Removedlodash.isplainobject@4.0.6(transitive)