# ttt-source-parser

> The package provides a set of utilities to parse project source code using regular expressions, and to transfer management of paired values (create and delete)

Latest version **1.2.2** (published 2025-07-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install ttt-source-parser
pnpm add ttt-source-parser
yarn add ttt-source-parser
bun add ttt-source-parser
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2025-07-29 |
| First published | 2025-07-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 6 |
| Unpacked size | 42.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | cbrgpl |
| Maintainers | cbrgpl |
| Keywords | source code, parser |

## Links

- npm: https://www.npmjs.com/package/ttt-source-parser
- npm.io page: https://npm.io/package/ttt-source-parser

## Dependencies (6)

- [ajv](https://npm.io/package/ajv.md) ^8.12.0
- [chalk](https://npm.io/package/chalk.md) ^5.2.0
- [yargs](https://npm.io/package/yargs.md) ^17.7.2
- [dotenv](https://npm.io/package/dotenv.md) ^16.1.4
- [time-stamp](https://npm.io/package/time-stamp.md) ^2.2.0
- [cli-highlight](https://npm.io/package/cli-highlight.md) ^2.1.11

## Recent versions

- 1.2.2 (latest) — 2025-07-29

## README

# ttt-source-parser

Пакет предоставляет набор классов-утилит, чтобы создать программу парсер исходного кода для поиска ключевых слов при помощи регулярных выражений. Программа должна содержать реализацию манипулятора, который обеспечит взаимодействие с серверной частью для создания или удаления ключевых слов.

## Usage

```bash
npm i ttt-source-parser --save
```

Пример реализации скрипта для поиска подсказок в исходном коде.

**index.ts**
```ts
import {
  CI,
  conductorFactory,
  _setArgsToModule,
} from 'ttt-source-parser'

import { HintManipulator } from './core/HintManipulator.js'

;( async (): Promise<void> => {
  try {
    _setArgsToModule( 'env' )

    const manipulator = new HintManipulator()
    const conductor = await conductorFactory( manipulator )

    const promises = [
      conductor.createKeywords(),
      conductor.deleteUnusedKeywords(),
    ]

    await Promise.all( promises )

    CI.finish( 'Finish' )
    process.exit( 0 )
  } catch ( err ) {
    // ...
    process.exit( 1 )
  }
} )()
```

**./core/HintManipulator.ts**
```ts
import {
  type IKeyword,
  type IEntity,
  EOperationStatus,

  AKeywordManpulator,
} from 'ttt-source-parser'

import { fetchWrapper } from '../helpers/fetchWrapper.js'
import { API_URL } from '@/static/consts.js'

interface IHint {
  id: number;
  name: string;
}

export class HintManipulator extends AKeywordManpulator<IHint> {
  protected _entities = [] as IEntity<IHint>[]

  async get() {
    const response = await fetchWrapper( API_URL + '/hints/' )

    this._entities = await response.json()

    return this._entities.map( entity => ( { value: entity.value.id } ) )
  }

  async create( keyword: IKeyword ) {
    const hint = {
      name: keyword.value,
    }

    const response = await fetchWrapper( API_URL + '/hints/', {
      method: 'POST',
      body: JSON.stringify( hint ),
    } )

    return EOperationStatus.SUCCESS
  }

  async delete( keyword: IKeyword ) {
    const hint = this._entities.find( entity => entity.value.id === keyword.value )

    const response = await fetchWrapper( API_URL + `/hints/${ hint!.value.id }/`, { method: 'DELETE'} )

    return EOperationStatus.SUCCESS
  }
}

```

## Архитектура

![Диаграмма классов](./documentation/source_parser_arch.svg)

---
_Source: https://npm.io/package/ttt-source-parser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
