A tiny (115B) find-and-replace utility for strings in Javascript.
If you're using Yarn:
yarn add sub-inIf you're using npm:
npm install sub-inCreate a string with any number of placeholders: $0, $1, $2, $3, $4, etc. Placeholders are zero based:
$0=['Peter'](Peter)$1=['Tom', 'Peter'](Peter)$2=['Tom', 'John', 'Peter'](Peter)
const greeting = 'Hey $0, how are you doing?'
subIn(greeting, ['Peter'])
// Hey Peter, how are you doing?const friends = '$0, $1 and $2 are my friends.'
subIn(friends, ['Jake', 'Tom', 'Zack'])
// Jake, Tom and Zack are my friends