<commit_before>import * as _ from 'lodash';
import * as BezierJs from 'bezier-js';
import { Point } from '../../common';
import { SvgChar, Projection } from '..';
import { CommandBuilder } from '../CommandImpl';
import { Calculator, BBox, Line } from '.';
import { PointCalculator } from './PointCalculator';
import { LineCalculator } from './LineCalculator';
import { environment } from '../../../../environments/environment';

/**
 * A simple typed wrapper class around the amazing bezier-js library.
 */
export class BezierCalculator implements Calculator {
  private readonly points: ReadonlyArray<Point>;
  private length: number;
  private bbox: BBox;
  private bezierJs_: any;

  constructor(
    private readonly id: string,
    private readonly svgChar: SvgChar,
    ...points: Point[],
  ) {
    this.points = points;

    // Don't initialize variables lazily for dev builds (to avoid
    // ngrx-store-freeze crashes).
    if (!environment.production) {
      (() => this.bezierJs)();
      this.getPathLength();
      this.getBoundingBox();
    }
  }

  get bezierJs() {
    if (this.bezierJs_ === undefined) {
      this.bezierJs_ = new BezierJs(this.points);
    }
    return this.bezierJs_;
  }

  getPathLength() {
    if (this.length === undefined) {
      this.length = this.bezierJs.length();
    }
    return this.length;
  }

  project(point: Point): Projection {
    const { x, y, t, d } = this.bezierJs.project(point);
    return { x, y, t, d };
  }

  split(t1: number, t2: number): Calculator {
    if (t1 === t2) {
      const p: { x: number, y: number } = this.bezierJs.get(t1);
      return new PointCalculator(this.id, this.svgChar, new Point(p.x, p.y));<commit_msg>fix lint<commit_after>import * as _ from 'lodash';
import * as BezierJs from 'bezier-js';
import { Point } from '../../common';
import { SvgChar, Projection } from '..';
import { CommandBuilder } from '../CommandImpl';
import { Calculator, BBox, Line } from '.';
import { PointCalculator } from './PointCalculator';
import { LineCalculator } from './LineCalculator';
import { environment } from '../../../../environments/environment';

/**
 * A simple typed wrapper class around the amazing bezier-js library.
 */
export class BezierCalculator implements Calculator {
  private readonly points: ReadonlyArray<Point>;
  private length: number;
  private bbox: BBox;
  private bezierJs_: any;

  constructor(
    private readonly id: string,
    private readonly svgChar: SvgChar,
    ...points: Point[],
  ) {
    this.points = points;

    // Don't initialize variables lazily for dev builds (to avoid
    // ngrx-store-freeze crashes).
    if (!environment.production) {
      // tslint:disable-next-line
      this.bezierJs;
      this.getPathLength();
      this.getBoundingBox();
    }
  }

  get bezierJs() {
    if (this.bezierJs_ === undefined) {
      this.bezierJs_ = new BezierJs(this.points);
    }
    return this.bezierJs_;
  }

  getPathLength() {
    if (this.length === undefined) {
      this.length = this.bezierJs.length();
    }
    return this.length;
  }

  project(point: Point): Projection {
    const { x, y, t, d } = this.bezierJs.project(point);
    return { x, y, t, d };
  }

  split(t1: number, t2: number): Calculator {
    if (t1 === t2) {
      const p: { x: number, y: number } = this.bezierJs.get(t1);
      return new PointCalculator(this.id, this.svgChar, new Point(p.x, p.y));
{'fraction_non_alphanumeric': 0.1463772367263127, 'fraction_numerical': 0.002933411557641537, 'mean_word_length': 3.011764705882353, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '931549', 'n_tokens_mistral': 1117, 'n_tokens_neox': 1085, 'n_words': 299}