New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

posthtml-ast-is-empty

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

posthtml-ast-is-empty

Find out, is nested array/object/string tree is empty

  • 1.0.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
21
increased by950%
Maintainers
1
Weekly downloads
 
Created
Source

posthtml-ast-is-empty

Standard JavaScript

Find out, is nested array/object/string tree (like PostHTML-parsed AST) is empty

Build Status bitHound Overall Score bitHound Dependencies bitHound Dev Dependencies Downloads/Month

Install

$ npm install --save posthtml-ast-is-empty

Use

// require first:
var isEmpty = require('posthtml-ast-is-empty')
...
// then, for example, feed a parsed HTML tree into it:
console.log(isEmpty(htmlAstObj))

Test

$ npm test

Uses AVA.

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.

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 throw if it encounters one anywhere within the input.

API

isEmpty (
  input        // AST tree, or object or array or whatever. Can be deeply-nested.
);
// => true||false

Contributing & testing

All contributions welcome. This library uses Standard JavaScript notation. See test.js. It's very minimalistic testing setup using AVA.

npm test

If you see anything incorrect whatsoever, raise an issue. PR's welcome too.

Licence

MIT © Roy Reveltas

Keywords

FAQs

Package last updated on 06 Nov 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc