Socket
Socket
Sign inDemoInstall

pedash

Package Overview
Dependencies
Maintainers
1
Versions
30
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

pedash - npm Package Compare versions

Comparing version 0.1.6 to 0.1.7

.prettierrc

88

index.js
export function getCharCountsByKey(arr) {
return arr.reduce((total, currentItem) => {
total[currentItem] = (total[currentItem] || 0) + 1;
return total;
}, {});
return arr.reduce((total, currentItem) => {
total[currentItem] = (total[currentItem] || 0) + 1;
return total;
}, {});
}
export function randomId() {
return Math.random()
.toString(36)
.substring(2);
return Math.random()
.toString(36)
.substring(2);
}
export function getLongest(arr, key) {
return arr.reduce((longestItemSoFar, currItem) => {
const theLongest =
typeof longestItemSoFar === "object"
? longestItemSoFar[key]
: longestItemSoFar;
const currentItem =
typeof currItem === "object" ? currItem[key] : currItem;
return theLongest.length > currentItem.length
? theLongest
: currentItem;
});
return arr.reduce((longestItemSoFar, currItem) => {
const theLongest = typeof longestItemSoFar === "object" ? longestItemSoFar[key] : longestItemSoFar;
const currentItem = typeof currItem === "object" ? currItem[key] : currItem;
return theLongest.length > currentItem.length ? theLongest : currentItem;
});
}
export function getUnique(arr) {
return arr.reduce((newArray, currItem) => {
if (newArray.indexOf(currItem) === -1) {
newArray.push(currItem);
}
return newArray;
}, []);
return arr.reduce((newArray, currItem) => {
if (newArray.indexOf(currItem) === -1) {
newArray.push(currItem);
}
return newArray;
}, []);
}
export function groupByKey(arr, key) {
return arr.reduce((r, a) => {
r[a[key]] = [...(r[a[key]] || []), a];
return r;
}, {});
return arr.reduce((r, a) => {
r[a[key]] = [...(r[a[key]] || []), a];
return r;
}, {});
}
export function getHighest(arr, key) {
if (arr.some(item => typeof item !== "number")) {
throw new Error(
"The type of items within the first parameter should be a number"
);
}
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;
}, {});
if (arr.some(item => typeof item !== "number")) {
throw new Error("The type of items within the first parameter should be a number");
}
return arr.reduce((theHighestSoFar, currItem) => {
const theHighest = !theHighestSoFar.constructor.prototype.hasOwnProperty("push")
? theHighestSoFar[key]
: theHighestSoFar;
const currentItem = !currItem.constructor.prototype.hasOwnProperty("push") ? currItem[key] : currItem;
return (theHighest || 0) > currentItem ? theHighest : currentItem;
}, {});
}
export function shuffle(arr) {
if (!Array.isArray(arr)) {
throw new Error("Please input an array as the parameter");
}
if (!Array.isArray(arr)) {
throw new Error("Please input an array as the parameter");
}
if (arr.length < 2) {
throw new Error("At least 2 items needed within the array");
}
if (arr.length < 2) {
throw new Error("At least 2 items needed within the array");
}
return arr.slice().sort(() => Math.random() - 0.5);
return arr.slice().sort(() => Math.random() - 0.5);
}
{
"name": "pedash",
"version": "0.1.6",
"version": "0.1.7",
"description": "A lodash-like javascript helper -- for dummies",

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc