pre-suf
Manipulate strings with prefixes and suffixes.
Install
$ npm install pre-suf --save
Usage
const presuf = presuf // '/path/to'presuf // '/path/to'
presuf.ensureLeading(str, prefix)
Ensures that the new string will have prefix
at the beginning of str
.
If str
does not begin with prefix
, prefix
will be added to the beggining of str
.
presuf.removeLeading(str, prefix)
Removes the leading prefix
of str
.
presuf // 'bc'presuf // 'bc'. removes 2 groups of '/a'
presuf.ensureEnding(str, suffix)
presuf.removeEnding(str, suffix)
License
MIT