Implement the String.prototype.remove

Hi guys!

The motivation behind this proposal is to simplify the text replacement within JavaScript. Currently, to remove some text in a string, you need to use the replace or replaceAll methods passing an empty string as a second parameter. This is an ugly way. So this proposal doesn't change the memory value and removes the second parameter.

How it works

It receives one string or RegExp that returns a new string.

Cases

// Imports omitted…

"bitcoin-mainnet".remove("-mainnet")
// "bitcoin"

"bitcoin-mainnet".remove(/-mainnet/)
// "bitcoin"

"bitcoin mainnet mainnet".remove("mainnet", { trim: true })
// "bitcoin"

"bitcoin mainnet mainnet".remove(/mainnet/, { trim: true })
// "bitcoin"

Install the polyfill

// Use your favorite package manager

npm install @hotequil/proposal-remove-string

Import the polyfill

// Import it in your main, index or app file

import "@hotequil/proposal-remove-string"