{"id":11579,"library":"prelude-ls","title":"Prelude.ls Functional Utility Library","description":"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.","status":"abandoned","version":"1.2.1","language":"javascript","source_language":"en","source_url":"git://github.com/gkz/prelude-ls","tags":["javascript","prelude","livescript","utility","ls","coffeescript","library","functional"],"install":[{"cmd":"npm install prelude-ls","lang":"bash","label":"npm"},{"cmd":"yarn add prelude-ls","lang":"bash","label":"yarn"},{"cmd":"pnpm add prelude-ls","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"This library is CommonJS-only and does not support ES module `import` syntax. The entire library is typically imported as a single object.","wrong":"import * as P from 'prelude-ls';","symbol":"P","correct":"const P = require('prelude-ls');"},{"note":"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`).","wrong":"import { map } from 'prelude-ls';","symbol":"map","correct":"const { map } = require('prelude-ls');"},{"note":"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.","symbol":"Obj.map","correct":"const { Obj } = require('prelude-ls');\nconst objectMap = Obj.map;"}],"quickstart":{"code":"const P = require('prelude-ls');\n\n// Example 1: Basic list mapping with a curried function\nconst addTwo = P.map(x => x + 2);\nconst numbers = [1, 2, 3, 4, 5];\nconst mappedNumbers = addTwo(numbers);\nconsole.log('Mapped numbers:', mappedNumbers); // Expected: [3, 4, 5, 6, 7]\n\n// Example 2: Filtering even numbers, demonstrating currying\nconst isEven = x => x % 2 === 0;\nconst filterEven = P.filter(isEven);\nconst evenNumbers = filterEven(numbers);\nconsole.log('Even numbers:', evenNumbers); // Expected: [2, 4]\n\n// Example 3: Folding (reducing) a list\nconst sum = P.fold((acc, x) => acc + x, 0);\nconst total = sum(numbers);\nconsole.log('Sum of numbers:', total); // Expected: 15\n\n// Example 4: Using an object-specific function\nconst data = { a: 1, b: 2, c: 3 };\nconst objMapValues = P.Obj.map(x => x * 10);\nconst mappedObject = objMapValues(data);\nconsole.log('Mapped object:', mappedObject); // Expected: { a: 10, b: 20, c: 30}\n","lang":"javascript","description":"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."},"warnings":[{"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.","message":"The `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.","severity":"breaking","affected_versions":">=1.2.1"},{"fix":"Always use `const P = require('prelude-ls');` for importing the library in Node.js and other CommonJS environments.","message":"`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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"Many 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.","severity":"gotcha","affected_versions":">=1.0.0"},{"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.","message":"The 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`.","severity":"gotcha","affected_versions":">=1.0.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"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.","cause":"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.","error":"ReferenceError: require is not defined"},{"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.","cause":"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.","error":"Error: Cannot find module 'prelude-ls'"},{"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.","cause":"This TypeScript error indicates that the type definitions for `prelude-ls` are either missing or incomplete, preventing the TypeScript compiler from recognizing exported functions.","error":"Property 'map' does not exist on type 'typeof import(\"prelude-ls\")'."}],"ecosystem":"npm"}