import { Nil } from '@terascope/types' ; import { isAsyncIterator , isIterator } from './iterators' ; export function isNil < T > ( input ) { return input == null ; } export function isNotNil < T > ( input ) { return input != null ; } /** Check if an input is empty, similar to lodash.isEmpty */ export function isEmpty < T > ( val ? ) { const _val = val as any ; if ( ! _val ) return true ; if ( typeof _val . size === 'number' ) return ! _val . size ; if ( typeof _val . length === 'number' ) return ! _val . length ; if ( _val instanceof Error ) return ! _val . message . length ; if ( Buffer . isBuffer ( _val ) ) return ! _val . length ; if ( isIterator ( val ) || isAsyncIterator ( val ) ) return false ; if ( typeof val === 'object' ) return ! Object . keys ( _val ) . length ; return true ; }