A tiny (2.7KB) functional programming library with autocurried functions and Maybe types for safe operations.
Barely Functional is a lightweight functional programming library for JavaScript that wraps native ES5/6 array methods with an autocurried, iteratee-first API. It includes core utilities like `curry` and `compose`, and uses `Maybe` types to safely handle operations that might fail, such as searching for missing elements in arrays.
JavaScript developers building small modules or applications where bundle size is critical, and those who want functional programming patterns without importing a large library like Ramda.
It offers a minimal, modular alternative to larger FP libraries, with individual imports to reduce footprint, and built-in safety via Fantasy Land-compliant Maybe types for error-prone operations.
tiny (2.7kb) functional programming library using native es5/6 operations
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Functions can be imported individually to minimize bundle size, with a basic subset as small as 1.1KB, allowing precise control over footprint. The README demonstrates this with examples like `const map = require('barely-functional/map')`.
All functions are curried by default with iteratee-first, data-last order, enabling easy function chaining and composition. The README shows this in action with `compose` examples, such as creating pipelines like `sumOfEven`.
Operations that can fail, like `find` or `nth`, return Fantasy Land-compliant Maybe types (Just or Nothing) to avoid runtime errors. The README explicitly states this guards against unsafe operations and provides functions like `fromMaybe` to handle results.
It provides functional wrappers for native ES5/6 methods like `map`, `filter`, and `reduce`, reducing learning curve for developers familiar with JavaScript arrays. The README lists these as core features with clear examples.
Written in ES6, it requires transpilation with Babel and bundling (e.g., webpack) for browser use, adding setup complexity. The README admits this, stating it 'will run on node.js v4.0 and up' but needs babel for browsers.
It lacks many advanced functional utilities found in libraries like Ramda, such as lenses or advanced composition tools, making it insufficient for complex FP needs. The README acknowledges this with 'But ramda is way better...' and focuses on minimalism.
The use of Maybe types for error handling introduces a learning curve and extra boilerplate for developers not versed in functional programming, as seen in functions like `find` that return `Just` or `Nothing` instead of raw values.
barely-functional is an open-source alternative to the following products: