Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

@igorskyflyer/extendable-string

igorskyflyer115MIT2.1.0TypeScript support: included

🦀 ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. 🪀

string, string-utils, string-manipulation, string-transformation, string-processing, abstract-class, extendable, typescript, typescript-library, custom-transform, immutable-string, string-wrapper, text-processing, string-utility, string-helper, igor dimitrijević, igorskyflyer

readme

Icon of ExtendableString

ExtendableString


🦀 ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. 🪀



📃 Table of Contents



🤖 Features

  • 🚀 Instantly applies custom string transformations on creation
  • 🔄 Updates value with transformation applied automatically
  • 🛡️ Validates transformation function before use
  • 🧩 Designed for easy extension via sub-classing
  • 📦 Encapsulates logic with private fields for safety
  • 📝 Provides clean string output through the toString() method
  • ⚡ Ensures consistent transformed state at all times


🕵🏼 Usage

Install it by executing any of the following, depending on your preferred package manager:

pnpm add @igorskyflyer/extendable-string
yarn add @igorskyflyer/extendable-string
npm i @igorskyflyer/extendable-string


🤹🏼 API

💡 TIP

First Steps

Do NOT instantiate a new object from the ExtendableString class, extend it instead.


constructor(raw, transformFn)

Creates an ExtendableString instance.


raw - The string input to transform.

transformFn - The transformation function to apply to the string.

Will throw an error if the transformation function is not supplied.


value: string

Gets the transformed string or sets a new value that will be transformed automatically.


toString(): string

Gets the transformed string value.

Returns the transformed string.



🗒️ Examples

UpperCaseString.ts

import { ExtendableString } from '@igorskyflyer/extendable-string'

export class UpperCaseString extends ExtendableString {
  constructor(value: string) {
    super(value, (str) => str.toUpperCase())
  }
}

example.ts

import { UpperCaseString } from './UpperCaseString.js'

const test = new UpperCaseString('aaaa')
console.log(test.value) // Outputs 'AAAA'

const example = new UpperCaseString('aaaa')
example.value = 'hello'
console.log(test.value) // Outputs 'HELLO'


📝 Changelog

📑 The changelog is available here, CHANGELOG.md.



🪪 License

Licensed under the MIT license which is available here, MIT license.



💖 Support

I work hard for every project, including this one and your support means a lot to me!
Consider buying me a coffee. ☕

Donate to igorskyflyer

Thank you for supporting my efforts! 🙏😊


@igorskyflyer/keppo

🎡 Parse, manage, compare and output SemVer-compatible version numbers. 🛡


@igorskyflyer/astro-escaped-component

🏃🏻‍♂️‍➡️ An Astro component that holds only HTML-encoded content. 📜


@igorskyflyer/normalized-string

💊 NormalizedString provides you with a String type with consistent line-endings, guaranteed. 📮


@igorskyflyer/windev

🍃 Provides ways of checking whether a path is a legacy Windows device. 💾


@igorskyflyer/mapped-replacer

🗺 Zero-dependency Map and RegExp based string replacer with Unicode support. 🍁




👨🏻‍💻 Author

Created by Igor Dimitrijević (@igorskyflyer).

changelog

📒 Changelog

of @igorskyflyer/extendable-string


v2.1.0 (04-Sep-2025)

  • 💻 dev: upgrade Node to >= v22
  • 💻 dev: upgrade dependencies


v2.0.0 (29-Jul-2024)

  • ❌ BREAKING: migrate to Node v20 and ESM-only
  • ✅ fix: minor improvements