pure-conditions is a JavaScript utility library providing a collection of pure, isolated functions designed to simplify common conditional logic. It offers methods for tasks like checking for duplicates in arrays, determining if an object or array is empty, validating email formats, and string manipulations such as checking if a string ends with a specific substring. The current stable version is 1.2.3. As a small, focused utility, it doesn't adhere to a strict release cadence but updates as new common conditions are identified or minor improvements are made. Its key differentiators include its adherence to pure function principles (no side effects, predictable output) and the complete isolation of functions, which benefits bundlers and compilers by allowing for efficient tree-shaking and minimal bundle sizes. It focuses on functional programming paradigms for robustness and testability.
npm install pure-conditionsVerified import paths — ran on the pinned version, not inferred.
Demonstrates importing and using several utility functions like `hasDuplicates`, `isEmpty`, `endsWith`, and `isEmail` to perform common conditional checks.
Always use named imports with destructuring: `import { functionName } from 'pure-conditions';`No fix needed, this is by design. Understand that functions like `hasDuplicates` do not change the array, they only evaluate it.
For modern Node.js and bundlers, use ESM `import`. If targeting older environments, ensure your build setup transpiles ESM to CommonJS, or stick to `require()` if feasible for your module type.
Ensure you are using named imports with destructuring: `import { hasDuplicates } from 'pure-conditions';` or `const { hasDuplicates } = require('pure-conditions');`Either convert your file/project to an ESM module by setting `'type': 'module'` in `package.json` or rename the file to `.mjs`, or use CommonJS `require`: `const { someFunction } = require('pure-conditions');`No dependency data recorded yet.