Package Exports
- nukes
- nukes/index.js
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (nukes) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
Nukes v2.0.0 - Enterprise-Grade JavaScript Utility Library
A comprehensive, modular utility library for modern JavaScript development, providing enterprise-grade tools for data manipulation, performance optimization, security utilities, and development productivity.
๐ Features
- ๐ Modular Architecture - Clean separation of concerns with dedicated modules
- โก Zero Dependencies - Lightweight and self-contained
- ๐ง TypeScript Ready - JSDoc annotations for excellent IDE support
- ๐ข Enterprise-Grade - Production-ready utilities for real-world applications
- ๐งช Comprehensive Testing - Extensive test coverage for all functionality
- ๐ Rich Documentation - Complete API documentation with examples
๐ฆ Installation
npm install nukes๐ฏ Quick Start
const nukes = require('nukes');
// Array utilities
const unique = nukes.array.deduplicate([1, 1, 2, 3, 3]);
const chunks = nukes.array.chunk([1, 2, 3, 4, 5, 6], 2);
// Object utilities
const cloned = nukes.object.deepClone(complexObject);
const value = nukes.object.get(obj, 'user.profile.name');
// String utilities
const camelCase = nukes.string.toCamelCase('hello-world');
const truncated = nukes.string.truncate(longText, 50);
// Validation utilities
const isValid = nukes.validation.isEmail('test@example.com');
// Security utilities
const uuid = nukes.security.generateUUID();
const masked = nukes.security.maskSensitiveData('1234567890', 2);
// Async utilities
await nukes.async.delay(1000);
const result = await nukes.async.retry(unstableFunction);
// Get package info
console.log(nukes.info());๐ API Documentation
๐ Array Module (nukes.array)
Advanced array manipulation and analysis utilities.
Core Functions
deduplicate(arr)- Remove duplicate values from arraycompact(arr)- Remove falsy values from arraychunk(arr, size)- Split array into chunks of specified sizeintersect(...arrays)- Find common elements across multiple arraysgroupBy(arr, criterion)- Group array elements by key or functionflatten(arr, depth)- Flatten nested arrays to specified depthshuffle(arr)- Randomly shuffle array elements
// Examples
const numbers = [1, 1, 2, 3, 3, 4, 5];
const unique = nukes.array.deduplicate(numbers); // [1, 2, 3, 4, 5]
const data = [1, null, 2, false, 3, '', 4];
const clean = nukes.array.compact(data); // [1, 2, 3, 4]
const large = [1, 2, 3, 4, 5, 6, 7, 8];
const chunks = nukes.array.chunk(large, 3); // [[1,2,3], [4,5,6], [7,8]]๐๏ธ Object Module (nukes.object)
Comprehensive object manipulation utilities.
Core Functions
deepClone(obj)- Create deep copy of objectdeepMerge(...objects)- Deep merge multiple objectsget(obj, path, defaultValue)- Get nested property using dot notationset(obj, path, value)- Set nested property using dot notationpick(obj, keys)- Create object with only specified propertiesomit(obj, keys)- Create object without specified propertieshas(obj, path)- Check if nested property exists
// Examples
const original = { a: 1, b: { c: 2, d: [3, 4] } };
const cloned = nukes.object.deepClone(original);
const user = { profile: { name: 'John', email: 'john@example.com' } };
const name = nukes.object.get(user, 'profile.name'); // 'John'
nukes.object.set(user, 'profile.age', 30);
// user.profile.age is now 30๐ค String Module (nukes.string)
Advanced string manipulation and formatting utilities.
Core Functions
toCamelCase(str)- Convert to camelCasetoKebabCase(str)- Convert to kebab-casetoSnakeCase(str)- Convert to snake_casetoTitleCase(str)- Convert to Title Casetruncate(str, length, suffix)- Truncate string with ellipsispad(str, length, char, direction)- Pad string to specified lengthescapeHtml(str)- Escape HTML special charactersnormalizeWhitespace(str)- Normalize whitespace in stringextractWords(str)- Extract words from string
// Examples
const text = 'hello world example';
nukes.string.toCamelCase(text); // 'helloWorldExample'
nukes.string.toKebabCase(text); // 'hello-world-example'
nukes.string.toSnakeCase(text); // 'hello_world_example'
const long = 'This is a very long text';
nukes.string.truncate(long, 15); // 'This is a ve...'โ
Validation Module (nukes.validation)
Comprehensive validation utilities for data types and formats.
Core Functions
isEmail(email)- Validate email addressisUrl(url)- Validate URLisAlpha(str)- Check if string contains only lettersisAlphaNumeric(str)- Check if string contains only letters and numbersisPhoneNumber(phone)- Validate phone numberisCreditCard(cardNumber)- Validate credit card number (Luhn algorithm)isDate(date)- Check if value is valid dateisJson(str)- Check if string is valid JSONisInRange(num, min, max)- Check if number is within rangeisStrongPassword(password, options)- Validate password strength
// Examples
nukes.validation.isEmail('test@example.com'); // true
nukes.validation.isUrl('https://example.com'); // true
nukes.validation.isStrongPassword('MyPass123!'); // true๐งน Console Module (nukes.console)
Enhanced console utilities for debugging and logging.
Core Functions
log(level, message, data)- Enhanced logging with timestamps and colorscreateTimer(label)- Create execution timertimeFunction(fn, label)- Time function executioncreateProgressBar(total, width)- Create console progress bartable(data, columns)- Display data in table formatprettyJson(data, indent)- Pretty print JSONclear(header)- Clear console with optional headergroup(label, fn)- Group console output
// Examples
nukes.console.log('info', 'Application started');
nukes.console.log('error', 'Database connection failed', error);
const timer = nukes.console.createTimer('API Call');
// ... do work ...
const elapsed = timer(); // Returns elapsed time in ms
nukes.console.table([
{ name: 'John', age: 30 },
{ name: 'Jane', age: 25 }
]);โก Async Module (nukes.async)
Asynchronous operation utilities and helpers.
Core Functions
delay(ms)- Create promise delayretry(fn, options)- Retry function with exponential backoffwithTimeout(fn, timeoutMs)- Execute function with timeoutbatchExecute(tasks, batchSize)- Execute promises in batchesdebounce(fn, delayMs)- Debounce function callsthrottle(fn, intervalMs)- Throttle function callspromisify(fn)- Convert callback function to promise
// Examples
await nukes.async.delay(1000); // Wait 1 second
const result = await nukes.async.retry(
() => unstableApiCall(),
{ maxAttempts: 3, baseDelay: 1000 }
);
const debouncedSave = nukes.async.debounce(saveFunction, 500);๐ Security Module (nukes.security)
Security utilities for data protection and validation.
Core Functions
generateRandomString(length, charset)- Generate random stringgenerateUUID()- Generate UUID v4simpleHash(str)- Create simple hash (non-cryptographic)base64Encode(str)- Base64 encode stringbase64Decode(str)- Base64 decode stringsanitizeString(str, options)- Sanitize potentially dangerous stringsmaskSensitiveData(str, visibleChars, maskChar)- Mask sensitive informationisSafeString(str, allowedPattern)- Check if string contains only safe charactersgenerateSecureToken(length)- Generate secure authentication token
// Examples
const uuid = nukes.security.generateUUID();
const token = nukes.security.generateSecureToken(32);
const encoded = nukes.security.base64Encode('Hello World');
const decoded = nukes.security.base64Decode(encoded);
const masked = nukes.security.maskSensitiveData('1234567890', 2);
// '12******90'๐ Convenience Methods
Access commonly used functions directly from the main object:
// These are shortcuts to frequently used functions
nukes.deduplicate(array); // โ nukes.array.deduplicate
nukes.deepClone(object); // โ nukes.object.deepClone
nukes.toCamelCase(string); // โ nukes.string.toCamelCase
nukes.isEmail(email); // โ nukes.validation.isEmail
nukes.delay(ms); // โ nukes.async.delay
nukes.generateUUID(); // โ nukes.security.generateUUID๐ Project Structure
nukes/
โโโ index.js # Main entry point
โโโ src/ # Source modules
โ โโโ array.js # Array utilities
โ โโโ object.js # Object utilities
โ โโโ string.js # String utilities
โ โโโ validation.js # Validation utilities
โ โโโ console.js # Console utilities
โ โโโ async.js # Async utilities
โ โโโ security.js # Security utilities
โโโ test.js # Test suite
โโโ package.json # Package configuration
โโโ README.md # This file๐งช Testing
Run the comprehensive test suite:
npm testThe test suite covers all 47+ utility functions across all modules with real-world scenarios.
๐ Performance
- Optimized Algorithms: All functions use efficient algorithms optimized for performance
- Memory Efficient: Minimal memory footprint with careful resource management
- Zero Dependencies: No external dependencies means faster installation and smaller bundle size
- Production Ready: Battle-tested utilities suitable for enterprise applications
๐ง Development
Package Information
// Get detailed package information
const info = nukes.info();
console.log(info);
// {
// name: 'nukes',
// version: '2.0.0',
// description: 'Enterprise-grade JavaScript utility library',
// modules: ['array', 'object', 'string', 'validation', 'console', 'async', 'security'],
// author: 'sureokaycool'
// }
// List all available functions
const functions = nukes.listFunctions();
console.log(functions);Requirements
- Node.js: >= 14.0.0
- Browser: Modern browsers with ES6+ support
๐ค Contributing
Contributions, issues, and feature requests are welcome!
- Fork the repository
- Create a feature branch
- Add tests for new functionality
- Ensure all tests pass
- Submit a pull request
๐ License
MIT License - see LICENSE file for details.
๐ค Author
sureokaycool
Built with โค๏ธ for the JavaScript community
๐ Why Choose Nukes?
- ๐ข Enterprise Ready: Production-tested utilities for real-world applications
- ๐ฆ Modular Design: Use only what you need, when you need it
- ๐ง Developer Friendly: Excellent TypeScript support and comprehensive documentation
- โก Performance Focused: Optimized algorithms and zero dependencies
- ๐ก๏ธ Reliable: Extensive testing and error handling
- ๐ Well Documented: Complete API documentation with practical examples
Transform your JavaScript development workflow with powerful, production-ready utilities. Install Nukes today and experience the difference! ๐