balena-temen
Advanced tools
Comparing version 0.0.15 to 0.0.16
@@ -52,8 +52,8 @@ /* tslint:disable */ | ||
/** | ||
* This re-exports `eval` into WASM-land, as `temen_evaluate`, with a prefix to avoid global namespace confusion | ||
* Evaluates the whole JSON | ||
* @param {any} arg0 | ||
* @returns {any} | ||
*/ | ||
module.exports.temen_evaluate = function(arg0) { | ||
return takeObject(wasm.temen_evaluate(addHeapObject(arg0))); | ||
module.exports.evaluate = function(arg0) { | ||
return takeObject(wasm.evaluate(addHeapObject(arg0))); | ||
}; | ||
@@ -94,2 +94,6 @@ | ||
module.exports.__wbindgen_json_parse = function(ptr, len) { | ||
return addHeapObject(JSON.parse(getStringFromWasm(ptr, len))); | ||
}; | ||
const TextEncoder = require('util').TextEncoder; | ||
@@ -96,0 +100,0 @@ |
/* tslint:disable */ | ||
export function temen_evaluate(arg0: any): any; | ||
export function evaluate(arg0: any): any; | ||
@@ -52,8 +52,8 @@ /* tslint:disable */ | ||
/** | ||
* This re-exports `eval` into WASM-land, as `temen_evaluate`, with a prefix to avoid global namespace confusion | ||
* Evaluates the whole JSON | ||
* @param {any} arg0 | ||
* @returns {any} | ||
*/ | ||
export function temen_evaluate(arg0) { | ||
return takeObject(wasm.temen_evaluate(addHeapObject(arg0))); | ||
export function evaluate(arg0) { | ||
return takeObject(wasm.evaluate(addHeapObject(arg0))); | ||
} | ||
@@ -92,2 +92,6 @@ | ||
export function __wbindgen_json_parse(ptr, len) { | ||
return addHeapObject(JSON.parse(getStringFromWasm(ptr, len))); | ||
} | ||
let cachedTextEncoder = new TextEncoder('utf-8'); | ||
@@ -94,0 +98,0 @@ |
@@ -8,3 +8,3 @@ { | ||
"description": "Templating engine for (not just) JSON", | ||
"version": "0.0.15", | ||
"version": "0.0.16", | ||
"license": "Apache-2.0", | ||
@@ -11,0 +11,0 @@ "repository": { |
@@ -29,10 +29,7 @@ # balena temen | ||
Anyone should be able to use this crate: | ||
This library is written in the Rust language and can be used: | ||
* as a Rust crate | ||
* as an NPM package (Node.js) | ||
* in the browser (Web Assembly) | ||
* directly, as a [Rust crate] | ||
* as an isomorphic [NPM package] (NodeJS & browser) | ||
NPM package / browser (Web Assembly) parts are not done yet and are under the construction. | ||
## Documentation | ||
@@ -45,2 +42,4 @@ | ||
### Rust | ||
Add as a dependency to your `Cargo.toml`: | ||
@@ -56,3 +55,3 @@ | ||
```rust | ||
use balena_temen::eval; | ||
use balena_temen::evaluate; | ||
use serde_json::json; | ||
@@ -75,5 +74,77 @@ | ||
assert_eq!(eval(data).unwrap(), evaluated); | ||
assert_eq!(evaluate(data).unwrap(), evaluated); | ||
``` | ||
### Node | ||
Add as a dependency to your `package.json`: | ||
```json | ||
{ | ||
"dependencies": { | ||
"balena-temen": "0" | ||
} | ||
} | ||
``` | ||
Evaluate simple JSON: | ||
```js | ||
const bt = require('balena-temen'); | ||
console.log( | ||
bt.evaluate({ | ||
"ssid": "Some Cool SSID!", | ||
"id": { | ||
"$$eval": "super.ssid | slugify" | ||
} | ||
}) | ||
); | ||
``` | ||
Fully working example available in the `examples/node` folder: | ||
```bash | ||
cd examples/node | ||
npm install | ||
npm start | ||
``` | ||
### Browser | ||
Add as a dependency to your `package.json`: | ||
```json | ||
{ | ||
"dependencies": { | ||
"balena-temen": "0" | ||
} | ||
} | ||
``` | ||
Evaluate simple JSON: | ||
```js | ||
import * as bt from "balena-temen"; | ||
console.log( | ||
bt.evaluate({ | ||
"ssid": "Some Cool SSID Network!", | ||
"id": { | ||
"$$eval": "super.ssid | slugify" | ||
} | ||
}) | ||
); | ||
``` | ||
Fully working example available in the `examples/browser` folder: | ||
```bash | ||
cd examples/browser | ||
npm install | ||
npm start | ||
``` | ||
Open `localhost:8080` in your browser and you should see evaluated JSON in the browser console. | ||
## Support | ||
@@ -86,3 +157,3 @@ | ||
`balena-temen` is free software, and may be redistributed under the terms specified in | ||
`balena-temen` is open source software, and may be redistributed under the terms specified in | ||
the [license]. | ||
@@ -96,1 +167,3 @@ | ||
[Expression language documentation]: https://github.com/balena-io-modules/balena-temen/blob/master/docs/expression.md | ||
[Rust crate]: https://crates.io/crates/balena-temen | ||
[NPM package]: https://www.npmjs.com/package/balena-temen |
Sorry, the diff of this file is not supported yet
1133611
192
164