pedash
Advanced tools
Comparing version 0.1.10 to 0.1.12
@@ -33,3 +33,3 @@ export function getCharCountsByKey(arr) { | ||
return arr.reduce((r, a) => { | ||
r[a[key]] = [...(r[a[key]] || []), a] | ||
r[a[key]] = [...(r[a[key]] || []), a][0] | ||
return r | ||
@@ -36,0 +36,0 @@ }, {}) |
{ | ||
"name": "pedash", | ||
"version": "0.1.10", | ||
"version": "0.1.12", | ||
"description": "A lodash-like javascript helper -- for dummies", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -32,3 +32,6 @@ ## Pedash 🌶 | ||
``` | ||
// Example | ||
import { getCharCountsByKey } from 'pedash' | ||
const chars = [34, 2, 90, 99, 45, 99, 99, 34] | ||
console.log(getCharCountsByKey(chars)) | ||
// {2: 1, 34: 2, 45: 1, 90: 1, 99: 3} | ||
``` | ||
@@ -39,3 +42,5 @@ | ||
``` | ||
// Example | ||
import { randomId } from 'pedash' | ||
console.log(randomId()) | ||
// "t536fwpn1je" | ||
``` | ||
@@ -46,3 +51,16 @@ | ||
``` | ||
// Example | ||
import { getLongest } from 'pedash' | ||
const people = ["Sid", "Rusmanto", "Udin", "Zainab"]; | ||
console.log(getLongest(people)); | ||
// "Rusmanto" | ||
const peopleObj = [ // if the argument is in an array of objects shape | ||
{ id: 1, name: "Glenn" }, | ||
{ id: 2, name: "Abi" }, | ||
{ id: 3, name: "Batugana" }, | ||
{ id: 4, name: "Zulu" } | ||
]; | ||
console.log(getLongest(peopleObj, "name")) | ||
// "Batugana" | ||
``` | ||
@@ -53,3 +71,6 @@ | ||
``` | ||
// Example | ||
import { getUnique } from 'pedash' | ||
const uniqueValues = [100, 44, 30, 100, 54, 54]; | ||
console.log(getUnique(uniqueValues)) | ||
// [100, 44, 30, 54] | ||
``` | ||
@@ -60,3 +81,11 @@ | ||
``` | ||
// Example | ||
import { groupByKey } from 'pedash' | ||
const valObj = [ | ||
{ id: 1, name: "Glenn", age: 56 }, | ||
{ id: 2, name: "Abi", age: 17 }, | ||
{ id: 3, name: "Batugana", age: 26 }, | ||
{ id: 4, name: "Zulu", age: 45 } | ||
]; | ||
console.log(groupByKey(valObj, "name")) | ||
// {} | ||
``` | ||
@@ -67,3 +96,6 @@ | ||
``` | ||
// Example | ||
import { getHighest } from 'pedash' | ||
const numbers = [34, 2300, 56, 900]; | ||
console.log(getHighest(numbers)) | ||
// 2300 | ||
``` | ||
@@ -70,0 +102,0 @@ |
5587
148