Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/igorskyflyer/npm-extendable-string
π¦ ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. πͺ
https://github.com/igorskyflyer/npm-extendable-string
back-end browser class extend extendable igorskyflyer javascript js node npm string text transform ts typescript utility vitest
Last synced: 2 days ago
JSON representation
π¦ ExtendableString allows you to create strings on steroids that have custom transformations applied to them, unlike common, plain strings. πͺ
- Host: GitHub
- URL: https://github.com/igorskyflyer/npm-extendable-string
- Owner: igorskyflyer
- License: mit
- Created: 2023-05-29T15:20:32.000Z (over 1 year ago)
- Default Branch: main
- Last Pushed: 2024-07-29T20:43:59.000Z (3 months ago)
- Last Synced: 2024-09-30T06:29:22.993Z (about 1 month ago)
- Topics: back-end, browser, class, extend, extendable, igorskyflyer, javascript, js, node, npm, string, text, transform, ts, typescript, utility, vitest
- Language: TypeScript
- Homepage: https://www.npmjs.com/package/@igor.dvlpr/extendable-string
- Size: 120 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE
Awesome Lists containing this project
README
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! ππ
@igorskyflyer
## π Table of contents
- [Usage](#-usage)
- [API](#-api)
- [constructor()](#constructorraw-transformfn)
- [value](#value-string)
- [toString()](#tostring-string)
- [Examples](#-examples)
- [Changelog](#-changelog)
- [License](#-license)
- [Related](#-related)
- [Author](#-author)
## π΅πΌ Usage
Install it by executing:
```shell
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`
```ts
import { ExtendableString } from '@igor.dvlpr/extendable-string'export class UpperCaseString extends ExtendableString {
constructor(value: string) {
super(value, (str) => str.toUpperCase())
}
}
```
`example.mts`
```ts
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](https://github.com/igorskyflyer/npm-extendable-string/blob/main/CHANGELOG.md).
---
## πͺͺ License
Licensed under the MIT license which is available here, [MIT license](https://github.com/igorskyflyer/npm-extendable-string/blob/main/LICENSE).
---
## 𧬠Related
[@igor.dvlpr/keppo](https://www.npmjs.com/package/@igor.dvlpr/keppo)
> _π‘ Parse, manage, compare and output SemVer-compatible version numbers. π‘_
[@igor.dvlpr/astro-escaped-component](https://www.npmjs.com/package/@igor.dvlpr/astro-escaped-component)
> _ππ»ββοΈββ‘οΈ An Astro component that holds only HTML-encoded content. π_
[@aria-toolkit/shared](https://www.npmjs.com/package/@aria-toolkit/shared)
> _π» Shared resources between Aria modules. π¦ββ¬_
[@igor.dvlpr/windev](https://www.npmjs.com/package/@igor.dvlpr/windev)
> _π Provides ways of checking whether a path is a legacy Windows device. πΎ_
[@igor.dvlpr/mapped-replacer](https://www.npmjs.com/package/@igor.dvlpr/mapped-replacer)
> _πΊ Zero-dependency Map and RegExp based string replacer with Unicode support. π_
---
### π¨π»βπ» Author
Created by **Igor DimitrijeviΔ** ([*@igorskyflyer*](https://github.com/igorskyflyer/)).