You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

index.js 306B

1234567891011
  1. 'use strict';
  2. var escapeStringRegexp = require('escape-string-regexp');
  3. module.exports = function (str, sub) {
  4. if (typeof str !== 'string' || typeof sub !== 'string') {
  5. throw new TypeError();
  6. }
  7. sub = escapeStringRegexp(sub);
  8. return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
  9. };