diff options
Diffstat (limited to 'node_modules/js-tokens')
-rw-r--r-- | node_modules/js-tokens/CHANGELOG.md | 17 | ||||
-rw-r--r-- | node_modules/js-tokens/LICENSE | 2 | ||||
-rw-r--r-- | node_modules/js-tokens/README.md | 32 | ||||
-rw-r--r-- | node_modules/js-tokens/index.js | 6 | ||||
-rw-r--r-- | node_modules/js-tokens/package.json | 10 |
5 files changed, 51 insertions, 16 deletions
diff --git a/node_modules/js-tokens/CHANGELOG.md b/node_modules/js-tokens/CHANGELOG.md index 208304b3e..755e6f6ec 100644 --- a/node_modules/js-tokens/CHANGELOG.md +++ b/node_modules/js-tokens/CHANGELOG.md @@ -1,3 +1,20 @@ +### Version 4.0.0 (2018-01-28) ### + +- Added: Support for ES2018. The only change needed was recognizing the `s` + regex flag. +- Changed: _All_ tokens returned by the `matchToToken` function now have a + `closed` property. It is set to `undefined` for the tokens where “closed” + doesn’t make sense. This means that all tokens objects have the same shape, + which might improve performance. + +These are the breaking changes: + +- `'/a/s'.match(jsTokens)` no longer returns `['/', 'a', '/', 's']`, but + `['/a/s']`. (There are of course other variations of this.) +- Code that rely on some token objects not having the `closed` property could + now behave differently. + + ### Version 3.0.2 (2017-06-28) ### - No code changes. Just updates to the readme. diff --git a/node_modules/js-tokens/LICENSE b/node_modules/js-tokens/LICENSE index 748f42e87..54aef52f3 100644 --- a/node_modules/js-tokens/LICENSE +++ b/node_modules/js-tokens/LICENSE @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2014, 2015, 2016, 2017 Simon Lydell +Copyright (c) 2014, 2015, 2016, 2017, 2018 Simon Lydell Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/node_modules/js-tokens/README.md b/node_modules/js-tokens/README.md index 5c93a8885..00cdf1634 100644 --- a/node_modules/js-tokens/README.md +++ b/node_modules/js-tokens/README.md @@ -73,14 +73,13 @@ Whitespace includes both line terminators and other whitespace. ECMAScript support ================== -The intention is to always support the latest stable ECMAScript version. +The intention is to always support the latest ECMAScript version whose feature +set has been finalized. If adding support for a newer version requires changes, a new version with a major verion bump will be released. -Currently, [ECMAScript 2017] is supported. - -[ECMAScript 2017]: https://www.ecma-international.org/ecma-262/8.0/index.html +Currently, ECMAScript 2018 is supported. Invalid code handling @@ -100,7 +99,8 @@ inside the regex. Invalid ASCII characters have their own capturing group. Invalid non-ASCII characters are treated as names, to simplify the matching of -names (except unicode spaces which are treated as whitespace). +names (except unicode spaces which are treated as whitespace). Note: See also +the [ES2018](#es2018) section. Regex literals may contain invalid regex syntax. They are still matched as regex literals. They may also contain repeated regex flags, to keep the regex @@ -144,7 +144,8 @@ var regex = / 2/g A human can easily understand that in the `number` line we’re dealing with division, and in the `regex` line we’re dealing with a regex literal. How come? Because humans can look at the whole code to put the `/` characters in context. -A JavaScript regex cannot. It only sees forwards. +A JavaScript regex cannot. It only sees forwards. (Well, ES2018 regexes can also +look backwards. See the [ES2018](#es2018) section). When the `jsTokens` regex scans throught the above, it will see the following at the end of both the `number` and `regex` rows: @@ -192,7 +193,7 @@ valid regex flag. I initially wanted to future-proof by allowing `[a-zA-Z]*` (any letter) as flags, but it is not worth it since it increases the amount of ambigous cases. So only the standard `g`, `m`, `i`, `y` and `u` flags are allowed. This means that the above example will be identified as division as -long as you don’t rename the `e` variable to some permutation of `gmiyu` 1 to 5 +long as you don’t rename the `e` variable to some permutation of `gmiyus` 1 to 6 characters long. Lastly, we can look _forward_ for information. @@ -215,6 +216,23 @@ If the end of a statement looks like a regex literal (even if it isn’t), it will be treated as one. Otherwise it should work as expected (if you write sane code). +### ES2018 ### + +ES2018 added some nice regex improvements to the language. + +- [Unicode property escapes] should allow telling names and invalid non-ASCII + characters apart without blowing up the regex size. +- [Lookbehind assertions] should allow matching telling division and regex + literals apart in more cases. +- [Named capture groups] might simplify some things. + +These things would be nice to do, but are not critical. They probably have to +wait until the oldest maintained Node.js LTS release supports those features. + +[Unicode property escapes]: http://2ality.com/2017/07/regexp-unicode-property-escapes.html +[Lookbehind assertions]: http://2ality.com/2017/05/regexp-lookbehind-assertions.html +[Named capture groups]: http://2ality.com/2017/05/regexp-named-capture-groups.html + License ======= diff --git a/node_modules/js-tokens/index.js b/node_modules/js-tokens/index.js index a3c8a0d7b..b23a4a0e7 100644 --- a/node_modules/js-tokens/index.js +++ b/node_modules/js-tokens/index.js @@ -1,4 +1,4 @@ -// Copyright 2014, 2015, 2016, 2017 Simon Lydell +// Copyright 2014, 2015, 2016, 2017, 2018 Simon Lydell // License: MIT. (See LICENSE.) Object.defineProperty(exports, "__esModule", { @@ -7,10 +7,10 @@ Object.defineProperty(exports, "__esModule", { // This regex comes from regex.coffee, and is inserted here by generate-index.js // (run `npm run build`). -exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyu]{1,5}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g +exports.default = /((['"])(?:(?!\2|\\).|\\(?:\r\n|[\s\S]))*(\2)?|`(?:[^`\\$]|\\[\s\S]|\$(?!\{)|\$\{(?:[^{}]|\{[^}]*\}?)*\}?)*(`)?)|(\/\/.*)|(\/\*(?:[^*]|\*(?!\/))*(\*\/)?)|(\/(?!\*)(?:\[(?:(?![\]\\]).|\\.)*\]|(?![\/\]\\]).|\\.)+\/(?:(?!\s*(?:\b|[\u0080-\uFFFF$\\'"~({]|[+\-!](?!=)|\.?\d))|[gmiyus]{1,6}\b(?![\u0080-\uFFFF$\\]|\s*(?:[+\-*%&|^<>!=?({]|\/(?![\/*])))))|(0[xX][\da-fA-F]+|0[oO][0-7]+|0[bB][01]+|(?:\d*\.\d+|\d+\.?)(?:[eE][+-]?\d+)?)|((?!\d)(?:(?!\s)[$\w\u0080-\uFFFF]|\\u[\da-fA-F]{4}|\\u\{[\da-fA-F]+\})+)|(--|\+\+|&&|\|\||=>|\.{3}|(?:[+\-\/%&|^]|\*{1,2}|<{1,2}|>{1,3}|!=?|={1,2})=?|[?~.,:;[\](){}])|(\s+)|(^$|[\s\S])/g exports.matchToToken = function(match) { - var token = {type: "invalid", value: match[0]} + var token = {type: "invalid", value: match[0], closed: undefined} if (match[ 1]) token.type = "string" , token.closed = !!(match[3] || match[4]) else if (match[ 5]) token.type = "comment" else if (match[ 6]) token.type = "comment", token.closed = !!match[7] diff --git a/node_modules/js-tokens/package.json b/node_modules/js-tokens/package.json index 7f5bd7800..66752fab2 100644 --- a/node_modules/js-tokens/package.json +++ b/node_modules/js-tokens/package.json @@ -1,6 +1,6 @@ { "name": "js-tokens", - "version": "3.0.2", + "version": "4.0.0", "author": "Simon Lydell", "license": "MIT", "description": "A regex that tokenizes JavaScript.", @@ -22,9 +22,9 @@ "dev": "npm run build && npm test" }, "devDependencies": { - "coffee-script": "~1.12.6", - "esprima": "^4.0.0", - "everything.js": "^1.0.3", - "mocha": "^3.4.2" + "coffeescript": "2.1.1", + "esprima": "4.0.0", + "everything.js": "1.0.3", + "mocha": "5.0.0" } } |