# @gotoeasy/btf

> A JavaScript Block-Text-File Parser

Latest version **1.3.2** (published 2020-03-30) · MIT license · 0 weekly downloads

## Install

```sh
npm install @gotoeasy/btf
pnpm add @gotoeasy/btf
yarn add @gotoeasy/btf
bun add @gotoeasy/btf
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.3.2 |
| Published | 2020-03-30 |
| First published | 2018-11-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 24.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | 青松 |
| Maintainers | rpose |
| Keywords | gotoeasy, btf, btf file, block-text-file, block text file, btf文件, 块文本文件 |

## Links

- npm: https://www.npmjs.com/package/@gotoeasy/btf
- Repository: https://github.com/gotoeasy/npm-packages
- Homepage: https://github.com/gotoeasy/npm-packages/blob/master/btf/README.md
- Issues: https://github.com/gotoeasy/npm-packages/issues
- npm.io page: https://npm.io/package/@gotoeasy/btf

## Recent versions

- 1.3.2 (latest) — 2020-03-30
- 1.3.1 — 2019-09-16
- 1.2.0 — 2019-05-29
- 1.1.2 — 2019-04-28
- 1.1.1 — 2019-01-07
- 1.1.0 — 2018-12-14
- 1.0.0 — 2018-12-14
- 0.0.6 — 2018-11-29
- 0.0.5 — 2018-11-29
- 0.0.4 — 2018-11-13
- 0.0.3 — 2018-11-13
- 0.0.2 — 2018-11-12
- 0.0.1 — 2018-11-12

## README

# `@gotoeasy/btf`
A JavaScript ![`Block-Text-File`](https://github.com/gotoeasy/block-text-file) Parser
<br>
<br>

[![NPM version](https://img.shields.io/npm/v/@gotoeasy/btf.svg)](https://www.npmjs.com/package/@gotoeasy/btf)
[![License](https://img.shields.io/badge/License-MIT-brightgreen.svg)](https://github.com/gotoeasy/npm-packages/blob/master/LICENSE)
<br>
<br>

## Install
```
npm i @gotoeasy/btf
```

## API
* BlockTextFile.getText(blockName) - get text of blockName from the first Document
* BlockTextFile.getMap(blockName) - get key-value map of blockName from the first Document
* BlockTextFile.getDocument() - get the first Document
* BlockTextFile.getDocuments() - get the Document array
* Document.getText(blockName) - get text of blockName from the Document
* Document.getMap(blockName) - get key-value map of blockName from the Document

```js
sample.btf
[key1]
value1
---------

[key2]
value2

[key-value]
k1 : v1
k2 = v2

=========
[name1]
111
[name2]
222
[]
333
[\]
\
[\]]
]
[\]\]
\---------
[\][\]]
\=========
```

```js
// parser sample.btf
const BlockTextFile = require('@gotoeasy/btf');

let btf = new BlockTextFile('sample.btf');

console.info(btf.getText('key1') == 'value1'); // true
console.info(btf.getText('key2') == 'value2\n'); // true

let map = btf.getMap('key-value');
console.info(map.get('k1') == 'v1'); // true
console.info(map.get('k2') == 'v2'); // true

let docs = btf.getDocuments(); // array
console.info(docs.length == 2); // true
let doc1 = docs[0];
console.info(doc1.getText('key1') == 'value1'); // true
console.info(doc1.getText('key2') == 'value2\n'); // true
let doc2 = docs[1];
console.info(doc2.getText('name1') == '111'); // true
console.info(doc2.getText('name2') == '222'); // true
console.info(doc2.getText('') == '333'); // true
console.info(doc2.getText('\\') == '\\'); // true
console.info(doc2.getText(']') == ']'); // true
console.info(doc2.getText(']\\') == '---------'); // true
console.info(doc2.getText('][]') == '========='); // true

```
<br>
<br>

## `Links`
* `Block-Text-File Specification` https://github.com/gotoeasy/block-text-file
* `npm-packages` https://github.com/gotoeasy/npm-packages

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