0.1.1 • Published 4 years ago

synox v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
4 years ago

Synox JavaScript bindings npm

This package implements JavaScript bindings for Synox, a library for program synthesis of string transformations from input-output examples.

Installation

npm install synox

This package expects that you are using a bundler like Webpack, and your deployment target supports WebAssembly. For best results, the core of Synox should be run in a Web Worker.

Example

worker.js

import { workerMain } from 'synox'

workerMain()

main.js

import { init } from 'synox'

const worker = new Worker('worker.js')
const Synox = await init(worker)

const unpaired = []
const examples = [
  [["Alyssa P. Hacker", "1985"], "A. Hacker '85"],
  [["Ben Bitdiddle",    "2002"], "B. Bitdiddle '02"],
]

const prog = await Synox.blinkfill.learn(unpaired, examples)
const result = await prog.run(["Cy D. Fect", "2017"])
console.assert(result === "C. Fect '17")

await prog.free()

License

Copyright (c) 2021 Anish Athalye. Released under the MIT License. See LICENSE.md for details.