ast-contains-only-empty-space examples

Table of Contents

Quick Take

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

assert.equal(
  empty({
    a: [
      {
        x: {
          y: [
            {
              z: ["\n"],
            },
          ],
        },
      },
    ],
    b: ["\t\t\t  "],
    c: ["\n \n\n"],
    d: ["\t   "],
  }),
  true
);

More Examples

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

assert.equal(empty([{ content: {} }]), true);

assert.equal(empty([{ tag: "style" }]), false);

// Works on simple arrays as well:
assert.equal(empty(["   ", " "]), true);

// Works on strings as well:
assert.equal(empty("   "), true);

// Object keys that have values as null are considered empty:
assert.equal(empty({ a: null }), true);