Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Rambda is a lightweight and fast utility library that provides a variety of functions for functional programming in JavaScript. It is a smaller and faster alternative to Ramda, offering a similar API but with a focus on performance and simplicity.
Currying
Currying is a technique of evaluating functions with multiple arguments, one at a time. Rambda's `curry` function allows you to transform a function so that it can be called with fewer arguments than it expects, returning a new function that takes the remaining arguments.
const R = require('rambda');
const add = R.curry((a, b) => a + b);
const add5 = add(5);
console.log(add5(3)); // 8
Composition
Function composition is the process of combining two or more functions to produce a new function. Rambda's `compose` function allows you to create a pipeline of functions that are executed from right to left.
const R = require('rambda');
const add = (a, b) => a + b;
const multiply = (a, b) => a * b;
const addAndMultiply = R.compose(R.multiply(2), R.add(3));
console.log(addAndMultiply(4)); // 14
Cloning
Cloning is the process of creating a deep copy of an object. Rambda's `clone` function allows you to create a deep copy of an object, ensuring that changes to the new object do not affect the original object.
const R = require('rambda');
const obj = {a: 1, b: 2};
const clonedObj = R.clone(obj);
console.log(clonedObj); // {a: 1, b: 2}
Filtering
Filtering is the process of selecting a subset of items from a collection based on a predicate function. Rambda's `filter` function allows you to filter elements in an array or object based on a provided predicate.
const R = require('rambda');
const isEven = n => n % 2 === 0;
const numbers = [1, 2, 3, 4, 5, 6];
const evenNumbers = R.filter(isEven, numbers);
console.log(evenNumbers); // [2, 4, 6]
Mapping
Mapping is the process of transforming each item in a collection using a provided function. Rambda's `map` function allows you to apply a function to each element in an array or object, returning a new array or object with the transformed elements.
const R = require('rambda');
const double = n => n * 2;
const numbers = [1, 2, 3, 4, 5];
const doubledNumbers = R.map(double, numbers);
console.log(doubledNumbers); // [2, 4, 6, 8, 10]
Lodash is a popular utility library that provides a wide range of functions for common programming tasks. It is more feature-rich compared to Rambda but also larger in size. Lodash focuses on performance and ease of use, offering a comprehensive set of tools for working with arrays, objects, strings, and more.
Underscore is another utility library that provides a variety of functional programming helpers. It is similar to Lodash but with a smaller footprint and fewer features. Underscore offers a core set of functions for working with collections, arrays, objects, and functions, making it a good choice for projects that need a lightweight utility library.
Ramda is a functional programming library for JavaScript that emphasizes immutability and pure functions. It offers a similar API to Rambda but with a larger set of functions and a focus on functional programming principles. Ramda is more feature-rich but also larger in size compared to Rambda.
Partial copy of Ramda using Ramda.compose and plain Javascript functions.
I admire Ramda but most of the time I use only small part of what it offers.
But even when I create custom Ramda build, I still am not completely happy with its size.
// npm i rambda
const R = require("rambda")
const result = R.compose(
R.filter(val => val>2),
R.flatten,
)([ [1], [2], [3], 4])
console.log(result) // => [3,4]
Rambda shadows only small part of the Ramda's API. A few things to note:
In some cases Ramda.__ can be replaced by Ramda.flip. Rambda is tested for compatability with Ramda.flip.
Performance was not the main reason for this library, it is side effect.
The benchmark coverage is small.
Its current status:
link to Ramda's docs for add method
link to Ramda's docs for adjust method
link to Ramda's docs for any method
link to Ramda's docs for append method
Just passing the original compose method of Ramda
link to Ramda's docs for compose method
link to Ramda's docs for contains method
link to Ramda's docs for drop method
link to Ramda's docs for dropLast method
link to Ramda's docs for filter method
link to Ramda's docs for flatten method
link to Ramda's docs for head method
link to Ramda's docs for init method
link to Ramda's docs for join method
link to Ramda's docs for last method
link to Ramda's docs for length method
link to Ramda's docs for map method
link to Ramda's docs for omit method
link to Ramda's docs for path method
link to Ramda's docs for prepend method
link to Ramda's docs for pick method
link to Ramda's docs for prop method
link to Ramda's docs for propEq method
link to Ramda's docs for range method
link to Ramda's docs for repeat method
link to Ramda's docs for replace method
link to Ramda's docs for sort method
link to Ramda's docs for sortBy method
link to Ramda's docs for split method
link to Ramda's docs for splitEvery method
link to Ramda's docs for subtract method
link to Ramda's docs for tail method
link to Ramda's docs for take method
link to Ramda's docs for takeLast method
link to Ramda's docs for test method
link to Ramda's docs for toLower method
link to Ramda's docs for toUpper method
link to Ramda's docs for type method
link to Ramda's docs for values method
link to Ramda's docs for uniq method
FAQs
Lightweight and faster alternative to Ramda with included TS definitions
The npm package rambda receives a total of 551,776 weekly downloads. As such, rambda popularity was classified as popular.
We found that rambda demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 0 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.