Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sail-sail/generate_function

Module that helps you write generated functions in Deno
https://github.com/sail-sail/generate_function

Last synced: 1 day ago
JSON representation

Module that helps you write generated functions in Deno

Awesome Lists containing this project

README

        

# generate_function

Module that helps you write generated functions in Deno

fork by https://github.com/mafintosh/generate-function

## Disclamer

Writing code that generates code is hard. You should only use this if you really, really, really need this for performance reasons (like schema validators / parsers etc).

## usage
```ts
import { assertEquals } from "https://deno.land/[email protected]/testing/asserts.ts";
import { genfun } from "https://deno.land/x/[email protected]/mod.ts";

Deno.test("genfun", function() {
const fn = genfun()
('function add(n) {')
('return n + %d', 42)
('}');
assertEquals(fn.toString(), 'function add(n) {\n return n + 42\n}');
});

```