Returns Boolean depending if passed AST contain only empty space

§ Quick Take

import { strict as assert } from "assert";
import containsOnlyEmptySpace from "ast-contains-only-empty-space";

    a: [
        x: {
          y: [
              z: ["\n"],
    b: ["\t\t\t  "],
    c: ["\n \n\n"],
    d: ["\t   "],

§ Examples

§ Purpose

Working with parsed HTML is always a battle against the white space. This program tells if given data structure is empty — containing only empty space or really empty.

By the way, weird things which don't belong to parsed structures (functions, for example) will yield a result false.



Input - anything. Output - Boolean.

This library does not mutate the input arguments.

§ Licence

MIT opens in a new tab

Copyright © 2010–2020 Roy Revelt and other contributors

Related packages:

📦 ast-get-object 1.9.18
Getter/setter for nested parsed HTML AST's, querying objects by key/value pairs
📦 ast-monkey-util 1.1.11
Utility library of AST helper functions
📦 ast-monkey-traverse 1.12.20
Utility library to traverse AST
📦 ast-delete-object 1.9.2
Delete all plain objects in AST if they contain a certain key/value pair
📦 ast-is-empty 1.10.10
Find out, is nested array/object/string/AST tree is empty
📦 ast-monkey-traverse-with-lookahead 1.1.12
Utility library to traverse AST, reports upcoming values
📦 ast-loose-compare 1.8.16
Compare anything: AST, objects, arrays and strings