e: Modern TypeScript Utility Library

0.2.33 · active · verified Sun Apr 19

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.

Common errors

Warnings

Install

Imports

Quickstart

Demonstrates core functionalities like asynchronous delays, random number generation, and array shuffling, emphasizing the library's non-mutating design philosophy.

import { sleep, randFloat, shuffleArr } from 'e';

async function demonstrateE() {
  console.log('Starting e library demonstration...');

  // Demonstrate asynchronous delay
  console.log('Pausing for 1000 milliseconds...');
  await sleep(1000);
  console.log('Resumed after sleep.');

  // Generate a random floating-point number
  const randomNumericValue = randFloat();
  console.log(`Generated a random float between 0 and 1: ${randomNumericValue.toFixed(4)}`);

  // Shuffle an array without mutating the original
  const originalNumbers = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
  console.log('Original array:', originalNumbers);
  const shuffledNumbers = shuffleArr(originalNumbers);
  console.log('Shuffled array (new instance):', shuffledNumbers);
  console.log('Original array remains unchanged:', originalNumbers);

  // Verify non-mutation explicitly
  if (originalNumbers === shuffledNumbers) {
    console.error('CRITICAL ERROR: Array mutation detected! This should not happen in \'e\'.');
  } else {
    console.log('Non-mutation confirmed: original and shuffled arrays are distinct instances.');
  }
  console.log('e library demonstration complete.');
}

demonstrateE().catch(console.error);

view raw JSON →