npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

test-stringx

v1.0.0

Published

A complete testing suite for the [stringx-js](https://www.stringx-js.com/) package, featuring **357 tests** across basic functionality, advanced scenarios, performance benchmarks, and security validations.

Downloads

3

Readme

StringX-JS Comprehensive Test Suite

A complete testing suite for the stringx-js package, featuring 357 tests across basic functionality, advanced scenarios, performance benchmarks, and security validations.

Quick Start

# Install dependencies
npm install

# Run all tests
npm test

# Run specific test categories
npm run test:basic       # Basic functionality tests
npm run test:advanced    # Advanced use cases and edge cases
npm run test:performance # Performance benchmarks
npm run test:security    # Security validations

Test Results Summary

✅ 344/357 tests passing (96.4% success rate)
⏱️  Total duration: ~781ms
📦 Package tested: stringx-js v1.1.2

Test Categories

1. Basic Tests (156 tests - ✅ 100% pass)

Tests core functionality of Str, Number, and Arr classes:

  • String case conversions (camel, snake, kebab, studly, title)
  • String extraction and manipulation
  • Number formatting and parsing
  • Array operations with dot notation
  • Type-safe getters
  • Fluent chaining

Run: npm run test:basic

2. Advanced Tests (144 tests - ✅ 94% pass)

Tests complex scenarios and real-world use cases:

  • Complex fluent chaining
  • Unicode and international text
  • Advanced pattern matching
  • Multi-language number spelling
  • Deeply nested data structures
  • E-commerce and API integration scenarios

Run: npm run test:advanced

3. Performance Tests (20+ tests - ✅ 95% pass)

Benchmarks performance with various workloads:

  • Large string operations (100k+ characters)
  • Bulk operations (1k-10k iterations)
  • Cache performance validation
  • Memory efficiency tests
  • Stress tests

Run: npm run test:performance

4. Security Tests (37 tests - ✅ 93% pass)

Validates security against common attacks:

  • XSS payload handling
  • SQL injection prevention
  • Command injection detection
  • Path traversal attempts
  • Prototype pollution (⚠️ vulnerability found)
  • ReDoS pattern detection
  • Secure random generation

Run: npm run test:security

Test Files

tests/
├── basic-str.test.js      # Str class basic tests (79 tests)
├── basic-number.test.js   # Number class basic tests (39 tests)
├── basic-arr.test.js      # Arr class basic tests (38 tests)
├── advanced-str.test.js   # Str advanced tests (74 tests)
├── advanced-number.test.js # Number advanced tests (39 tests)
├── advanced-arr.test.js   # Arr advanced tests (31 tests)
├── performance.test.js    # Performance benchmarks (20+ tests)
└── security.test.js       # Security tests (37 tests)

Key Features Tested

✅ String Operations (Str)

  • 95+ methods including camel, snake, kebab case conversions
  • Pattern matching with regex
  • UUID/ULID/password generation
  • Slug generation for URLs
  • Base64 encoding/decoding
  • Pluralization and singularization
  • Fluent chaining with of()

✅ Number Operations (Number)

  • Number formatting with locales
  • Currency formatting (USD, EUR, GBP, JPY, etc.)
  • File size formatting (B, KB, MB, GB, TB)
  • Human-readable numbers (1K, 2M, 3B)
  • Number spelling in 16+ languages
  • Ordinal numbers (1st, 2nd, 3rd)
  • Percentage formatting

✅ Array Operations (Arr)

  • Dot notation for nested data (user.profile.email)
  • Plucking and mapping
  • Filtering and sorting
  • Type-safe getters (boolean, integer, float, string, array)
  • Array flattening and collapsing
  • CSS class/style generation
  • Query string building

Performance Highlights

| Operation | Workload | Performance | |-----------|----------|-------------| | String operations | 100k chars | < 100ms | | UUID generation | 1000 UUIDs | < 200ms | | Number formatting | 10k numbers | < 200ms | | Dot notation access | 10k accesses | < 100ms | | Array filtering | 10k items | < 200ms | | Fluent chaining | 1000 chains | < 100ms |

Security Findings

✅ Secure Features

  • Cryptographically secure UUID/ULID generation
  • XSS payload sanitization
  • SQL injection prevention
  • Secure password generation
  • Sensitive data masking

⚠️ Security Concerns

  1. Prototype Pollution: Arr.set() allows setting __proto__ which pollutes Object.prototype
    • Workaround: Never use __proto__, constructor, or prototype as keys
  2. ReDoS Risk: Some regex operations could be vulnerable to denial of service
    • Mitigation: Validate and sanitize regex patterns from user input

Usage Examples

String Operations

import Str from 'stringx-js';

// Fluent chaining
const result = Str.of('  [email protected]  ')
    .trim()
    .lower()
    .before('@')
    .replace('.', '_')
    .camel()
    .toString(); // 'johnDoe'

// UUID generation
const id = Str.uuid(); // 'e3c2d7a4-5c8e-4b2f-...'

// Slug generation
const slug = Str.slug('Hello World 2024'); // 'hello-world-2024'

Number Operations

import { Number } from 'stringx-js';

// Format numbers
Number.format(1234567.89, 2); // '1,234,567.89'

// Currency
Number.currency(1234.56); // '$1,234.56'

// File sizes
Number.fileSize(1024 * 1024); // '1 MB'

// Human-readable
Number.abbreviate(1500000); // '2M'

// Spell in multiple languages
Number.spell(42, 'en'); // 'forty-two'
Number.spell(42, 'fr'); // 'quarante-deux'

Array Operations

import { Arr } from 'stringx-js';

// Dot notation
const data = { user: { name: 'John', profile: { email: '[email protected]' } } };
Arr.get(data, 'user.profile.email'); // '[email protected]'

// Pluck values
const users = [
    { name: 'John', age: 30 },
    { name: 'Jane', age: 25 }
];
Arr.pluck(users, 'name'); // ['John', 'Jane']

// Flatten nested data
const nested = { 'user.name': 'John', 'user.age': 30 };
Arr.undot(nested); // { user: { name: 'John', age: 30 } }

Requirements

  • Node.js >= 14.0.0
  • npm or yarn

Contributing

Feel free to add more tests or improve existing ones:

  1. Fork the repository
  2. Add your tests in the appropriate file
  3. Ensure tests follow the existing structure
  4. Run npm test to verify
  5. Submit a pull request

Test Structure

Each test file uses Node.js native test runner with this structure:

import { describe, it } from 'node:test';
import assert from 'node:assert';

describe('Feature Name', () => {
    describe('Sub-feature', () => {
        it('should do something', () => {
            assert.strictEqual(actual, expected);
        });
    });
});

Reporting Issues

If you find bugs or security vulnerabilities:

  1. Check TEST_SUMMARY.md for known issues
  2. Create an issue at stringx-js GitHub
  3. Include test case and expected behavior

Resources

  • Official Website: https://www.stringx-js.com/
  • NPM Package: https://www.npmjs.com/package/stringx-js
  • GitHub: https://github.com/AymanAtmeh/stringx-js
  • Documentation: See README in node_modules/stringx-js

License

MIT


Created for: stringx-js v1.1.2 Test Coverage: 96.4% (344/357 tests passing) Last Updated: October 31, 2025