New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

curry-map

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

curry-map - npm Package Compare versions

Comparing version

to
0.1.1

34

lib/curry-map.js

@@ -9,12 +9,3 @@ 'use strict';

function _traverse(args, defa, param, curry) {
if (args[param])
return args[param](...curry);
if (defa)
return defa(...curry.concat([param]));
throw new Error('Invalid argument: ' + param + ', did you mean one of these? ' + JSON.stringify(args));
}
const CurryMap = (args, defa, prot = {}) => (...curry) => {
const CurryMap = (args, defa, prot = {}) => {
if (typeof args !== 'object') throw new Error('Expected an object.');

@@ -28,2 +19,11 @@ if (typeof defa === 'object') {

for (const key of Object.keys(prot)) {
if (RESTRICTED.includes(key)) throw new Error('Restricted prototype: ' + key);
if (typeof prot[key] !== 'function') throw new Error('Expected a function: ' + key);
}
return (...curry) => _buildCurry(args, defa, prot, curry);
};
function _buildCurry(args, defa, prot, curry) {
const func = (...params) => {

@@ -38,5 +38,2 @@ let output = _traverse(args, defa, params.shift(), curry);

for (const key of Object.keys(prot)) {
if (RESTRICTED.includes(key)) throw new Error('Restricted prototype: ' + key);
if (typeof prot[key] !== 'function') throw new Error('Expected a function: ' + key);
func[key] = prot[key](...curry);

@@ -46,4 +43,13 @@ }

return func;
};
}
function _traverse(args, defa, param, curry) {
if (args[param])
return args[param](...curry);
if (defa)
return defa(...curry.concat([param]));
throw new Error('Invalid argument: ' + param + ', did you mean one of these? ' + JSON.stringify(args));
}
CurryMap.deep = (count, defa, prot) => {

@@ -50,0 +56,0 @@ if (typeof count !== 'number' || count < 1) throw new Error('Expected a number over 0.');

{
"name": "curry-map",
"version": "0.1.0",
"version": "0.1.1",
"description": "Currying with pathways",

@@ -5,0 +5,0 @@ "main": "./lib/index.js",