object replace prefix - nodef/extra-string GitHub Wiki

Replace prefix of string using object.

const objectReplacePrefix = require('@extra-string/object-replace-prefix');
// objectReplacePrefix(<string>, <object>, [max prefix length])

objectReplacePrefix('dishonoured', {'dis': '', 'un': '', 'in': ''});
// 'honoured'
objectReplacePrefix('dishonoured', {'honour': 'respect', 'flatter': 'mock'});
// 'dishonoured' (only prefix)
objectReplacePrefix('dishonoured', {'dis': 'redis', 'redis': 'super'}, 5);
// 'redishonoured' (only once)

extra-string

⚠️ **GitHub.com Fallback** ⚠️