Comparing version 0.0.7 to 0.0.8
27
index.js
@@ -14,8 +14,13 @@ module.exports.getCharCountsByKey = function(arr) { | ||
module.exports.getLongest = function(arr) { | ||
module.exports.getLongest = function(arr, key) { | ||
return arr.reduce((longestItemSoFar, currItem) => { | ||
if (currItem.length > longestItemSoFar.length) { | ||
return currItem; | ||
} | ||
return longestItemSoFar; | ||
const theLongest = | ||
typeof longestItemSoFar === "object" | ||
? longestItemSoFar[key] | ||
: longestItemSoFar; | ||
const currentItem = | ||
typeof currItem === "object" ? currItem[key] : currItem; | ||
return theLongest.length > currentItem.length | ||
? theLongest | ||
: currentItem; | ||
}); | ||
@@ -39,1 +44,13 @@ }; | ||
}; | ||
module.exports.getHighest = function(arr, key) { | ||
return arr.reduce((theHighestSoFar, currItem) => { | ||
const theHighest = | ||
typeof theHighestSoFar === "object" | ||
? theHighestSoFar[key] | ||
: theHighestSoFar; | ||
const currentItem = | ||
typeof currItem === "object" ? currItem[key] : currItem; | ||
return (theHighest || 0) > currentItem ? theHighest : currentItem; | ||
}, {}); | ||
}; |
{ | ||
"name": "pedash", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "A lodash-like javascript helper -- for dummies", | ||
@@ -12,3 +12,6 @@ "main": "index.js", | ||
"lodash", | ||
"helper" | ||
"helper", | ||
"utils", | ||
"utilities", | ||
"javascript" | ||
], | ||
@@ -15,0 +18,0 @@ "author": "Bejo Karmila", |
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
2179
49