@yurkimus/curry
Advanced tools
Comparing version 0.0.4 to 0.0.5
{ | ||
"name": "@yurkimus/curry", | ||
"version": "0.0.4", | ||
"fmt": { | ||
"semiColons": false, | ||
"singleQuote": true | ||
}, | ||
"exports": "./source/index.js" | ||
"version": "0.0.5", | ||
"exports": "./source/index.js", | ||
"imports": { | ||
"@yurkimus/types": "https://raw.githubusercontent.com/yurkimus/types/main/source/index.js" | ||
} | ||
} |
{ | ||
"type": "module", | ||
"version": "0.0.4", | ||
"version": "0.0.5", | ||
"name": "@yurkimus/curry", | ||
@@ -5,0 +5,0 @@ "author": { |
@@ -41,3 +41,3 @@ # Curry | ||
``` | ||
curry :: function -> number -> function | ||
curry :: Function -> Number -> Function | ||
``` | ||
@@ -50,4 +50,4 @@ | ||
// predicate, no need to specify length unless using variadic function parameters | ||
(a, b) => a + b | ||
)(1)(2); // => 3 | ||
(a, b) => a + b, | ||
)(1)(2) // => 3 | ||
@@ -58,4 +58,4 @@ curry( | ||
// specified length to handle variadic function parameters | ||
2 | ||
)(1)(2, 3); // => 6 | ||
2, | ||
)(1)(2, 3) // => 6 | ||
``` | ||
@@ -62,0 +62,0 @@ |
@@ -0,1 +1,3 @@ | ||
import { is } from '@yurkimus/types' | ||
/** | ||
@@ -7,4 +9,2 @@ * Returns a curried version of a function. | ||
* | ||
* @returns {Function} | ||
* | ||
* @throws {TypeError} "predicate" must be a function | ||
@@ -20,8 +20,8 @@ * @throws {TypeError} "length" must be a number | ||
*/ | ||
export var curry = (predicate, length = predicate.length) => { | ||
if (typeof predicate != "function") | ||
throw new TypeError('"predicate" must be a function') | ||
export let curry = (predicate, length = predicate.length) => { | ||
if (typeof predicate !== 'function') | ||
throw new TypeError(`Parameter 'predicate' must be a function.`) | ||
if (Object.prototype.toString.call(length) != "[object Number]") | ||
throw new TypeError('"length" must be a number') | ||
if (!is('Number', length)) | ||
throw new TypeError(`Parameter 'length' must be a number.`) | ||
@@ -28,0 +28,0 @@ return (...parameters) => |
3803
7
55