Installations
npm install @pnpm/ramda
Developer
Developer Guide
Module System
CommonJS, ESM
Min. Node Version
Typescript Support
No
Node Version
16.16.0
NPM Version
8.11.0
Statistics
23,839 Stars
3,027 Commits
1,437 Forks
264 Watching
2 Branches
332 Contributors
Updated on 28 Nov 2024
Languages
JavaScript (99.82%)
Shell (0.12%)
Makefile (0.06%)
Total Downloads
Cumulative downloads
Total Downloads
18,812,978
Last day
5%
48,256
Compared to previous day
Last week
9.3%
240,378
Compared to previous week
Last month
-5.7%
974,867
Compared to previous month
Last year
308.6%
14,998,460
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
Dev Dependencies
29
Ramda
A practical functional library for JavaScript programmers.
Why Ramda?
There are already several excellent libraries with a functional flavor. Typically, they are meant to be general-purpose toolkits, suitable for working in multiple paradigms. Ramda has a more focused goal. We wanted a library designed specifically for a functional programming style, one that makes it easy to create functional pipelines, one that never mutates user data.
What's Different?
The primary distinguishing features of Ramda are:
-
Ramda emphasizes a purer functional style. Immutability and side-effect free functions are at the heart of its design philosophy. This can help you get the job done with simple, elegant code.
-
Ramda functions are automatically curried. This allows you to easily build up new functions from old ones simply by not supplying the final parameters.
-
The parameters to Ramda functions are arranged to make it convenient for currying. The data to be operated on is generally supplied last.
The last two points together make it very easy to build functions as sequences of simpler functions, each of which transforms the data and passes it along to the next. Ramda is designed to support this style of coding.
Introductions
- Introducing Ramda by Buzz de Cafe
- Why Ramda? by Scott Sauyet
- Favoring Curry by Scott Sauyet
- Why Curry Helps by Hugh Jackson
- Hey Underscore, You're Doing It Wrong! by Brian Lonsdorf
- Thinking in Ramda by Randy Coulman
Philosophy
Using Ramda should feel much like just using JavaScript. It is practical, functional JavaScript. We're not introducing lambda expressions in strings, we're not borrowing consed lists, we're not porting over all of the Clojure functions.
Our basic data structures are plain JavaScript objects, and our usual collections are JavaScript arrays. We also keep other native features of JavaScript, such as functions as objects with properties.
Functional programming is in good part about immutable objects and side-effect free functions. While Ramda does not enforce this, it enables such style to be as frictionless as possible.
We aim for an implementation both clean and elegant, but the API is king. We sacrifice a great deal of implementation elegance for even a slightly cleaner API.
Last but not least, Ramda strives for performance. A reliable and quick implementation wins over any notions of functional purity.
Installation
To use with node:
1$ npm install ramda
Then in the console:
1const R = require('ramda');
To use directly in Deno:
1import * as R from "https://deno.land/x/ramda@v0.27.2/mod.ts";
or using Nest.land:
1import * as R from "https://x.nest.land/ramda@0.27.2/mod.ts";
To use directly in the browser:
1<script src="path/to/yourCopyOf/ramda.js"></script>
or the minified version:
1<script src="path/to/yourCopyOf/ramda.min.js"></script>
or from a CDN, either cdnjs:
1<script src="//cdnjs.cloudflare.com/ajax/libs/ramda/0.30.0/ramda.min.js"></script>
or one of the below links from jsDelivr:
1<script src="//cdn.jsdelivr.net/npm/ramda@0.30.0/dist/ramda.min.js"></script> 2<script src="//cdn.jsdelivr.net/npm/ramda@latest/dist/ramda.min.js"></script>
(note that using latest
is taking a significant risk that ramda API changes could break your code.)
These script tags add the variable R
on the browser's global scope.
Or you can inject ramda into virtually any unsuspecting website using the bookmarklet.
Note for versions > 0.25
Ramda versions > 0.25 don't have a default export.
So instead of import R from 'ramda';
, one has to use import * as R from 'ramda';
Or better yet, import only the required functions via import { functionName } from 'ramda';
Note for ES6 module and browsers
In order to access to the ES6 module in browsers, one has to provide the content of the es directory (see below for the build instructions) and use import * as R from './node_modules/ramda/es/index.js';
Build
npm run build
creates es
, src
directories and updates both dist/ramda.js and dist/ramda.min.js
Partial Builds
It is possible to build Ramda with a subset of the functionality to reduce its file size. Ramda's build system supports this with command line flags. For example if you're using R.compose
, R.reduce
, and R.filter
you can create a partial build with:
npm run --silent partial-build compose reduce filter > dist/ramda.custom.js
This requires having Node/io.js installed and ramda's dependencies installed (just use npm install
before running partial build).
Documentation
Please review the API documentation.
Also available is our Cookbook of functions built from Ramda that you may find useful.
The Name
Ok, so we like sheep. That's all. It's a short name, not already
taken. It could as easily have been eweda
, but then we would be
forced to say eweda lamb!, and no one wants that. For non-English
speakers, lambs are baby sheep, ewes are female sheep, and rams are male
sheep. So perhaps ramda is a grown-up lambda... but probably not.
Running The Test Suite
Console:
To run the test suite from the console, you need to have mocha
installed:
npm install -g mocha
Then from the root of the project, you can just call
mocha
Alternately, if you've installed the dependencies, via:
npm install
then you can run the tests (and get detailed output) by running:
npm test
Browser:
You can use testem to
test across different browsers (or even headlessly), with livereloading of
tests. Install testem (npm install -g testem
) and run testem
. Open the
link provided in your browser and you will see the results in your terminal.
If you have PhantomJS installed, you can run testem -l phantomjs
to run the
tests completely headlessly.
Usage
For v0.25
and up, import the whole library or pick ES modules directly from the library:
1import * as R from 'ramda' 2 3const {identity} = R 4R.map(identity, [1, 2, 3])
Destructuring imports from ramda does not necessarily prevent importing the entire library. You can manually cherry-pick methods like the following, which would only grab the parts necessary for identity
to work:
1import identity from 'ramda/src/identity' 2 3identity()
Manually cherry picking methods is cumbersome, however. Most bundlers like Webpack and Rollup offer tree-shaking as a way to drop unused Ramda code and reduce bundle size, but their performance varies, discussed here. Here is a summary of the optimal setup based on what technology you are using:
- Webpack + Babel - use
babel-plugin-ramda
to automatically cherry pick methods. Discussion here, example here - Webpack only - use
UglifyJS
plugin for treeshaking along with theModuleConcatenationPlugin
. Discussion here, with an example setup here - Rollup - does a fine job properly treeshaking, no special work needed; example here
Typings
Translations
Funding
If you wish to donate to Ramda please see our Open Collective page. Thank you!
Acknowledgements
Thanks to J. C. Phillipps for the Ramda logo. Ramda logo artwork © 2014 J. C. Phillipps. Licensed Creative Commons CC BY-NC-SA 3.0.
No vulnerabilities found.
Reason
security policy file detected
Details
- Info: security policy file detected: SECURITY.md:1
- Info: Found linked content: SECURITY.md:1
- Info: Found disclosure, vulnerability, and/or timelines in security policy: SECURITY.md:1
- Info: Found text in security policy: SECURITY.md:1
Reason
no dangerous workflow patterns detected
Reason
no binaries found in the repo
Reason
license file detected
Details
- Info: project has a license file: LICENSE.txt:0
- Info: FSF or OSI recognized license: MIT License: LICENSE.txt:0
Reason
project is fuzzed
Details
- Info: JavaScriptPropertyBasedTesting integration found: test/add.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/always.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/collectBy.js:2
- Info: JavaScriptPropertyBasedTesting integration found: test/compose.js:5
- Info: JavaScriptPropertyBasedTesting integration found: test/curry.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/equals.js:5
- Info: JavaScriptPropertyBasedTesting integration found: test/flip.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/o.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/prop.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/reverse.js:3
- Info: JavaScriptPropertyBasedTesting integration found: test/symmetricDifference.js:3
Reason
Found 23/30 approved changesets -- score normalized to 7
Reason
dependency not pinned by hash detected -- score normalized to 5
Details
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/build.yml:14: update your workflow using https://app.stepsecurity.io/secureworkflow/ramda/ramda/build.yml/master?enable=pin
- Warn: GitHub-owned GitHubAction not pinned by hash: .github/workflows/coverage.yml:20: update your workflow using https://app.stepsecurity.io/secureworkflow/ramda/ramda/coverage.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/coverage.yml:52: update your workflow using https://app.stepsecurity.io/secureworkflow/ramda/ramda/coverage.yml/master?enable=pin
- Warn: third-party GitHubAction not pinned by hash: .github/workflows/coverage.yml:61: update your workflow using https://app.stepsecurity.io/secureworkflow/ramda/ramda/coverage.yml/master?enable=pin
- Info: 0 out of 2 GitHub-owned GitHubAction dependencies pinned
- Info: 0 out of 2 third-party GitHubAction dependencies pinned
- Info: 2 out of 2 npmCommand dependencies pinned
Reason
0 commit(s) and 2 issue activity found in the last 90 days -- score normalized to 1
Reason
detected GitHub workflow tokens with excessive permissions
Details
- Info: jobLevel 'contents' permission set to 'read': .github/workflows/coverage.yml:15
- Warn: no topLevel permission defined: .github/workflows/build.yml:1
- Warn: no topLevel permission defined: .github/workflows/coverage.yml:1
- Info: no jobLevel write permissions found
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
SAST tool is not run on all commits -- score normalized to 0
Details
- Warn: 0 commits out of 28 are checked with a SAST tool
Reason
23 existing vulnerabilities detected
Details
- Warn: Project is vulnerable to: GHSA-qwcr-r2fm-qrc7
- Warn: Project is vulnerable to: GHSA-grv7-fg5c-xmjg
- Warn: Project is vulnerable to: GHSA-pxg6-pf52-xh8x
- Warn: Project is vulnerable to: GHSA-3xgq-45jj-v275
- Warn: Project is vulnerable to: GHSA-434g-2637-qmqr
- Warn: Project is vulnerable to: GHSA-49q7-c7j4-3p7m
- Warn: Project is vulnerable to: GHSA-977x-g7h5-7qgw
- Warn: Project is vulnerable to: GHSA-f7q4-pwc6-w24p
- Warn: Project is vulnerable to: GHSA-fc9h-whq2-v747
- Warn: Project is vulnerable to: GHSA-rv95-896h-c2vc
- Warn: Project is vulnerable to: GHSA-qw6h-vgh9-j6wx
- Warn: Project is vulnerable to: GHSA-jchw-25xp-jwwc
- Warn: Project is vulnerable to: GHSA-cxjh-pqwp-8mfp
- Warn: Project is vulnerable to: GHSA-hxm2-r34f-qmc5
- Warn: Project is vulnerable to: GHSA-f8q6-p94x-37v3
- Warn: Project is vulnerable to: GHSA-9wv6-86v2-598j
- Warn: Project is vulnerable to: GHSA-gcx4-mw62-g8wm
- Warn: Project is vulnerable to: GHSA-m6fv-jmcg-4jfg
- Warn: Project is vulnerable to: GHSA-hxcc-f52p-wc94
- Warn: Project is vulnerable to: GHSA-cm22-4g7w-348p
- Warn: Project is vulnerable to: GHSA-qg8p-v9q4-gh34
- Warn: Project is vulnerable to: GHSA-g4rg-993r-mgx7
- Warn: Project is vulnerable to: GHSA-3h5v-q93c-6h6q
Score
5.3
/10
Last Scanned on 2024-11-18
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn MoreOther packages similar to @pnpm/ramda
ramda
A practical functional library for JavaScript programmers.
types-ramda
Dedicated types library for ramda
ramda-adjunct
Ramda Adjunct is the most popular and most comprehensive set of utilities for use with Ramda, providing a variety of useful, well tested functions with excellent documentation.
@types/ramda
TypeScript definitions for ramda