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 🙏

© 2026 – Pkg Stats / Ryan Hefner

transformation-utils

v1.0.0

Published

A utility library for data transformation, type coercion, and value manipulation

Readme

Transformation Utils

A utility library for data transformation, type coercion, and value manipulation in JavaScript.

Installation

npm install transformation-utils

Usage

Import the entire library

import {
  AddValues,
  StrictNumberConverter,
  CoerceToType,
  StringifyValue,
} from 'transformation-utils';

Import specific modules

import { AddValues } from 'transformation-utils/addValues';
import { StrictNumberConverter } from 'transformation-utils/strictNumberConverter';
import { CoerceToType } from 'transformation-utils/coerceToType';
import { StringifyValue } from 'transformation-utils/stringifyValue';

API Reference

AddValues

Adds two values with intelligent type handling and fallback to string concatenation.

import { AddValues } from 'transformation-utils';

// Numeric addition
const result1 = new AddValues(5, 3).add(); // 8
const result2 = new AddValues('10', '20').add(); // 30

// String concatenation fallback
const result3 = new AddValues('hello', 'world').add(); // 'helloworld'
const result4 = new AddValues('123', 'abc').add(); // '123abc'

// Array concatenation
const result5 = new AddValues([1, 2], [3, 4]).add(); // [1, 2, 3, 4]

// Object merging
const result6 = new AddValues({ a: 1 }, { b: 2 }).add(); // {a: 1, b: 2}

StrictNumberConverter

Converts values to numbers with strict validation.

import { StrictNumberConverter } from 'transformation-utils';

// Valid conversions
const converter1 = new StrictNumberConverter('123');
console.log(converter1.convertToNumber()); // 123

const converter2 = new StrictNumberConverter('3.14');
console.log(converter2.convertToNumber()); // 3.14

// Nested object conversion
const converterNested = new StrictNumberConverter({ value: '456' }.value);
console.log(converterNested.convertToNumber()); // 456

// Invalid conversions throw errors
try {
  const converter3 = new StrictNumberConverter('abc');
  converter3.convertToNumber(); // Throws error
} catch (error) {
  console.log(error.message); // "There is no digits in your string"
}

CoerceToType

Coerces values to specific types with validation.

import { CoerceToType } from 'transformation-utils';

// String coercion
const stringResult = new CoerceToType('hello', 'string').coerce(); // 'hello'

// Number coercion
const numberResult = new CoerceToType('123', 'number').coerce(); // 123

// Boolean coercion
const boolResult = new CoerceToType('true', 'boolean').coerce(); // true

// Array coercion
const arrayResult = new CoerceToType('1,2,3', 'array').coerce(); // [1, 2, 3]

// Object coercion
const objectResult = new CoerceToType('{"a": 1}', 'object').coerce(); // {a: 1}

StringifyValue

Converts any value to a string representation.

import { StringifyValue } from 'transformation-utils';

const stringifier = new StringifyValue();

// Basic types
console.log(new StringifyValue(42).toString()); // "42
console.log(new StringifyValue(null)); // "null"

// Objects and arrays

console.log(new StringifyValue({ a: 1, b: 2 })).toString(); // '{"a":1,"b":2}'

// Functions
console.log(new StringifyValue(() => {})).toString; // "function"

Error Handling

The library includes a centralized error handling system:

import { error } from 'transformation-utils';

// The error helper is used internally by the classes
// You can also use it in your own code if needed
error('Custom error message');

Testing

Run the test suite:

npm test

Run tests with coverage:

npm run test:coverage

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests for new functionality
  5. Run the test suite
  6. Submit a pull request

License

ISC License - see LICENSE file for details.

Author

Natalia Novikova [email protected]