diff --git a/README.md b/README.md index d077420..30255f0 100644 --- a/README.md +++ b/README.md @@ -25,3 +25,30 @@ console.log(hello); hello.any(); ``` + +```bash +node example.js +``` + +## How I made this + +1. Install [Node.js](https://nodejs.org). +2. Install build tools + * macOS: XCode and `xcode-select install` (CLI Tools) + * Windows: `npm install --global --production windows-build-tools` + * Ubuntu: `sudo apt install -y build-essential` +3. Install Rust +4. Install neon; Create (and rename) project + +```bash +npm install --global neon-cli +neon version +neon new hello.neon +mv hello.neon hello.neon.js +pushd hello.neon.js +neon build +``` + +Then I just followed along in +[the docs](https://neon-bindings.com/docs/hello-world) +and [the examples](https://github.com/neon-bindings/examples) diff --git a/example.js b/example.js new file mode 100644 index 0000000..54e6508 --- /dev/null +++ b/example.js @@ -0,0 +1,31 @@ +'use strict'; + +var hello = require('.'); +//var hello = require('hello.neon'); + +console.log('hello()', hello.hello()); +console.log('threadCount()', hello.threadCount()); +console.log('greet("Bob")', hello.greet("Bob")); +console.log('noop()', hello.noop()); +console.log('any()', hello.any()); +console.log('any()', hello.any()); +console.log('any()', hello.any()); +console.log('any()', hello.any()); +console.log('any()', hello.any()); +console.log('any()', hello.any()); +console.log('any()', hello.any()); + +if (Math.round(Math.random() * 1)) { + console.log('throw()'); + console.log(hello.throw()); +} else { + try { + console.log(console.log('panic()')); + console.log(hello.panic()); + } catch(e) { + console.error('caught error:'); + console.error(e); + } +} + +console.log("all done");