npm.io
1.0.0 • Published 3 years ago

cue-wasm

Licence
—
Version
1.0.0
Deps
1
Size
12.5 MB
Vulns
0
Weekly
0

Cue Wasm

Wasm bindings for cue. Works with node 16+ and modern browsers thanks to microbundle

contributors last update forks stars open issues license

Documentation · Report Bug · Request Feature


Table of Contents

Features

  • Cue to json cue.toJSON()
  • Cue to js object cue.parse()
  • Highly optimized - 2.1MB gzipped bundle size when using "slim" variant, 4.2MB for "full"

Getting Started

Installation

Install cue-wasm with yarn

  yarn add cue-wasm
Build Locally

Clone the project

  git clone https://github.com/dclareio/cue-wasm.git

Go to the project directory

  cd cue-wasm

Install dependencies

  yarn

Build the library (requires docker)

  yarn build

Usage

import CUE from 'cue-wasm'

const cue = await CUE.init();

// basic API
cue.parse('hello: "world"')  // returns { hello: "world" }

// Tagged template literals
const mergeObj = { test: "test" }
const obj = cue`
  key: "val"
  test: string
  ${mergeObj}
`; // returns { test: "test", key: "val" }

// note that for strings you'll need to quote them manually if you
// don't want cue to interpret them literally. This allows dynamically
// writing cue e.g.

cue`test: ${"test"}` // evaluates `test: test` vs.
cue`test: "${"test"}"` // evaluates `test: "test"`

Roadmap

  • CUE -> JSON/JS
  • CUE -> OpenAPI
  • CUE -> JSONSchema
  • CUE -> AST
  • CUE -> Typescripe Types
  • CUE -> Protobufs
  • JSON/JS -> CUE
  • JSONSchema -> CUE
  • Typescripe Types -> CUE
  • Protobufs -> CUE

License

Distributed under the MIT License. See LICENSE for more information.

Contact

@dclario - https://dclare.io - contact@dclare.io - We do consulting!!

Project Link: https://github.com/dclareio/cue-wasm

Acknowledgements