@jscpd/tokenizer
tokenizer of source code for jscpd
Last updated 3 months ago by apk .
MIT · Repository · Bugs · Original npm · Tarball · package.json
$ npm install @jscpd/tokenizer 
SYNC missed versions from official npm registry.

@jscpd/tokenizer

Tokenizer package for @jscpd — converts source code into a list of tokens for duplicate detection.

Supports 223 programming languages and formats via a self-contained reprism-based grammar engine. Grammars are loaded lazily for fast startup, with O(n) hot paths for high-throughput scanning.

Special tokenization modes handle multi-language files:

  • Vue SFC (.vue) — <template>, <script>, and <style> blocks each tokenized by their own language
  • Svelte (.svelte) — per-block tokenization for HTML, JS, and CSS sections
  • Astro (.astro) — frontmatter and template blocks tokenized independently
  • Markdown (.md) — fenced code blocks tokenized by the declared language

This enables cross-format clone detection: a <script lang="ts"> block in a .vue file can match a plain .ts file.

Installation

npm install @jscpd/tokenizer --save

Usage

import { IOptions, ITokensMap } from '@jscpd/core';
import { Tokenizer } from '@jscpd/tokenizer';

const tokenizer = new Tokenizer();
const options: IOptions = {};

const maps: ITokensMap[] = tokenizer.generateMaps('source_id', 'let a = "11"', 'javascript', options);

Supported formats

The full list of 223 supported formats is available in FORMATS.md at the repository root, or at runtime:

jscpd --list

License

MIT © Andrey Kucherenko

Current Tags

  • 3.3.0-alpha.8                                ...           canary (7 years ago)
  • 4.2.6                                ...           latest (3 months ago)
  • 4.0.0                                ...           rc (3 years ago)

38 Versions

  • 4.2.6                                ...           3 months ago
  • 4.2.5                                ...           6 months ago
  • 4.2.4                                ...           6 months ago
  • 4.2.3                                ...           6 months ago
  • 4.2.2                                ...           6 months ago
  • 4.2.1                                ...           6 months ago
  • 4.2.0                                ...           6 months ago
  • 4.1.1                                ...           7 months ago
  • 4.1.0                                ...           7 months ago
  • 4.0.5                                ...           8 months ago
  • 4.0.4                                ...           10 months ago
  • 4.0.3                                ...           a year ago
  • 4.0.2                                ...           a year ago
  • 4.0.1                                ...           3 years ago
  • 4.0.0                                ...           3 years ago
  • 3.5.4                                ...           4 years ago
  • 3.5.1                                ...           4 years ago
  • 3.5.0                                ...           4 years ago
  • 3.4.5                                ...           5 years ago
  • 3.4.1                                ...           5 years ago
  • 3.3.24                                ...           6 years ago
  • 3.3.23                                ...           6 years ago
  • 3.3.20                                ...           6 years ago
  • 3.3.17                                ...           6 years ago
  • 3.3.14                                ...           6 years ago
  • 3.3.13                                ...           6 years ago
  • 3.3.11                                ...           6 years ago
  • 3.3.9                                ...           6 years ago
  • 3.3.8                                ...           6 years ago
  • 3.3.1                                ...           6 years ago
  • 3.3.0-rc.10                                ...           6 years ago
  • 3.3.0-rc.8                                ...           6 years ago
  • 3.3.0-rc.7                                ...           6 years ago
  • 3.3.0-rc.5                                ...           7 years ago
  • 3.3.0-rc.4                                ...           7 years ago
  • 3.3.0-rc.3                                ...           7 years ago
  • 3.3.0-alpha.8                                ...           7 years ago
  • 3.3.0-alpha.2                                ...           7 years ago
Maintainers (1)
Downloads
Total 94
Today 0
This Week 1
This Month 55
Last Day 0
Last Week 52
Last Month 26
Dependencies (2)
Dev Dependencies (7)
Dependents (2)

© 2010 - cnpmjs.org x YWFE | Home | YWFE