Skip to content

Commit 6e05ae5

Browse files
committed
Require Node.js 8
1 parent da4458c commit 6e05ae5

File tree

4 files changed

+17
-4
lines changed

4 files changed

+17
-4
lines changed

.travis.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,3 @@ language: node_js
22
node_js:
33
- '10'
44
- '8'
5-
- '6'

index.d.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,19 @@
22
Get the real length of a string - by correctly counting astral symbols and ignoring [ansi escape codes](https://github.com/sindresorhus/strip-ansi).
33
44
`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.
5+
6+
@example
7+
```
8+
import stringLength from 'string-length';
9+
10+
'🐴'.length;
11+
//=> 2
12+
13+
stringLength('🐴');
14+
//=> 1
15+
16+
stringLength('\u001B[1municorn\u001B[22m');
17+
//=> 7
18+
```
519
*/
6-
export default function stringLength(input: string): number;
20+
export default function stringLength(string: string): number;

index.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
const stripAnsi = require('strip-ansi');
33
const astralRegex = require('astral-regex');
44

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

77
module.exports = stringLength;
88
module.exports.default = stringLength;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"url": "sindresorhus.com"
1111
},
1212
"engines": {
13-
"node": ">=6"
13+
"node": ">=8"
1414
},
1515
"scripts": {
1616
"test": "xo && ava && tsd-check"

0 commit comments

Comments
 (0)