# grotto

> WASM lib for functional pure data manipulation

Latest version **0.0.2-alpha1** (published 2022-06-03) · MIT license · 0 weekly downloads

## Install

```sh
npm install grotto
pnpm add grotto
yarn add grotto
bun add grotto
```

## Health

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

Positive: has types; no vulnerabilities.

Warnings: low downloads; no esm support; pre 1.0.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.0.2-alpha1 |
| Published | 2022-06-03 |
| First published | 2022-06-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 49.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Maintainers | grotto |
| Keywords | WASM, Express, Templating Engine, Rust, String Interpolation |

## Links

- npm: https://www.npmjs.com/package/grotto
- Repository: https://git.sr.ht/~atalocke/grotto
- Homepage: https://git.sr.ht/~atalocke/grotto#readme
- Issues: https://todo.sr.ht/~atalocke/grotto
- npm.io page: https://npm.io/package/grotto

## 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

- 0.0.2-alpha1 (latest) — 2022-06-03
- 0.0.2-alpha — 2022-06-03
- 0.0.1-beta — 2022-06-03
- 0.0.1-alpha — 2022-06-02
- 0.0.1 — 2022-06-02

## README

<div align="center">

  <h1><code>Grotto</code></h1>

  <strong>WASM lib for functional pure data manipulation</strong>.

  <!-- <p>
    <a href="https://travis-ci.org/rustwasm/wasm-pack-template"><img src="https://img.shields.io/travis/rustwasm/wasm-pack-template.svg?style=flat-square" alt="Build Status" /></a>
  </p>

  <h3>
    <a href="https://rustwasm.github.io/docs/wasm-pack/tutorials/npm-browser-packages/index.html">Tutorial</a>
    <span> | </span>
    <a href="https://discordapp.com/channels/442252698964721669/443151097398296587">Chat</a>
  </h3>

  <sub>Built with 🦀🕸 by <a href="https://rustwasm.github.io/">The Rust and WebAssembly Working Group</a></sub>
-->
</div> 

## About

**Grotto** is a WASM library for manipulating pure data functionally. That means core JavaScript/TypeScript types like string, number, object, array, and boolean. Grotto abstracts away common types of data manipulation to increase application peformance. Leaving you to focus on the unique aspects of your application.

## 🚴 Usage
```sh 
npm i grotto
```
**A real world example of Grotto in the [Candy Apple](https://www.npmjs.com/package/candyapple) Express template engine**

```ts
import fs from 'fs'
import { replace } from 'grotto';

export function engine(filePath: string, options: object, callback: (err: any, render?: string | Buffer) => void): void {
    fs.readFile(filePath, (err, content) => {
        if (err) return callback(err);
        let render = content.toString();
        let guide = {};
        for (const [key, val] of Object.entries(options)) {
            if (key !== "settings" && key !== "_locals" && key !== "cache") {
               (guide as any)[key] = (options as any)[key]
            }

        }

        const result = replace(render, guide)

        // Object.entries(options).filter(([key, val]) => { key !== "settings" && key !== "_locals" && key !== "cache" }).map(([key, val]) => {
        //     const doubleBraceSelect: RegExp = new RegExp(`\{{2}${key}}}`, "g") // select all: `(?<=\{\{).*?(?=\}\})`
        //     render = render.replace(doubleBraceSelect, val)
        // })
        callback(null, result)
    })
}
```

<!-- ### 🐑 Use `cargo generate` to Clone this Template -->

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