0.1.3 • Published 6 years ago
string-mapreplaceprefix v0.1.3
string-mapreplaceprefix
NOTE: string-mapreplaceprefix was renamed to @extra-string/map-replace-prefix.
Replace prefix of string using map.
const mapReplacePrefix = require('string-mapreplaceprefix');
// mapReplacePrefix(<string>, <map>, [max prefix length])
mapReplacePrefix('dishonoured', new Map([['dis', ''], ['un', ''], ['in', '']]));
// 'honoured'
mapReplacePrefix('dishonoured', new Map([['honour', 'respect'], ['flatter', 'mock']]));
// 'dishonoured' (only prefix)
mapReplacePrefix('dishonoured', new Map([['dis', 'redis'], ['redis', 'super']]), 5);
// 'redishonoured' (only once)