UNPKG

moleculer-decorators

Version:
33 lines (29 loc) 910 B
function getTag(value) { if (value == null) { return value === undefined ? '[object Undefined]' : '[object Null]'; } return toString.call(value); } function isObject(value) { const type = typeof value; return value != null && (type == 'object' || type == 'function'); } export function omit(object: object, remove: string[]) { let newObj = Object.assign({}, object); for (let n of remove) delete newObj[n]; return newObj; } export function isFunction(value) { if (!isObject(value)) { return false; } // The use of `Object#toString` avoids issues with the `typeof` operator // in Safari 9 which returns 'object' for typed arrays and other constructors. const tag = getTag(value); return ( tag == '[object Function]' || tag == '[object AsyncFunction]' || tag == '[object GeneratorFunction]' || tag == '[object Proxy]' ); }