Simplify Node.js API

This commit is contained in:
Wilson Lin 2020-01-05 14:10:21 +11:00
parent 89567988cf
commit 9ee904fdc0
2 changed files with 11 additions and 4 deletions

View File

@ -85,9 +85,7 @@ yarn add hyperbuild
```js
const hyperbuild = require("hyperbuild");
const code = Buffer.from("<p> Hello, world! </p>");
const len = hyperbuild.minify(code);
const minified = code.slice(0, len).toString();
const minified = hyperbuild.minify("<p> Hello, world! </p>");
```
</details>

View File

@ -1 +1,10 @@
module.exports = require('../native');
const hyperbuild = require('../native');
module.exports = {
minify: code => {
const buf = Buffer.from(code);
const len = hyperbuild.minify(buf);
return buf.slice(0, len).toString();
},
minify_in_place: hyperbuild.minify,
};