map replace suffix - nodef/extra-string GitHub Wiki

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)

extra-string

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