Registry / serialization / prelude-ls

prelude-ls

JSON →
library1.2.1jsnpmunverified

prelude.ls is a functionally oriented utility library designed to simplify common programming tasks by providing a rich set of curried functions. It is primarily written in LiveScript and serves as the recommended base library for LiveScript projects, although it is fully usable within standard JavaScript environments. The library offers a wide array of utilities for lists, objects, strings, functions, and numbers, emphasizing a functional programming paradigm with functions like `map`, `filter`, and `fold` readily available. The current stable version is 1.2.1. Given its last update approximately six years ago (around April 2020), its release cadence is effectively inactive, indicating it is no longer actively maintained. A key differentiator is its deep integration with and recommendation for the LiveScript ecosystem, providing a Haskell-like prelude module, and its consistent use of currying across most functions. It predates widespread modern JavaScript module systems and exclusively functions via CommonJS modules.

npm install prelude-ls
INSTALL
IMPORT
SIG · PRELUDE-LS
P
prelude-ls
serializationjavascriptv1.2.1
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

P
const P = require('prelude-ls');
import * as P from 'prelude-ls';
This library is CommonJS-only and does not support ES module `import` syntax. The entire library is typically imported as a single object.
map
const { map } = require('prelude-ls');
import { map } from 'prelude-ls';
While possible to destructure, it's more common to import the entire `prelude-ls` object and access functions as `P.map` due to potential name conflicts (e.g., `List.map` vs `Obj.map`).
Obj.map
const { Obj } = require('prelude-ls'); const objectMap = Obj.map;
Some functions with conflicting names (like `map`) are available directly on sub-modules (e.g., `Obj`, `List`) within the main exported object. Accessing them through their specific module ensures correct behavior.

This quickstart demonstrates how to import `prelude-ls` using CommonJS and utilize its core functional programming utilities, including curried `map`, `filter`, `fold`, and an object-specific `Obj.map` function.

const P = require('prelude-ls'); // Example 1: Basic list mapping with a curried function const addTwo = P.map(x => x + 2); const numbers = [1, 2, 3, 4, 5]; const mappedNumbers = addTwo(numbers); console.log('Mapped numbers:', mappedNumbers); // Expected: [3, 4, 5, 6, 7] // Example 2: Filtering even numbers, demonstrating currying const isEven = x => x % 2 === 0; const filterEven = P.filter(isEven); const evenNumbers = filterEven(numbers); console.log('Even numbers:', evenNumbers); // Expected: [2, 4] // Example 3: Folding (reducing) a list const sum = P.fold((acc, x) => acc + x, 0); const total = sum(numbers); console.log('Sum of numbers:', total); // Expected: 15 // Example 4: Using an object-specific function const data = { a: 1, b: 2, c: 3 }; const objMapValues = P.Obj.map(x => x * 10); const mappedObject = objMapValues(data); console.log('Mapped object:', mappedObject); // Expected: { a: 10, b: 20, c: 30}
Debug
Known issues
breakingThe `prelude-ls` library is no longer actively maintained, with its last publish occurring approximately six years ago. This means it may not receive updates for new JavaScript features, security vulnerabilities, or compatibility with newer Node.js versions.
fix
Consider migrating to a modern, actively maintained functional utility library such as Ramda, Lodash/fp, or a native JavaScript functional approach for new projects. For existing projects, be aware of potential long-term compatibility risks.
affects: >=1.2.1
gotcha`prelude-ls` is a CommonJS-only module and does not support ES module `import` syntax natively. Attempting to use `import * as P from 'prelude-ls';` will result in module resolution errors in environments requiring ESM.
fix
Always use `const P = require('prelude-ls');` for importing the library in Node.js and other CommonJS environments.
affects: >=1.0.0
gotchaThe library does not ship with built-in TypeScript type definitions. While an unofficial `@types/prelude-ls` package exists, its accuracy and maintenance status may vary.
fix
Install the external type definitions using `npm install --save-dev @types/prelude-ls`. Be prepared to create or augment declaration files (`.d.ts`) for functions not fully covered or if types are outdated.
affects: >=1.0.0
gotchaMany functions in `prelude-ls` are curried by default, which can lead to unexpected partial application if not used correctly, especially for developers unfamiliar with this functional programming concept.
fix
Ensure you provide all expected arguments to a curried function or explicitly handle the partially applied function. Refer to the prelude.ls documentation on currying for detailed usage examples.
affects: >=1.0.0
gotchaThe main exported object of `prelude-ls` has many functions directly on it (e.g., `P.map`). However, some functions with the same name behave differently for different data structures (e.g., `List.map` vs `Obj.map`). The top-level `map` typically refers to `List.map`.
fix
When working with objects, explicitly use `P.Obj.map` to ensure you are applying the function intended for objects, and similarly for other specific data structure modules.
affects: >=1.0.0
Errors
Common errors & fixes
ReferenceError: require is not defined
Attempting to use `require('prelude-ls')` in a browser environment without a CommonJS bundler (like Webpack or Browserify) or trying to use `import` in a pure CommonJS Node.js project.
fix
For Node.js, ensure your project is configured for CommonJS modules. For browser usage, use a bundler that can resolve CommonJS modules, or include the `prelude-browser.js` file directly from the package's `browser` directory via a `<script>` tag.
Error: Cannot find module 'prelude-ls'
The package `prelude-ls` is not installed or the module resolution path is incorrect, or an ES module `import` statement is used in a CommonJS-only context that doesn't transpile it.
fix
First, ensure the package is installed: `npm install prelude-ls`. If in Node.js, verify you are using `require('prelude-ls')`. If using a bundler, check its configuration for module resolution.
Property 'map' does not exist on type 'typeof import("prelude-ls")'.
This TypeScript error indicates that the type definitions for `prelude-ls` are either missing or incomplete, preventing the TypeScript compiler from recognizing exported functions.
fix
Install the unofficial type definitions: `npm install --save-dev @types/prelude-ls`. If the issue persists for specific functions, you may need to manually augment the type declarations in a local `.d.ts` file.
Upgrade
Version history
1.2.1latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
4 hits · last 30 days
node
4
Resources
prelude-ls — npm install prelude-ls · libregistry