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.8 to 0.1.9

56

index.js
export function getCharCountsByKey(arr) {
return arr.reduce((total, currentItem) => {
total[currentItem] = (total[currentItem] || 0) + 1;
return total;
}, {});
total[currentItem] = (total[currentItem] || 0) + 1
return total
}, {})
}

@@ -11,3 +11,3 @@

.toString(36)
.substring(2);
.substring(2)
}

@@ -17,6 +17,6 @@

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;
});
const theLongest = typeof longestItemSoFar === "object" ? longestItemSoFar[key] : longestItemSoFar
const currentItem = typeof currItem === "object" ? currItem[key] : currItem
return theLongest.length > currentItem.length ? theLongest : currentItem
})
}

@@ -27,6 +27,6 @@

if (newArray.indexOf(currItem) === -1) {
newArray.push(currItem);
newArray.push(currItem)
}
return newArray;
}, []);
return newArray
}, [])
}

@@ -36,5 +36,5 @@

return arr.reduce((r, a) => {
r[a[key]] = [...(r[a[key]] || []), a];
return r;
}, {});
r[a[key]] = [...(r[a[key]] || []), a]
return r
}, {})
}

@@ -44,9 +44,9 @@

if (arr.some(item => typeof item !== "number")) {
throw new Error("The type of items within the first parameter should be a 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;
}, {});
const theHighest = typeof theHighestSoFar === "object" ? theHighestSoFar[key] : theHighestSoFar
const currentItem = typeof currItem === "object" ? currItem[key] : currItem
return (theHighest || 0) > currentItem ? theHighest : currentItem
}, {})
}

@@ -56,10 +56,10 @@

if (!Array.isArray(arr)) {
throw new Error("Please input an array as the parameter");
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");
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)
}

@@ -69,6 +69,14 @@

if (typeof sentence !== "string") {
throw new Error("The paramater input should be string");
throw new Error("The paramater input should be string")
}
return sentence.replace(/\b(\w+)\s+\1\b/gi, "$1");
return sentence.replace(/\b(\w+)\s+\1\b/gi, "$1")
}
export function removeWhitespaces(sentence) {
if (typeof sentence !== "string") {
throw new Error("The paramater input should be string")
}
return sentence.replace(/\s\s+/g, " ").trim()
}
{
"name": "pedash",
"version": "0.1.8",
"version": "0.1.9",
"description": "A lodash-like javascript helper -- for dummies",

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

@@ -90,1 +90,14 @@ ## Pedash 🌶

```
#### removeWhitespaces(sentence: string)
```
import { removeWhitespaces } from pedash;
// Then use it whatever you like
const sentence = " You you can do it now or never "
console.log(removeWhitespaces(sentence));
// "You can do it now or never"
```

Sorry, the diff of this file is not supported yet

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