lamb
v0.61.1
Published
A lightweight, and docile, JavaScript library to help embracing functional programming.
Downloads
227
Maintainers
Readme
Lamb, because it's docile like a lamb.
A lightweight, and docile, JavaScript (ES5) library to help embracing functional programming.
Documentation.
The API documentation is here.
Installation and basic usage.
Install it with npm
:
npm install lamb
Require it in node.js:
const _ = require("lamb");
Since version 0.57.0, Lamb is splitted in ES modules and can take advantage of tree-shaking capabilities of module bundlers:
import * as _ from "lamb";
You can also import only the functions you want to use:
import { compose, map } from "lamb";
In a browser, simply include the version you want from the dist
folder:
<script src="dist/lamb.js"></script>
or
<script src="dist/lamb.min.js"></script>
Doing so a lamb
variable will be created in the global object.
The source map for the minified file is in the same dist
folder.
Since version 0.58.0 there is also a one file ES modules build, always in the dist
folder, named lamb.mjs
(previously lamb.esm.js
) and its minified version lamb.min.mjs
(previously lamb.esm.min.js
).
Lamb it's also delivered on a CDN, courtesy of cdnjs, jsDelivr and unpkg:
<script src="https://cdnjs.cloudflare.com/ajax/libs/lamb/0.61.1/lamb.min.js"></script>
<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/lamb.min.js"></script>
<script src="https://unpkg.com/[email protected]/dist/lamb.min.js"></script>
Please note that Lamb is served by jsDelivr since version 0.42.0.
You can try it right now in your browser, too.
Semantic Versioning.
Lamb uses semantic versioning and please be aware that, as long as the major version is 0
, any
bump in the minor version could involve a breaking change in the API.
You can check the recent or the full changelog to see if your code is affected.
Frequently self-asked questions.
Is another JavaScript library really needed? Don't know, really. The story here is that I like to write my own code and, time permitting, to even reinvent the wheel: it's part of my learning process. This library is only a means for me to gather some utilities I wrote, clean them up a bit and put them together with some new tools to make a documented, reusable package.
Are your wheels rounder? Not at all, but I do try my best to add better suspension; and you do realise that you're reading a guy talking to himself, don't you?
Why you say "to help embracing functional programming"? Is it for beginners? No, it's a utility library for everyone; beginners included, though. Lamb embraces functional concepts and encourages users to take advantage of them, but without forcing anyone to change his style. Experienced functional programmers will feel immediately at home, and beginners will discover that the library is able to adapt to them while their knowledge grows.
Why ECMAScript 5? Because this is simply me tidying up some old code, and will hopefully be my goodbye to ES5 before fully diving into the world of transpilers.
What about ES4 environments? In my make-believe world they don't exist, but in case I can be proven wrong you can load some shims / polyfills before my library. There's plenty of those in the JavaScript Reference on MDN, and there are many pre-made packages as well out there.
Are there plans for the future? Absolutely yes: this isn't a complete work at all, only a first public release. I need better documentation and examples for starters, and I also want to add a bunch of other functions and concepts into the mix.
I really like Lamb's logo: are you the designer? I like it a lot too and, no, it isn't my doing: the author is a very talented designer who never signs his works by choice and doesn't want to be credited for it. Other than being eternally grateful, the least I can do is offer my services as a middleman and put you in touch if you need his craft.
Why "Lamb"? See the main header: because it's docile like a lamb. Lamb adapts to you without needing you to adapt.
Recent changes
You can also check the full changelog.
v0.61.1 - 2023/11/15
- Fully compatible with versions down to 0.59.0
- Fixed
reduceWith
andreduceRightWith
not using the initial value whenreduce
was called with more than three arguments
v0.61.0 - 2022/11/09
- Fully compatible with versions down to 0.59.0
- Added
symmetricDifference
- Big performance improvements to the following functions in ES6 aware environments:
difference
,intersection
,symmetricDifference
,union
,unionBy
,uniques
anduniquesBy
- Gave a new coat of paint to all tests
- Updated doc comments and streamlined some parameter names
- Dropped TravisCI for Github actions
v0.60.0 - 2021/03/08
- Fully compatible with versions down to 0.59.0
- Added
mean
,median
andreplace
v0.59.2 - 2020/07/17
- Fully compatible with version 0.59.0
- Updated "exports" property in
package.json
to address the issue where some tools couldn't access the manifest file. See https://github.com/nodejs/node/issues/33460. - Got rid of ES5 in all examples
v0.59.0 - 2020/07/07
- Sorry for all the renaming, but I'm in the process of freezing the API and wanted to tackle some inconsistencies in naming choices.
- Updated to support Node.js ES modules (and renamed ES modules build to
lamb.mjs
) - Added
split
andsplitBy
- API change: renamed
pick
topickIn
andpickKeys
topick
- API change: renamed
skip
toskipIn
andskipKeys
toskip
- API change: renamed
rename
torenameIn
andrenameKeys
torename
- API change: renamed
pluck
topluckFrom
andpluckKey
topluck
- API change: renamed
case
tocasus
to avoid confusion and clashing with the switch statement's case - API change: renamed
invoker
andinvokerOn
toinvoke
andinvokeOn
- Fixed
.DS_STORE
file leaking again in thedist
folder