UNPKG

pragmatic-fp-ts

Version:

Opinionated functional programming library with easy use in mind

27 lines (23 loc) 569 B
import { Dictionary, getValue, isNil, isLeft, isNothing, MonadType, } from "./main.ts"; export function isEmpty(coll: MonadType<any[] | Dictionary | string>): boolean { const theColl = getValue(coll); return typeof coll === "number" ? false : isNothing(coll) || isNil(theColl) || isLeft(coll) ? true : coll instanceof Array || typeof coll === "string" ? coll.length === 0 : Object.keys(theColl).length === 0; } export function isNotEmpty( coll: MonadType<any[] | Dictionary | string> ): boolean { return !isEmpty(coll); }