Contents:
- cpu-count is the example from the Neon docs.
- allbooks is a more complex example with more complex Rust types.
Build the Rust code with cargo build
from the root and the allbooks
project from its
directory with npm install
and npm run build --release
.
You can now use it from the root with node
:
const allbooks = require('./allbooks')
allbooks.get_books()
Output:
[
{
title: 'Chadwick the Crab',
[
{
title: 'Chadwick the Crab',
author: 'Priscilla Cummings',
year: 2009
},
{
title: 'The Little Prince',
author: 'Antoine de Saint-Exupéry',
year: 1943
},
{ title: 'The Hobbit', author: 'J. R. R. Tolkien', year: 1937 }
]
- NPM 7 minimum
- Rust