Skip to content

Commit

Permalink
Require Node.js 6
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 23, 2018
1 parent b7222dc commit 3baa12f
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 72 deletions.
2 changes: 1 addition & 1 deletion .editorconfig
Expand Up @@ -7,6 +7,6 @@ charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true

[{package.json,*.yml}]
[*.yml]
indent_style = space
indent_size = 2
1 change: 1 addition & 0 deletions .gitignore
@@ -1 +1,2 @@
node_modules
yarn.lock
1 change: 1 addition & 0 deletions .npmrc
@@ -0,0 +1 @@
package-lock=false
5 changes: 1 addition & 4 deletions .travis.yml
@@ -1,7 +1,4 @@
sudo: false
language: node_js
node_js:
- '8'
- '6'
- '4'
- '0.12'
- '0.10'
12 changes: 6 additions & 6 deletions index.js
@@ -1,11 +1,11 @@
'use strict';
var escapeStringRegexp = require('escape-string-regexp');
const escapeStringRegexp = require('escape-string-regexp');

module.exports = function (str, sub) {
if (typeof str !== 'string' || typeof sub !== 'string') {
throw new TypeError();
module.exports = (input, substring) => {
if (typeof input !== 'string' || typeof substring !== 'string') {
throw new TypeError('Expected a string');
}

sub = escapeStringRegexp(sub);
return str.replace(new RegExp('^' + sub + '|' + sub + '$', 'g'), '');
substring = escapeStringRegexp(substring);
return input.replace(new RegExp(`^${substring}|${substring}$`, 'g'), '');
};
20 changes: 4 additions & 16 deletions license
@@ -1,21 +1,9 @@
The MIT License (MIT)
MIT License

Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
84 changes: 42 additions & 42 deletions package.json
@@ -1,44 +1,44 @@
{
"name": "strip-outer",
"version": "1.0.1",
"description": "Strip a substring from the start/end of a string",
"license": "MIT",
"repository": "sindresorhus/strip-outer",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=0.10.0"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"strip",
"trim",
"remove",
"outer",
"str",
"string",
"substring",
"start",
"end",
"wrap",
"leading",
"trailing",
"regex",
"regexp"
],
"dependencies": {
"escape-string-regexp": "^1.0.2"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
"name": "strip-outer",
"version": "1.0.1",
"description": "Strip a substring from the start/end of a string",
"license": "MIT",
"repository": "sindresorhus/strip-outer",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
},
"scripts": {
"test": "xo && ava"
},
"files": [
"index.js"
],
"keywords": [
"strip",
"trim",
"remove",
"outer",
"str",
"string",
"substring",
"start",
"end",
"wrap",
"leading",
"trailing",
"regex",
"regexp"
],
"dependencies": {
"escape-string-regexp": "^1.0.2"
},
"devDependencies": {
"ava": "*",
"xo": "*"
}
}
2 changes: 1 addition & 1 deletion readme.md
Expand Up @@ -6,7 +6,7 @@
## Install

```
$ npm install --save strip-outer
$ npm install strip-outer
```


Expand Down
4 changes: 2 additions & 2 deletions test.js
@@ -1,7 +1,7 @@
import test from 'ava';
import m from './';
import m from '.';

test(t => {
test('main', t => {
t.is(m('foobarfoo', 'foo'), 'bar');
t.is(m('unicorncake', 'unicorn'), 'cake');
});

0 comments on commit 3baa12f

Please sign in to comment.