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

@nan0web/transformer

v1.0.0

Published

Basic and agnostic transformer.

Downloads

5

Readme

@nan0web/transformer

Basic and agnostic transformer.

|Package name|Status|Documentation|Test coverage|Features|Npm version| |---|---|---|---|---|---| |@nan0web/transformer |🟢 99.7% |🧪 English 🏴󠁧󠁢󠁥󠁮󠁧󠁿Українською 🇺🇦 |🟢 100.0% |✅ d.ts 📜 system.md 🕹️ playground |— |

Description

The @nan0web/transformer package provides a lightweight and flexible foundation for sequential data transformation. It allows you to chain multiple transformation steps (transformers) that can encode and decode data in a predictable, composable way.

A Transformer instance collects transformer objects and applies their encode or decode methods in sequence. Each transformer may implement one or both methods, and the process is fully asynchronous, allowing integration with async operations.

This package is ideal for:

  • Building data pipelines (e.g., encryption, compression, formatting)
  • Creating serialization/deserialization layers
  • Developing middleware-like processing sequences
  • Any scenario where data must pass through multiple stages of transformation

Installation

How to install with npm?

npm install @nan0web/transformer

How to install with pnpm?

pnpm add @nan0web/transformer

How to install with yarn?

yarn add @nan0web/transformer

Usage

Basic Transformation

Create a Transformer and add transformer objects with encode and/or decode methods.

How to chain multiple encoders?

import { Transformer } from '@nan0web/transformer'
const transformer = new Transformer()

const upperCase = {
	encode: async (data) => data.toUpperCase(),
	decode: async (data) => data.toLowerCase()
}

const addPrefix = {
	encode: async (data) => `[ENC] ${data}`,
	decode: async (data) => data.replace(/^\[ENC\]\s/i, '')
}

transformer.addTransformer(upperCase)
transformer.addTransformer(addPrefix)

const encoded = await transformer.encode("hello world")
console.info(encoded) // [ENC] HELLO WORLD

const decoded = await transformer.decode(encoded)
console.info(decoded) // hello world

How to add and remove transformers dynamically?

import { Transformer } from '@nan0web/transformer'
const transformer = new Transformer()

const spyTransformer = {
	encode: async (data) => `${data} • spy`,
	decode: async (data) => data.replace(/ • spy$/, '')
}

transformer.addTransformer(spyTransformer)
console.info(transformer.transformers) // ← [spyTransformer]

transformer.removeTransformer(spyTransformer)
console.info(transformer.transformers) // ← []

Skip Non-Implementing Transformers

Transformers without encode or decode methods are skipped automatically.

How to ensure only transformers with encode/decode are applied?

import { Transformer } from '@nan0web/transformer'
const transformer = new Transformer()

const validEncoder = {
	encode: async (data) => data + "•encoded"
}

const invalidTransformer = {
	process: async (data) => data
}

transformer.addTransformer(validEncoder)
transformer.addTransformer(invalidTransformer)

const result = await transformer.encode("data")
console.info(result) // data•encoded

Asynchronous Transformers

All transformations are async, enabling integration with promises and async operations.

How to use asynchronous transformations with delays?

import { Transformer } from '@nan0web/transformer'
const transformer = new Transformer()

const delayEncode = {
	encode: async (data) => {
		await new Promise(r => setTimeout(r, 10))
		return `[DELAYED] ${data}`
	}
}

transformer.addTransformer(delayEncode)
const result = await transformer.encode("test")
console.info(result) // [DELAYED] test

API

Transformer

A class that manages a sequence of transformers.

  • Constructor

    • new Transformer() — creates an empty transformer chain.
  • Properties

    • transformers – array of transformer objects added via addTransformer.
  • Methods

    • encode(data) – applies all encode methods in sequence.
    • decode(data) – applies all decode methods in sequence.
    • addTransformer(t) – adds a transformer object to the chain.
    • removeTransformer(t) – removes a specific transformer object from the chain.

All methods return promises and are await-safe.

Java•Script

Uses d.ts files for autocompletion

CLI Playground

Run local experiments using the playground script.

How to run playground script?

# Run the playground
npm run play

Contributing

This project follows strict testing and linting rules.

How to contribute? - check here

License

Licensed under ISC.

How to license ISC? - check here