Changelog
Version 9.0.0 (2024-02-08)
#!
hashbang comments at the start of files.Changelog
Version 8.0.3 (2024-02-03)
Maximum call stack size exceeded
or similar error. There are still a few [even more extreme such edge cases][known-failures], which I don’t think can be solved but are documented at least.Changelog
Version 8.0.2 (2023-09-09)
export default
, but apparently export =
is the correct syntax to use for packages that export a single function, which can be used both in CJS and MJS. (Read more about [Incorrect default export]). It should now be possible to do const jsTokens = require("js-tokens")
in a @ts-checked
ed JS file without TypeScript complaining. Note: This requires "esModuleInterop": true
in your tsconfig.json, but as far as I can tell that’s not a breaking change, since importing js-tokens with "esModuleInterop": false
didn’t work at runtime anyway.Changelog
Version 8.0.1 (2023-01-16)
/]/
is now parsed as a RegularExpressionLiteral
. That’s invalid regex syntax, unless [Annex B: Additional ECMAScript Features for Web Browsers][annexb] is honored, which js-tokens does. Thanks to Jared Hughes (@jared-hughes) for reporting and fixing!Changelog
Version 8.0.0 (2022-05-15)
Support for ES2022!
Added: Support for the d
regex flag.
Added: A new token type – PrivateIdentifier
– for things like #name
.
this.#name
now tokenizes differently:
IdentifierName: this
, Punctuator: .
, Invalid: #
, IdentifierName: name
IdentifierName: this
, Punctuator: .
, PrivateIdentifier: #name
Changelog
Version 7.0.0 (2021-04-25)
||=
, &&=
and ??=
operators, as well as underscores in numeric literals (1_000
).Changelog
Version 6.0.0 (2020-04-13)
.default
when using CommonJS: const jsTokens = require("js-tokens")
. (import jsTokens from "js-tokens"
also works in module environments.)jsTokens("<p>Hello, world!</p>", { jsx: true })
.5n
.?.
and ??
.Changelog
Version 5.0.0 (2019-06-15)
\u2028
and \u2029
are now allowed unescaped inside string literals.Changelog
Version 4.0.0 (2018-01-28)
s
regex flag.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.)closed
property could now behave differently.