-
Notifications
You must be signed in to change notification settings - Fork 6
Node.js Interoperability
Vihan edited this page Nov 18, 2018
·
3 revisions
VSL is designed to have a consistent ABI for most types. For ICP the OS may provide a mechanism but you can still construct objects which can be passed through Buffers. This is the equivalent of the vsl/native.h
for Node.js.
import * as VSL from 'vsl/interop';
let vslString = VSL.String.from("Hello, World!"); // Wraps in VSL string
vslString.toBuffer();
vslString.toString();
vslString.toArrayBuffer();
let vslNumber = VSL.Number.from(123, {
width: 64, // default 32 on 32-bit systems and 64 on 64-bit systems
signed: true, // default `true`
}); // Converts to a Int dependent on system settings
vslNumber.toBuffer();
vslNumber.toNumber();
vslNumber.toArrayBuffer();
let vslBool = VSL.Boolean.from(true);
vslBool.toBuffer();
vslBool.toNumber();
vslBool.toArrayBuffer();
The easiest way to unwrap these objects is then by a bit case:
let stdinData: ByteSequence = ...;
let unwrapped = String[]::stdinData;
- Introduction
- Installation
- VSL By Example
- Usage
- WASM (WebAssembly)
- The Basics
- Your First Program
- Syntax
- Concepts
- Modules
- Advanced Details
- Interop
- VSL Development
- Common Errors