import fs from 'fs' ; const toString = Object . prototype . toString ; export function is ( val , type ) { return toString . call ( val ) === `[object ${ type }]` ; } export function isFunction < T = Function > ( val ) { return is ( val , 'Function' ) || is ( val , 'AsyncFunction' ) ; } export function isArray ( val ) { return val && Array . isArray ( val ) ; } export function isRegExp ( val ) { return is ( val , 'RegExp' ) ; } export function sleep ( time ) { return new Promise ( ( resolve ) => { setTimeout ( ( ) => { resolve ( '' ) ; } , time ) ; } ) ; } export function fileExists ( f ) { try { fs . accessSync ( f , fs . constants . W_OK ) ; return true ; } catch ( error ) { return false ; } }