pre-suf
DefinitelyTyped icon, indicating that this package has TypeScript declarations provided by the separate @types/pre-suf package

1.1.1 • Public • Published

Build Status

pre-suf

Manipulate strings with prefixes and suffixes.

Install

$ npm install pre-suf --save

Usage

const presuf = require('pre-suf')
 
presuf.ensureLeading('path/to', '/')    // '/path/to'
presuf.removeEnding('/path/to//', '/')  // '/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.removeLeading('/abc', '/a')       // 'bc'
presuf.removeLeading('/a/abc', '/a')     // 'bc'. removes 2 groups of '/a'

presuf.ensureEnding(str, suffix)

presuf.removeEnding(str, suffix)

License

MIT

Package Sidebar

Install

npm i pre-suf

Weekly Downloads

571

Version

1.1.1

License

MIT

Unpacked Size

4.57 kB

Total Files

3

Last publish

Collaborators

  • kael