ast-is-empty
Version:
Find out, is nested array/object/string/AST tree is empty
11 lines (9 loc) • 648 B
JavaScript
/**
* @name ast-is-empty
* @fileoverview Find out, is nested array/object/string/AST tree is empty
* @version 4.2.1
* @author Roy Revelt
* @license MIT
* {@link https://codsen.com/os/ast-is-empty/}
*/
import{isPlainObject as l}from"codsen-utils";var r="4.2.1";var m=r;function n(e){let t=!0;if(Array.isArray(e)){if(e.length===0)return!0;for(let s of e){if(t=n(s),t===null)return null;if(!t)return!1}}else if(l(e)){let s=Object.keys(e);if(s.length===0)return!0;for(let o of s){if(t=n(e[o]),t===null)return null;if(!t)return!1}}else if(typeof e=="string"){if(e.length!==0)return!1}else return null;return t}export{n as isEmpty,m as version};