# fretted-strings

> Mark on your strings and get it's position

Latest version **2.0.0** (published 2024-04-02) · MIT license · 0 weekly downloads

## Install

```sh
npm install fretted-strings
pnpm add fretted-strings
yarn add fretted-strings
bun add fretted-strings
```

## Health

**Score 45/100 (D)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities; high maintenance score; high quality score.

Warnings: low downloads.

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2024-04-02 |
| First published | 2020-03-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 0 |
| Unpacked size | 12.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 4 |
| Author | yosuke.kurami@gmail.com |
| Maintainers | quramy |
| Keywords | string |

## Links

- npm: https://www.npmjs.com/package/fretted-strings
- Repository: https://github.com/Quramy/fretted-strings
- Homepage: https://github.com/Quramy/fretted-strings#readme
- Issues: https://github.com/Quramy/fretted-strings/issues
- npm.io page: https://npm.io/package/fretted-strings

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2024-04-02
- 2.0.0-alpha.0 (next) — 2024-04-02
- 1.0.1 — 2020-03-04
- 1.0.0 — 2020-03-02
- 1.0.0-alpha.1 — 2020-03-02

## README

# fretted-strings

[![npm version](https://badge.fury.io/js/fretted-strings.svg)](https://badge.fury.io/js/fretted-strings)
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/Quramy/fretted-strings/master/LICENSE.txt)

Marks on your strings and get it's position.

```sh
npm i fretted-strings
```

## Basic usage

```ts
import assert from 'node:assert';
import { extract } from 'fretted-strings';

const [content, frets] = extract(
  `
      hogehoge
  %%% ^      ^   %%%
  %%% p1     p2  %%%
      fooo`,
);

// The 1st value of the tuple is a string which is removed lines enclosed by '%%%' tags from the parameter.
assert.equal(
  content,
  `
      hogehoge
      fooo`,
);

// The 2nd value of the tuple is an object whose value represents location corresponding to "^" character.
// And names under "^" character are available to use as keys of the object.
assert.equal(frets.p1.pos, 7);
assert.equal(frets.p1.line, 1);
assert.equal(frets.p1.character, 6);

assert.equal(frets.p2.pos, 14);
assert.equal(frets.p2.line, 1);
assert.equal(frets.p2.character, 13);
```

## Use custom tag

```ts
import { createExtractFn } from 'fretted-strings';

const extract = createExtractFn('<!--%%', '%%-->');

const [content, frets] = extract(
  `
    <html>
      <div>hogehoge</div>
      <!--%%   ^    %%-->
      <!--%%   p    %%-->
    </html>
  `,
);
```

## LICENSE

MIT

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