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