0.10.7 • Published 10 months ago
@kcl-lang/wasm-lib v0.10.7
KCL WASM Library for Node.js and Browser
Quick Start
Node.js
npm install @kcl-lang/wasm-lib
import { load, invokeKCLRun } from "@kcl-lang/wasm-lib";
async function main() {
const inst = await load();
const result = invokeKCLRun(inst, {
filename: "test.k",
source: `
schema Person:
name: str
p = Person {name = "Alice"}`,
});
console.log(result);
}
main();
Rust
cargo add kcl-wasm-lib --git https://github.com/kcl-lang/lib
cargo add anyhow
use anyhow::Result;
use kcl_wasm_lib::{KCLModule, RunOptions};
fn main() -> Result<()> {
let opts = RunOptions {
filename: "test.k".to_string(),
source: "a = 1".to_string(),
};
let mut module = KCLModule::from_path("path/to/kcl.wasm")?;
let result = module.run(&opts)?;
println!("{}", result);
Ok(())
}
Go
package main
import (
"fmt"
"github.com/kcl-lang/wasm-lib/pkg/module"
)
func main() {
m, err := module.New("../../kcl.wasm")
if err != nil {
panic(err)
}
result, err := m.Run(&module.RunOptions{
Filename: "test.k",
Source: "a = 1",
})
if err != nil {
panic(err)
}
fmt.Println(result)
}
Developing
- Install
node.js
- Install dependencies
npm install
Building
npm run compile
Testing
npm run test
Format
npm run format
0.10.7
10 months ago
0.10.5
10 months ago
0.10.6
10 months ago
0.10.4
10 months ago
0.10.3
10 months ago
0.10.2
10 months ago
0.10.0-rc.2
11 months ago
0.10.0-rc.1
11 months ago
0.10.0
11 months ago
0.10.0-beta.2
12 months ago
0.10.0-beta.1
12 months ago
0.10.0-alpha.2
1 year ago
0.10.0-alpha.1
1 year ago
0.9.3
1 year ago
0.9.2
1 year ago
0.9.1
1 year ago
0.9.0-rc.2
1 year ago
0.9.0-beta.2
1 year ago
0.9.0-beta.1
1 year ago