THE PROJECT IS IN DEVELOPMENT AND IS NOT YET A REPLACEMENT
FOR LODASH
lo-fns is a faster and smaller, yet fully compatible Lodash
alternative.
- lo-fns is fast. Benchmarks coming soon
- lo-fns is small. All extreme edge-case code of Lodash is gone
- lo-fns is pure. Method arguments are never mutated
- lo-fns is modern. It is written explicitely in ES6
- lo-fns is safe. It is written in TypeScript and heavily tested
Why this package? Should I use it?
First of all I want to say that Lodash is great. It is an incredible
toolset. However, I have some problems with it. Lodash is old (10+ years), and
a lot of code targets old browsers and runtimes. The code is not tree-shakable,
which makes Lodash a dependency so big, it spawned memes around the topic.
lo-fns is my attempt to rethink Lodash in a modern way. Lodash functions try
to save the end user from shooting themselves in a leg by extra checks for
argument types and values. My approach is to replace this with robust type
definitions and tests to make sure the functions work as expected.
The functions will be exported as ES6 modules from the start, and importing
them separately from each other is the intended way to use them. Tree-shaking
is available in virtually every bundler, so it is silly not to take advantage
of it.
In the end, I will try to make lo-fns not only a lighter, but also a faster
version of Lodash (if this renders to be possible). Despite our machines being
able to achive things that were unachievable a few years ago, there is still no
point in using extra power when it is possible not to do so.
Install
Node
yarn add lo-fns
npm install lo-fns
Browsers
<script src="https://cdn.jsdelivr.net/npm/lo-fns/dist/lo-fns.min.js"></script>
Usage
Import functions as you need them:
import { chunk } from "lo-fns";
const chunkedArray = chunk([1, 2, 3, 4, 5], 3);
lo-fns can also be used as a drop-in replacement for Lodash:
import * as _ from "lo-fns";
const chunkedArray = _.chunk([1, 2, 3, 4, 5], 3);