@jscpd/core
TypeScript icon, indicating that this package has built-in type declarations

3.5.4 • Public • Published

@jscpd/core

core package for detect duplicates, depends only on eventemitter3.

Installation

npm install @jscpd/core --save

Usage

import {Tokenizer} from '@jscpd/tokenizer';
import {
    Detector,
    MemoryStore,
    IOptions,
    IClone,
    IStore,
    ITokenizer
} from '@jscpd/core';

const options: IOptions = {
    minLines: 5,
    maxLines: 500,
}

const tokenizer: ITokenizer = new Tokenizer();

// here you can use any store what implement IStore interface
const store: IStore = new MemoryStore();

// list of validators, implemented IValidator interface, validate clones
const validators = [];

const detector = new Detector(tokenizer, store, validators, options);

( async () => {
    const format = 'javascript';
    const code: string = '...string with code...';
    const clones: IClone[] = await detector.detect('source_id', code, format);

    console.log(clones);
})();

ga tracker

License

MIT © Andrey Kucherenko

Readme

Keywords

none

Package Sidebar

Install

npm i @jscpd/core

Weekly Downloads

62,259

Version

3.5.4

License

MIT

Unpacked Size

47 kB

Total Files

79

Last publish

Collaborators

  • apk