Socket
Socket
Sign inDemoInstall

@igor.dvlpr/extendable-string

Package Overview
Dependencies
0
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    @igor.dvlpr/extendable-string

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


Version published
Maintainers
1
Created

Readme

Source

ExtendableString

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


💖 Support further development

Donate to igorskyflyer



Table of Contents



Usage

Install it by executing:

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

API


To actually use it, you should extend your own String class from it.


Example


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'

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'

Each time you create a new string or assign a new value to it, your string transformation function will fire.



❗ You do NOT instantiate a new object from the ExtendableString class, you extend it instead.



Properties

value

The value property represents the current transformed value of the string.



Methods

toString()

The toString() method returns the current transformed value of the string.



License

This project is licensed under the terms of the MIT license.

Keywords

FAQs

Last updated on 30 May 2023

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc