@tomhundley/sparkdash
v1.0.0
Published
A Lodash-style JavaScript utility library for arrays, objects, strings, collections, and functions
Maintainers
Readme
@tomhundley/sparkdash
A Lodash-style utility library for JavaScript. Same kind of helpers: arrays, objects, strings, collections, numbers, and functions. Zero dependencies.
npm install @tomhundley/sparkdashUsage
Named imports:
import { map, groupBy, debounce, get } from "@tomhundley/sparkdash";
map([1, 2, 3], (n) => n * 2);
groupBy(users, "role");
get(user, "address.city", "unknown");Lodash-style _:
import _ from "@tomhundley/sparkdash";
_.uniq([1, 1, 2, 3]);
_.pick(user, ["id", "name"]);
_.camelCase("hello world");Chaining:
import _ from "@tomhundley/sparkdash";
_([1, 2, 3, 4])
.map((n) => n * 2)
.filter((n) => n > 4)
.value();
// [6, 8]What is included
| Area | Examples |
| --- | --- |
| Array | chunk, uniq, flattenDeep, difference, zip, take, drop |
| Collection | map, filter, groupBy, orderBy, reduce, find |
| Object | get, set, merge, pick, omit, cloneDeep |
| String | camelCase, kebabCase, trim, truncate, escape |
| Function | debounce, throttle, once, curry, memoize, partial |
| Lang | isEqual, isEmpty, isPlainObject, isNil |
| Math | sumBy, mean, clamp, inRange, random |
Iteratee shorthands work like Lodash:
filter(users, { active: true });
map(users, "name");
find(users, ["id", 3]);License
MIT
