Lightning-fast, tree-shakable utility functions for modern JavaScript applications
- β‘ Zero Dependencies - No lodash, no bloat, just pure ES2022+ utilities
- π³ Tree-shakable - Only import what you need, keep your bundle lean
- π§ TypeScript First - Full type safety with modern TypeScript features
- β‘ Performance Optimized - Uses native browser APIs and modern JavaScript features
- π¦ Modular Imports - Import from specific modules:
@nlabs/utils/objects
- π ESM Ready - Native ES modules with proper exports
npm install @nlabs/utils
# or
yarn add @nlabs/utils
# or
pnpm add @nlabs/utils
// Import everything (not recommended for production)
import { cloneDeep, merge, uniq, isString } from '@nlabs/utils';
// Import from specific modules (recommended)
import { cloneDeep, merge } from '@nlabs/utils/objects';
import { uniq, chunk } from '@nlabs/utils/arrays';
import { isString, isArray } from '@nlabs/utils/checks';
import { replace, trim } from '@nlabs/utils/strings';
Deep cloning, merging, property access, and object manipulation utilities.
- cloneDeep - Deep clone objects with native
structuredClone
- merge - Deep merge objects
- get - Safe property access with dot notation
- set - Immutable deep property assignment
- isEmpty - Check if value is empty
- debounce - Debounce function calls
- mapValues - Transform object values
- pick/omit - Select or exclude object properties
Array manipulation and utility functions.
- uniq - Remove duplicates from arrays
- chunk - Split arrays into chunks
- compact - Remove falsy values
- difference - Find array differences
- intersection - Find common elements
String manipulation and formatting utilities.
- replace - String replacement with regex support
- trim - Trim whitespace or custom characters
- case - Case conversion (camelCase, kebab-case, etc.)
- escape - HTML entity escaping
Type-safe validation functions.
- isString - Check if value is a string
- isArray - Check if value is an array
- isPlainObject - Check if value is a plain object
- isNumber - Check if value is a valid number
- isBoolean - Check if value is a boolean
- isFunction - Check if value is a function
- isNullish - Check if value is null or undefined
Input formatting and validation utilities.
- Formatter - Input masking and formatting
Data parsing and transformation utilities.
- String Parsers - Email, phone, ID parsing
- Number Parsers - Number formatting and conversion
- Object Parsers - Object transformation
- Boolean Parsers - Boolean parsing
Function | @nlabs/utils | lodash | Native |
---|---|---|---|
cloneDeep | β‘ 2.1x faster | 1x | β |
merge | β‘ 1.8x faster | 1x | β |
uniq | β‘ 1.5x faster | 1x | β‘ 1.2x |
isString | β‘ 1.3x faster | 1x | β‘ 1.1x |
# Full library (not recommended)
import * as utils from '@nlabs/utils';
# ~45KB gzipped
# Specific modules (recommended)
import { cloneDeep } from '@nlabs/utils/objects';
# ~2.1KB gzipped
import { uniq } from '@nlabs/utils/arrays';
# ~0.8KB gzipped
// Before (lodash)
import { cloneDeep, merge, uniq } from 'lodash';
// After (@nlabs/utils)
import { cloneDeep, merge } from '@nlabs/utils/objects';
import { uniq } from '@nlabs/utils/arrays';
We welcome contributions! Please see our Contributing Guide for details.
MIT License - see LICENSE for details.
Built with β€οΈ by Nitrogen Labs