String#replaceAll
polyfill for TypeScriptString#replaceAll
, along with TypeScript typings.The
replaceAll
function is defined in this TC39 proposal.Installation
npm install --save ts-replace-all
Usage
import 'ts-replace-all'
'test'.replaceAll('t', '1')
'test'.replaceAll('t', () => '2')
'test'.replaceAll(/t/g, '3')
'test'.replaceAll(/t/g, () => '4')