Comparing version 0.1.0 to 0.1.1
30
index.js
@@ -1,2 +0,2 @@ | ||
module.exports.getCharCountsByKey = function(arr) { | ||
export function getCharCountsByKey(arr) { | ||
return arr.reduce((total, currentItem) => { | ||
@@ -6,11 +6,11 @@ total[currentItem] = (total[currentItem] || 0) + 1; | ||
}, {}); | ||
}; | ||
} | ||
module.exports.randomId = function() { | ||
export function randomId() { | ||
return Math.random() | ||
.toString(36) | ||
.substring(2); | ||
}; | ||
} | ||
module.exports.getLongest = function(arr, key) { | ||
export function getLongest(arr, key) { | ||
return arr.reduce((longestItemSoFar, currItem) => { | ||
@@ -27,5 +27,5 @@ const theLongest = | ||
}); | ||
}; | ||
} | ||
module.exports.getUnique = function(arr) { | ||
export function getUnique(arr) { | ||
return arr.reduce((newArray, currItem) => { | ||
@@ -37,5 +37,5 @@ if (newArray.indexOf(currItem) === -1) { | ||
}, []); | ||
}; | ||
} | ||
module.exports.groupByKey = function(arr, key) { | ||
export function groupByKey(arr, key) { | ||
return arr.reduce((r, a) => { | ||
@@ -45,5 +45,5 @@ r[a[key]] = [...(r[a[key]] || []), a]; | ||
}, {}); | ||
}; | ||
} | ||
module.exports.getHighest = function(arr, key) { | ||
export function getHighest(arr, key) { | ||
return arr.reduce((theHighestSoFar, currItem) => { | ||
@@ -58,6 +58,8 @@ const theHighest = | ||
}, {}); | ||
}; | ||
} | ||
module.exports.shuffle = function(arr) { | ||
export function shuffle(arr) { | ||
if (typeof arr !== "object") | ||
throw new Error("Please input an array as the parameter"); | ||
return arr.slice().sort(() => Math.random() - 0.5); | ||
}; | ||
} |
{ | ||
"name": "pedash", | ||
"version": "0.1.0", | ||
"version": "0.1.1", | ||
"description": "A lodash-like javascript helper -- for dummies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -68,3 +68,10 @@ ## Pedash 🌶 | ||
``` | ||
// Example | ||
import { shuffle } from pedash; | ||
// Then use it whatever you like | ||
const numbers = [56, 89, 21, 20, 7]; | ||
console.log(shuffle(numbers)); | ||
// [7, 20, 21, 56, 89] | ||
``` |
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
2920
54
77