Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

js-tokens

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

js-tokens - npm Package Versions

23

9.0.0

Diff

Changelog

Source

Version 9.0.0 (2024-02-08)

  • Added: Support for ES2023: #! hashbang comments at the start of files.
lydell
published 8.0.3 •

Changelog

Source

Version 8.0.3 (2024-02-03)

  • Fixed: Extremely long string literals, template literals, regex literals, identifiers, comments, and runs of whitespace are now supported where possible. We’re talking about 10 million characters long. Previously, such long tokens could make the regex engine of the runtime give up and throw a 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.
lydell
published 8.0.2 •

Changelog

Source

Version 8.0.2 (2023-09-09)

  • Fixed: The TypeScript type definitions shipped in the npm package are now more correct. Previously they used 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-checkeded 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.
lydell
published 8.0.1 •

Changelog

Source

Version 8.0.1 (2023-01-16)

  • Fixed: /]/ 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!
lydell
published 8.0.0 •

Changelog

Source

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:

    • Before: IdentifierName: this, Punctuator: ., Invalid: #, IdentifierName: name
    • After: IdentifierName: this, Punctuator: ., PrivateIdentifier: #name
lydell
published 7.0.0 •

Changelog

Source

Version 7.0.0 (2021-04-25)

  • Added: Support for ES2021: The ||=, &&= and ??= operators, as well as underscores in numeric literals (1_000).
lydell
published 6.0.0 •

Changelog

Source

Version 6.0.0 (2020-04-13)

  • Changed: The main export of this module is no longer a regex (accompanied by a small helper function). Instead, the only export is a function that tokenizes JavaScript (which was the main use case of the regex). The tokenization is still powered by basically the same regex as before, but is now wrapped up in 300–400 lines of code. This is required to tokenize regex and templates correctly, and to support JSX (see below).
  • Changed: You no longer need .default when using CommonJS: const jsTokens = require("js-tokens"). (import jsTokens from "js-tokens" also works in module environments.)
  • Changed: Node.js 10 or later is now required (because [Unicode property escapes] are used.)
  • Changed: The tokens are now named like in the ECMAScript spec.
  • Changed: Whitespace and line terminator sequences are now matched as separate tokens to match the spec.
  • Added: TypeScript definition.
  • Added: Support for JSX: jsTokens("<p>Hello, world!</p>", { jsx: true }).
  • Added: Support for BigInt syntax: 5n.
  • Added: Support for ?. and ??.
  • Added: Support for legacy octal and octal like numeric literals.
  • Improved: Template literals now support infinite nesting, and separate tokens are made for interpolations.
  • Improved: Regex vs division detection. js-tokens now passes all [but 3][edge-cases] of [test262-parser-tests].
  • Improved: Unclosed regular expressions are now matched as such, instead of as division.
  • Improved: Invalid non-ASCII characters are no longer matched as identifier names.
lydell
published 5.0.0 •

Changelog

Source

Version 5.0.0 (2019-06-15)

  • Added: Support for ES2019. The only change is that \u2028 and \u2029 are now allowed unescaped inside string literals.
lydell
published 4.0.0 •

Changelog

Source

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.
lydell
published 3.0.2 •

Changelog

Source

Version 3.0.2 (2017-06-28)

  • No code changes. Just updates to the readme.
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc