npm package: @stagas/mono
Description: mono is a low level language for audio expressions that compiles to wasm
Author: stagas
Latest version: 0.1.0

<h1 align="center">mono</h1>

<p align="center">
mono is a low level language for audio expressions that compiles to wasm
</p>

<p align="center">
   <a href="#install">        🔧 <strong>Install</strong></a>
 · <a href="#example">        🧩 <strong>Example</strong></a>
 · <a href="#api">            📜 <strong>API docs</strong></a>
 · <a href="https://github.com/stagas/mono/releases"> 🔥 <strong>Releases</strong></a>
 · <a href="#contribute">     💪🏼 <strong>Contribute</strong></a>
 · <a href="https://github.com/stagas/mono/issues">   🖐️ <strong>Help</strong></a>
</p>

***

## Install

```sh
$ npm i @stagas/mono
```

**-- work in progress --**

## API

<!-- Generated by documentation.js. Update this documentation by updating the source code. -->

#### Table of Contents

*   [todo](#todo)
*   [bin](#bin)
    *   [Parameters](#parameters)
*   [typebin](#typebin)
    *   [Parameters](#parameters-1)
*   [eq](#eq)
    *   [Parameters](#parameters-2)
*   [funcDef](#funcdef)
    *   [Parameters](#parameters-3)
*   [Op](#op)
*   [OpArgs](#opargs)
*   [build](#build)
    *   [Parameters](#parameters-4)
*   [map](#map)
    *   [Parameters](#parameters-5)
*   [typeOf](#typeof)
    *   [Parameters](#parameters-6)
*   [typeAs](#typeas)
    *   [Parameters](#parameters-7)
*   [cast](#cast)
    *   [Parameters](#parameters-8)
*   [castAll](#castall)
    *   [Parameters](#parameters-9)
*   [hi](#hi)
    *   [Parameters](#parameters-10)
*   [max](#max)
    *   [Parameters](#parameters-11)
*   [top](#top)
    *   [Parameters](#parameters-12)
*   [infer](#infer)
    *   [Parameters](#parameters-13)
*   [flatten](#flatten)
    *   [Parameters](#parameters-14)
*   [mush](#mush)
    *   [Parameters](#parameters-15)

### todo

[src/compiler.ts:92-92](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L92-L92 "Source code on GitHub")

todo is a "not implemented" marker for ops

### bin

[src/compiler.ts:95-98](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L95-L98 "Source code on GitHub")

constructs a binary op of least type `type`

#### Parameters

*   `type` **Type**&#x20;
*   `op` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

Returns **[Op](#op)**&#x20;

### typebin

[src/compiler.ts:101-104](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L101-L104 "Source code on GitHub")

constructs a binary op of exact type `type`

#### Parameters

*   `type` **Type**&#x20;
*   `op` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

Returns **[Op](#op)**&#x20;

### eq

[src/compiler.ts:107-113](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L107-L113 "Source code on GitHub")

constructs an equality op

#### Parameters

*   `op` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;

Returns **[Op](#op)**&#x20;

### funcDef

[src/compiler.ts:116-123](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L116-L123 "Source code on GitHub")

defines a function

#### Parameters

*   `ctx` **Context**&#x20;
*   `ops` **OpTable**&#x20;
*   `sym` **(Token | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String))**&#x20;
*   `args` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)>**&#x20;
*   `rhs` **[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)**&#x20;

### Op

[src/compiler.ts:126-335](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L126-L335 "Source code on GitHub")

primary optable

Type: OpTable

### OpArgs

[src/compiler.ts:338-349](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L338-L349 "Source code on GitHub")

arguments optable

Type: OpTable

### build

[src/compiler.ts:352-365](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L352-L365 "Source code on GitHub")

builds a `node` under context `ctx` and optable `ops`

#### Parameters

*   `node` **[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)**&#x20;
*   `ctx` **Context**&#x20;
*   `ops` **OpTable**&#x20;

Returns **SExpr**&#x20;

### map

[src/compiler.ts:368-372](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/compiler.ts#L368-L372 "Source code on GitHub")

builds an array of `nodes` under context `ctx` and optable `ops`

#### Parameters

*   `nodes` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)>**&#x20;
*   `ctx` **Context**&#x20;
*   `ops` **OpTable**&#x20;

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<SExpr>**&#x20;

### typeOf

[src/typed.ts:31-31](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L31-L31 "Source code on GitHub")

looks up and returns the type of `x`, if found, otherwise returns type `any`

#### Parameters

*   `x` **([undefined](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/undefined) | [string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String) | SExpr)**&#x20;

Returns **Type**&#x20;

### typeAs

[src/typed.ts:34-34](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L34-L34 "Source code on GitHub")

marks sexpr `x` to be of type `type`

#### Parameters

*   `type` **Type**&#x20;
*   `x` **SExpr**&#x20;

### cast

[src/typed.ts:37-46](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L37-L46 "Source code on GitHub")

creates a cast operation if the given value `x` doesn't satisfy `type`

#### Parameters

*   `type` **Type**&#x20;
*   `x` **SExpr**&#x20;

### castAll

[src/typed.ts:49-49](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L49-L49 "Source code on GitHub")

casts all `values` to be of type `type`

#### Parameters

*   `type` **Type**&#x20;
*   `values` **...SExpr**&#x20;

Returns **SExpr**&#x20;

### hi

[src/typed.ts:52-55](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L52-L55 "Source code on GitHub")

returns the highest precision type of the given values

#### Parameters

*   `values` **...SExpr**&#x20;

Returns **Type**&#x20;

### max

[src/typed.ts:58-60](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L58-L60 "Source code on GitHub")

returns at least the precision of the given type among the given types

#### Parameters

*   `type` **Type**&#x20;
*   `types` **...[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<Type>**&#x20;

Returns **Type**&#x20;

### top

[src/typed.ts:63-67](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L63-L67 "Source code on GitHub")

types an operation with the correct prefix (f32 or i32) and type casts the values to satisfy the op

#### Parameters

*   `type` **Type**&#x20;
*   `ops` **SExpr**&#x20;

Returns **SExpr**&#x20;

### infer

[src/typed.ts:70-75](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/typed.ts#L70-L75 "Source code on GitHub")

infers the type of a token literal string: bool for 0 or 1, i32 for integers and f32 for floats

#### Parameters

*   `x` **Token**&#x20;

Returns **Type**&#x20;

### flatten

[src/util.ts:4-9](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/util.ts#L4-L9 "Source code on GitHub")

flattens a node that is left hand side recursing on symbol `sym`

#### Parameters

*   `sym` **[string](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String)**&#x20;
*   `x` **[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)**&#x20;

Returns **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)<[Node](https://developer.mozilla.org/docs/Web/API/Node/nextSibling)>**&#x20;

### mush

[src/util.ts:12-16](https://github.com/stagas/mono/blob/dea884701068fcda3cbb2ee9b908529cb3039b33/src/util.ts#L12-L16 "Source code on GitHub")

Merges or pUSHes `obj` to array `arr`

#### Parameters

*   `arr` **[Array](https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Array)\<any>**&#x20;
*   `obj` **any**&#x20;

## Contribute

[Fork](https://github.com/stagas/mono/fork) or
[edit](https://github.dev/stagas/mono) and submit a PR.

All contributions are welcome!

## License

MIT © 2022
[stagas](https://github.com/stagas)