Skip to content

Commit

Permalink
Require Node.js 8
Browse files Browse the repository at this point in the history
  • Loading branch information
sindresorhus committed Mar 18, 2019
1 parent da4458c commit 6e05ae5
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 4 deletions.
1 change: 0 additions & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,3 @@ language: node_js
node_js:
- '10'
- '8'
- '6'
16 changes: 15 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,19 @@
Get the real length of a string - by correctly counting astral symbols and ignoring [ansi escape codes](https://github.com/sindresorhus/strip-ansi).
`String#length` errornously counts [astral symbols](https://web.archive.org/web/20150721114550/http://www.tlg.uci.edu/~opoudjis/unicode/unicode_astral.html) as two characters.
@example
```
import stringLength from 'string-length';
'🐴'.length;
//=> 2
stringLength('🐴');
//=> 1
stringLength('\u001B[1municorn\u001B[22m');
//=> 7
```
*/
export default function stringLength(input: string): number;
export default function stringLength(string: string): number;
2 changes: 1 addition & 1 deletion index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
const stripAnsi = require('strip-ansi');
const astralRegex = require('astral-regex');

const stringLength = input => stripAnsi(input).replace(astralRegex(), ' ').length;
const stringLength = string => stripAnsi(string).replace(astralRegex(), ' ').length;

module.exports = stringLength;
module.exports.default = stringLength;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"url": "sindresorhus.com"
},
"engines": {
"node": ">=6"
"node": ">=8"
},
"scripts": {
"test": "xo && ava && tsd-check"
Expand Down

0 comments on commit 6e05ae5

Please sign in to comment.