-
Notifications
You must be signed in to change notification settings - Fork 1
object replace suffix
Subhajit Sahu edited this page May 5, 2020
·
1 revision
Replace suffix of string using object.
const objectReplaceSuffix = require('@extra-string/object-replace-suffix');
// objectReplaceSuffix(<string>, <object>, [max suffix length])
objectReplaceSuffix('ender', {'er': '', 'ing': '', 'ed': ''});
// 'end
objectReplaceSuffix('ender', {'end': 'right', 'start': 'left'});
// 'ender' (only suffix)
objectReplaceSuffix('ender', {'er': ' game', 'game': 'play'}, 4);
// 'end game' (only once)