Get started with ramda CDN

MIT licensed

Ramda: JS functional library .

Tags:
  • functional

Stable version

Copied!

How to start using ramda CDN


// Import Ramda library
const R = require('https://cdn.cdnhub.io/ramda/0.29.1/ramda.min.js');

// Sample data
const data = [
  { name: 'Alice', age: 25 },
  { name: 'Bob', age: 30 },
  { name: 'Charlie', age: 20 },
];

// Function to filter objects based on age (> 25)
const filterOlder = R.filter(R.propSatisfies(R.over(R.lensProp('age'), R.gt(25))));

// Function to square the age value
const squareAge = R.map(R.over(R.lensProp('age'), R.multiply(R.identity, 2)));

// Apply filtering and mapping in one go
const result = R.pipe(
  filterOlder,
  squareAge
)(data);

console.log(result); // [{ name: 'Bob', age: 900 }]
Copied!
Copied!

All versions