-
Notifications
You must be signed in to change notification settings - Fork 1
object replace prefix
Subhajit Sahu edited this page May 5, 2020
·
1 revision
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)