Skip to content

πŸ¦€ ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. πŸͺ€

License

Notifications You must be signed in to change notification settings

igorskyflyer/npm-extendable-string

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

68 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

ExtendableString


πŸ¦€ ExtendableString allows you to create strings on steroids that have custom
transformations applied to them, unlike common, plain strings. πŸͺ€



πŸ’– Support further development

I work hard for every project, including this one
and your support means a lot to me!

Consider buying me a coffee. β˜•
Thank you for supporting my efforts! πŸ™πŸ˜Š


Donate to igorskyflyer

@igorskyflyer




πŸ“ƒ Table of contents



πŸ•΅πŸΌ Usage

Install it by executing:

npm i '@igor.dvlpr/extendable-string'

🀹🏼 API


Warning

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.mts

import { ExtendableString } from '@igor.dvlpr/extendable-string'

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

example.mts

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

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.


🧬 Related

@igor.dvlpr/keppo

🎑 Parse, manage, compare and output SemVer-compatible version numbers. πŸ›‘


@igor.dvlpr/astro-escaped-component

πŸƒπŸ»β€β™‚οΈβ€βž‘οΈ An Astro component that holds only HTML-encoded content. πŸ“œ


@aria-toolkit/shared

πŸ‘» Shared resources between Aria modules. πŸ¦β€β¬›


@igor.dvlpr/windev

πŸƒ Provides ways of checking whether a path is a legacy Windows device. πŸ’Ύ


@igor.dvlpr/mapped-replacer

πŸ—Ί Zero-dependency Map and RegExp based string replacer with Unicode support. 🍁



πŸ‘¨πŸ»β€πŸ’» Author

Created by Igor Dimitrijević (@igorskyflyer).

About

πŸ¦€ ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. πŸͺ€

Topics

Resources

License

Stars

Watchers

Forks

Sponsor this project