diff --git a/src/curry.js b/src/curry.js index a26d74d..96c53c4 100644 --- a/src/curry.js +++ b/src/curry.js @@ -1,9 +1,9 @@ -import { isInteger } from '@fpc/types'; +import { isInteger, expectFunction } from '@fpc/types'; import { curry as unsafeCurry } from './internals'; import { failWith } from './failWith'; export const curry = (fn, numArgs = fn.length) => ( isInteger(numArgs) && numArgs > 0 - ? unsafeCurry(fn, numArgs) + ? unsafeCurry(expectFunction(fn), numArgs) : failWith(new TypeError(`Expected positive integer, got ${numArgs}`)) ); diff --git a/src/flip.js b/src/flip.js index 455dfb4..f58a6bb 100644 --- a/src/flip.js +++ b/src/flip.js @@ -1 +1,6 @@ -export const flip = fn => (...args) => fn(...args.reverse()); +import { expectFunction } from '@fpc/types'; + +export const flip = fn => ( + /* eslint-disable no-sequences */ + expectFunction(fn), (...args) => fn(...args.reverse()) +); diff --git a/src/lazy.js b/src/lazy.js index 71704eb..85dd2ee 100644 --- a/src/lazy.js +++ b/src/lazy.js @@ -1,6 +1,10 @@ +import { expectFunction } from '@fpc/types'; + const empty = {}; export const lazy = (fn, ...args) => { + expectFunction(fn); + let result = empty; const cached = () => ( diff --git a/src/negate.js b/src/negate.js index 402da2a..6ebb4fc 100644 --- a/src/negate.js +++ b/src/negate.js @@ -1 +1,6 @@ -export const negate = fn => (...args) => !fn(...args); +import { expectFunction } from '@fpc/types'; + +export const negate = fn => ( + /* eslint-disable no-sequences */ + expectFunction(fn), (...args) => !fn(...args) +);