Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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
- Host: GitHub
- URL: https://github.com/sail-sail/generate_function
- Owner: sail-sail
- License: mit
- Created: 2022-05-17T08:28:37.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-06-10T03:14:51.000Z (over 2 years ago)
- Last Synced: 2025-02-01T00:28:29.116Z (5 days ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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}');
});```