# tinyml-core

> TinyML-syntax parser

Latest version **2.0.16** (published 2022-10-19) · MIT license · 0 weekly downloads

## Install

```sh
npm install tinyml-core
pnpm add tinyml-core
yarn add tinyml-core
bun add tinyml-core
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned.

## Facts

| | |
|---|---|
| Version | 2.0.16 |
| Published | 2022-10-19 |
| First published | 2022-10-16 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 95.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Iuriiiii |
| Maintainers | iuriiiii |
| Keywords | TinyML, TypeScript |

## Links

- npm: https://www.npmjs.com/package/tinyml-core
- Repository: https://github.com/Iuriiiii/TinyML-core
- Homepage: https://github.com/Iuriiiii/TinyML-core#readme
- Issues: https://github.com/Iuriiiii/TinyML-core/issues
- npm.io page: https://npm.io/package/tinyml-core

## Alternatives

- [monaco-yaml](https://npm.io/package/monaco-yaml.md) — 420.1K weekly downloads
- [@crewx/workflow](https://npm.io/package/@crewx/workflow.md) — 3.1K weekly downloads
- [yaml-cat](https://npm.io/package/yaml-cat.md) — 38 weekly downloads
- [nunjucks-in-yaml](https://npm.io/package/nunjucks-in-yaml.md) — 9 weekly downloads
- [shopify-symlinks](https://npm.io/package/shopify-symlinks.md) — 3 weekly downloads

## Recent versions

- 2.0.16 (latest) — 2022-10-19
- 2.0.14 — 2022-10-19
- 2.0.10 — 2022-10-16
- 2.0.9 — 2022-10-16
- 2.0.8 — 2022-10-16
- 2.0.7 — 2022-10-16
- 2.0.6 — 2022-10-16
- 2.0.5 — 2022-10-16
- 2.0.3 — 2022-10-16

## README

# TinyML Core

TinyML Core is a little, faster and lightweight module that will help you to parse the source code of TinyML.

❌ Please don't use until we delete this message, this lib is under construction 🚫

## Installation

    npm install tinyml-core

## Concept

The structure pattern is similar to HTML, you will get tags, content, params and comments.

<table>
<tr>
<th>HTML</th>
<th>TinyML</th>
</tr>
<tr>
<td>

```html
<!DOCTYPE html>
<html lang="en">
    <head>
        <title>The page title</title>
    </head>
    <body>
        <!-- This is a comment -->
        <hr/>
        <div class="container">
            <h1>My first title</h1>
            <p>
                Lorem ipsum dolor sit<br>
                amet, consectetur
            <p>
        </div>
    </body>
</html>
```

</td>
<td>

```
{!DOCTYPE html}
html(lang="en") {
    head {
        title {The page title}
    }
    body {
        [ This is a comment ]
        hr;
        div(class="container") {
            h1 {My first title}
            p {
                Lorem ipsum dolor sit\n
                amet, consectetur
            }
        }
    }
}
```

</td>
</tr>
</table>

## Functions

### From `Core`

#### parse

❕ This method will help you to parse synchronically a TinyML-syntax source.

##### Return

✅ An array with the data

❌ Throw an error.

##### Params:

🔹 source: string - The source code to parse.

##### Example:

```js
import { Core } from 'tinyml-core/common';

try {
    var parsed = Core.parse(`
    thisIsATag(param1) {
        This is a raw content
        tag{This is raw content too}
        [This is a commentary]
    } Raw content again
`);
} catch (e) {
    console.error(e);
}
```

## Data description

`Core.parse` returns an array of the following kind of elements if succedes:

* <b>Core.Element</b>
* <b>Core.Raw</b>
* <b>Core.Comment</b>
* <b>Core.Code</b>

### Global methods & members

The following members & methods will be inherited by `Core.Raw`, `Core.Element`, `Core.Comment` and `Core.Code`

🔹 <b>tokens: Token[]</b> - All tokens catched for the instance.

🔹 <b>isRaw(): boolean</b> - Checks if the instance is a `Core.Raw` instance.

🔹 <b>isElement(): boolean</b> - Checks if the instance is a `Core.Element` instance.

🔹 <b>isComment(): boolean</b> - Checks if the instance is a `Core.Comment` instance.

🔹 <b>isCode(): boolean</b> - Checks if the instance is a `Core.Code` instance.

🔹 <b>toString(): string</b> - A string representation of all tokens contained in the instance.

### The `Token` data type

This data type contains information about an element of the source code. It has the following members:

🔹 <b>text: string</b> - The string of the token.

🔹 <b>pos: TokenPosition /* {x: number, y: number} */</b> - The location of the token in the source code.

🔹 <b>text: TokenType</b> - The token type.


### Core.Element

This data type defines an element. It is composed by the following members.

🔹 <b>tag: Token</b> - The token that contain the tag name and location. The type ever will be `TokenType.identifier`.

🔹 <b>params: Token[]</b> - All tokens that compounds the parameters.

🔹 <b>children: (Core.Element | Core.Raw | Core.Comment | Core.Code)[] | undefined</b> - The content inside of. An array of TinyML elements or undefined.

### Core.Raw

This data type different to `Core.Element` element, generally the content of this last one.

> Does not contain new methods or members by itself.

### Core.Comment

This data type defines the content between `[` and `]` characters.

> Does not contain new methods or members by itself.

### Core.Code

This data type defines the content between unnamed `{` and `}` characters.

> Does not contain new methods or members by itself.

####

<table>
<tr>
<th>Named Block</th>
<th>Unnamed Block</th>
</tr>
<tr>
<td>

```
namedBlock {
    content of named block
}
```

</td>
<td>

```
{
    content of unnamed block
}
```

</td>
</tr>
</table>

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