JSPM

nukes

2.0.0
    • ESM via JSPM
    • ES Module Entrypoint
    • Export Map
    • Keywords
    • License
    • Repository URL
    • TypeScript Types
    • README
    • Created
    • Published
    • Downloads 11
    • Score
      100M100P100Q35209F
    • License MIT

    Advanced enterprise-grade JavaScript utility library providing comprehensive data manipulation, performance optimization, security utilities, and development productivity tools for modern applications.

    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

    npm version License: MIT Node.js

    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 array
    • compact(arr) - Remove falsy values from array
    • chunk(arr, size) - Split array into chunks of specified size
    • intersect(...arrays) - Find common elements across multiple arrays
    • groupBy(arr, criterion) - Group array elements by key or function
    • flatten(arr, depth) - Flatten nested arrays to specified depth
    • shuffle(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 object
    • deepMerge(...objects) - Deep merge multiple objects
    • get(obj, path, defaultValue) - Get nested property using dot notation
    • set(obj, path, value) - Set nested property using dot notation
    • pick(obj, keys) - Create object with only specified properties
    • omit(obj, keys) - Create object without specified properties
    • has(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 camelCase
    • toKebabCase(str) - Convert to kebab-case
    • toSnakeCase(str) - Convert to snake_case
    • toTitleCase(str) - Convert to Title Case
    • truncate(str, length, suffix) - Truncate string with ellipsis
    • pad(str, length, char, direction) - Pad string to specified length
    • escapeHtml(str) - Escape HTML special characters
    • normalizeWhitespace(str) - Normalize whitespace in string
    • extractWords(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 address
    • isUrl(url) - Validate URL
    • isAlpha(str) - Check if string contains only letters
    • isAlphaNumeric(str) - Check if string contains only letters and numbers
    • isPhoneNumber(phone) - Validate phone number
    • isCreditCard(cardNumber) - Validate credit card number (Luhn algorithm)
    • isDate(date) - Check if value is valid date
    • isJson(str) - Check if string is valid JSON
    • isInRange(num, min, max) - Check if number is within range
    • isStrongPassword(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 colors
    • createTimer(label) - Create execution timer
    • timeFunction(fn, label) - Time function execution
    • createProgressBar(total, width) - Create console progress bar
    • table(data, columns) - Display data in table format
    • prettyJson(data, indent) - Pretty print JSON
    • clear(header) - Clear console with optional header
    • group(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 delay
    • retry(fn, options) - Retry function with exponential backoff
    • withTimeout(fn, timeoutMs) - Execute function with timeout
    • batchExecute(tasks, batchSize) - Execute promises in batches
    • debounce(fn, delayMs) - Debounce function calls
    • throttle(fn, intervalMs) - Throttle function calls
    • promisify(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 string
    • generateUUID() - Generate UUID v4
    • simpleHash(str) - Create simple hash (non-cryptographic)
    • base64Encode(str) - Base64 encode string
    • base64Decode(str) - Base64 decode string
    • sanitizeString(str, options) - Sanitize potentially dangerous strings
    • maskSensitiveData(str, visibleChars, maskChar) - Mask sensitive information
    • isSafeString(str, allowedPattern) - Check if string contains only safe characters
    • generateSecureToken(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 test

    The 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!

    1. Fork the repository
    2. Create a feature branch
    3. Add tests for new functionality
    4. Ensure all tests pass
    5. 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! ๐Ÿš€