diff --git a/src/lib/is.ts b/src/lib/is.ts index cb85223..76f11a0 100644 --- a/src/lib/is.ts +++ b/src/lib/is.ts @@ -4,12 +4,18 @@ const createIs = (type) => (value) => const createIsBooleanObject = (trueOrFalse) => (value) => is.Boolean(value) && value.valueOf() === trueOrFalse; +const createIsFunction = () => { + const syncFn = createIs('Function'); + const asyncFn = createIs('AsyncFunction'); + return (value) => syncFn(value) || asyncFn(value); +}; + export const is = { Array: createIs('Array'), Boolean: createIs('Boolean'), Date: createIs('Date'), False: createIsBooleanObject(false), - Function: createIs('Function'), + Function: createIsFunction(), Object: createIs('Object'), String: createIs('String'), True: createIsBooleanObject(true), diff --git a/test/toBeFunction.spec.js b/test/toBeFunction.spec.js index 5e200df..7f27cfa 100644 --- a/test/toBeFunction.spec.js +++ b/test/toBeFunction.spec.js @@ -4,6 +4,9 @@ describe('toBeFunction', () => { it('should confirm', () => { expect(() => {}).toBeFunction(); }); + it('should confirm for async functions', () => { + expect(async () => {}).toBeFunction(); + }); }); describe('when subject is NOT a function', () => { it('should deny', () => { diff --git a/webpack.config.js b/webpack.config.js index 8ff0ec8..a4a27f9 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -21,6 +21,7 @@ module.exports = { extensions: ['.ts', '.js'] }, output: { - path: path.resolve(__dirname, 'dist') + path: path.resolve(__dirname, 'dist'), + hashFunction: 'sha512' } };