{"id":10773,"library":"e","title":"e: Modern TypeScript Utility Library","description":"The 'e' library is a modern, universal utility collection specifically designed for TypeScript and Node.js environments. Currently at version 0.2.33, it emphasizes immutability, ensuring that none of its functions mutate or alter any passed arguments, promoting predictable side-effect-free code. Its design philosophy centers on simplicity, with each exported function serving a single, clear purpose. While currently in an early 0.x.x release cycle, it aims to provide a reliable, lightweight alternative to larger utility libraries, focusing on a clean API and strong TypeScript support from the ground up. The library is actively developed and geared towards contemporary JavaScript development practices.","status":"active","version":"0.2.33","language":"javascript","source_language":"en","source_url":"https://github.com/gc/e","tags":["javascript","typescript","ts","utility","util","lodash"],"install":[{"cmd":"npm install e","lang":"bash","label":"npm"},{"cmd":"yarn add e","lang":"bash","label":"yarn"},{"cmd":"pnpm add e","lang":"bash","label":"pnpm"}],"dependencies":[],"imports":[{"note":"The 'e' library is primarily designed for ES Modules (ESM). CommonJS `require()` is not officially supported and may lead to issues.","wrong":"const { sleep } = require('e');","symbol":"sleep","correct":"import { sleep } from 'e';"},{"note":"All utilities are named exports; there is no default export from the 'e' package.","wrong":"import randFloat from 'e';","symbol":"randFloat","correct":"import { randFloat } from 'e';"},{"symbol":"shuffleArr","correct":"import { shuffleArr } from 'e';"}],"quickstart":{"code":"import { sleep, randFloat, shuffleArr } from 'e';\n\nasync function demonstrateE() {\n  console.log('Starting e library demonstration...');\n\n  // Demonstrate asynchronous delay\n  console.log('Pausing for 1000 milliseconds...');\n  await sleep(1000);\n  console.log('Resumed after sleep.');\n\n  // Generate a random floating-point number\n  const randomNumericValue = randFloat();\n  console.log(`Generated a random float between 0 and 1: ${randomNumericValue.toFixed(4)}`);\n\n  // Shuffle an array without mutating the original\n  const originalNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];\n  console.log('Original array:', originalNumbers);\n  const shuffledNumbers = shuffleArr(originalNumbers);\n  console.log('Shuffled array (new instance):', shuffledNumbers);\n  console.log('Original array remains unchanged:', originalNumbers);\n\n  // Verify non-mutation explicitly\n  if (originalNumbers === shuffledNumbers) {\n    console.error('CRITICAL ERROR: Array mutation detected! This should not happen in \\'e\\'.');\n  } else {\n    console.log('Non-mutation confirmed: original and shuffled arrays are distinct instances.');\n  }\n  console.log('e library demonstration complete.');\n}\n\ndemonstrateE().catch(console.error);","lang":"typescript","description":"Demonstrates core functionalities like asynchronous delays, random number generation, and array shuffling, emphasizing the library's non-mutating design philosophy."},"warnings":[{"fix":"Pin to exact versions in your `package.json` (e.g., `\"e\": \"0.2.33\"` instead of `\"^0.2.33\"`) and manually update after reviewing release notes.","message":"As a 0.x.x version library, the API of 'e' is considered unstable and subject to frequent breaking changes with minor version updates. Always review the changelog before upgrading.","severity":"breaking","affected_versions":">=0.1.0"},{"fix":"Always assign the return value of 'e' functions to a new variable or explicitly reassign it to the original variable if mutation is desired (though not recommended for 'e' patterns). For example: `const newArr = shuffleArr(oldArr);`","message":"All functions in 'e' are designed to be immutable, meaning they return new instances (e.g., a new array after shuffling) rather than modifying the input arguments. Failing to reassign the return value can lead to using stale data.","severity":"gotcha","affected_versions":">=0.1.0"},{"fix":"Ensure your project uses `import` statements and is configured for ESM. If you must use CommonJS, consider a transpilation step or a tool like `cjstoesm` if available, or check for dual-packaging support in future versions.","message":"The library is primarily built for ES Modules (ESM) environments. Using CommonJS `require()` in a Node.js project not configured for dual-package mode might result in import errors or unexpected behavior.","severity":"gotcha","affected_versions":">=0.1.0"}],"env_vars":null,"last_verified":"2026-04-19T00:00:00.000Z","next_check":"2026-07-18T00:00:00.000Z","problems":[{"fix":"Change `const { symbol } = require('e');` to `import { symbol } from 'e';`. Ensure your `package.json` has `\"type\": \"module\"` if you are in an ESM project, or use a build tool to transpile.","cause":"Attempting to use `require()` to import `e` in an ES Module context, or in a Node.js project not configured for CommonJS compatibility.","error":"TypeError: require is not a function"},{"fix":"Verify the symbol name against the 'e' documentation or source code. Ensure it is a named export, as 'e' does not use default exports. For example, use `import { correctFunctionName } from 'e';`.","cause":"Attempting to import a symbol (e.g., `MyFunction`) that either does not exist, is misspelled, or is not a named export from the 'e' package.","error":"TS2305: Module ''e'' has no exported member 'MyFunction'."},{"fix":"Always ensure arguments passed to 'e' functions are of the expected type. Also, remember that 'e' functions are immutable; always capture their return value: `const newArray = shuffleArr(myArray);`","cause":"This error can occur if you pass `undefined` or `null` to a function expecting an array, or if you call a method on the result of an immutable operation without reassigning it, expecting the original to be modified.","error":"TypeError: Cannot read properties of undefined (reading 'length')"}],"ecosystem":"npm"}