@applitools/functional-commons
Advanced tools
Comparing version 1.3.7 to 1.4.1
{ | ||
"name": "@applitools/functional-commons", | ||
"version": "1.3.7", | ||
"version": "1.4.1", | ||
"description": "", | ||
@@ -42,5 +42,5 @@ "main": "src/functional-commons.js", | ||
"eslint-plugin-prettier": "^3.0.1", | ||
"mocha": "^6.0.2", | ||
"mocha": "^6.1.2", | ||
"prettier": "^1.16.4" | ||
} | ||
} |
@@ -94,44 +94,16 @@ 'use strict' | ||
// Returns a function which reverses the order of the | ||
// arguments to the passed in function when invoked. | ||
function flip(fn) { | ||
return function() { | ||
var args = [].slice.call(arguments) | ||
return fn.apply(this, args.reverse()) | ||
} | ||
} | ||
// Returns a new function that curries the original | ||
// function's arguments from right to left. | ||
function rightCurry(fn, n) { | ||
var arity = n || fn.length, | ||
fn = flip(fn) | ||
return function curried() { | ||
var args = [].slice.call(arguments), | ||
context = this | ||
function group(prop, list) { | ||
return list.reduce(function(grouped, item) { | ||
const key = item[prop] | ||
return args.length >= arity | ||
? fn.apply(context, args.slice(0, arity)) | ||
: function() { | ||
var rest = [].slice.call(arguments) | ||
return curried.apply(context, args.concat(rest)) | ||
} | ||
} | ||
} | ||
grouped[key] = grouped[key] || [] | ||
const toString = Object.prototype.toString | ||
const isFunction = function(o) { | ||
return toString.call(o) == '[object Function]' | ||
} | ||
grouped[key].push(item) | ||
function group(list, prop) { | ||
return list.reduce(function(grouped, item) { | ||
var key = isFunction(prop) ? prop.apply(this, [item]) : item[prop] | ||
grouped[key] = grouped[key] || [] | ||
grouped[key].push(item) | ||
return grouped | ||
}, {}) | ||
} | ||
// our right curried version of `group()` | ||
const groupBy = rightCurry(group) | ||
const groupBy = prop => list => group(prop, list) | ||
/** | ||
@@ -466,4 +438,4 @@ * @param {{[x: string]: any}} object | ||
diff, | ||
rightCurry, | ||
group, | ||
groupBy, | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
0
34949
408