Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
Park-Miller-Carta PRNG
(documentation in progress) This is a multi-language repository, demonstrating C-Rust-Node.js-Web interoperability/portability.
It utilizes Rust as a build system, in order to compile the original C implemetations by Robin Whittle. A faithful Rust port is also included, cross-compilable to asm.js and WebAssembly via Emscripten, for use in Node.js and browsers.
Using from browser
Add with npm i --save --only=production park-miller-carta-prng
.
index.html:
Wasm
host the html via python2 -m SimpleHTTPServer
/python3 -m http.server
of your preferred method.
Using from Node.js
WebAssembly & asm.js
Add with npm i --save --only=production park-miller-carta-prng
.
index.js:
let = require;
let assert = require;
// use asm.js version
let generator = ;
;
generator.;
// use wasm version
generator = ;
;
generator.;
You should always call destroy()
when you are done using the generator.
Available methods:
prng
, takes either the suppliedasmjs
, orwasm
modules, generated byemcc
. Then, it must be supplied with a positive seed integer.getInteger
,getFloat
anddestroy
methods, are self explanatory.
Native Addon
Clone the repository and npm run build:addon
.
check src/test.coffee
for usage.
[Todo] simple API, conditional build on npm download.
Using from Rust
Add park-miller-carta-prng
to [dependencies]
in Cargo.toml
main.rs:
extern crate prng;
use PRNG;
Getting Started
- Clone the repository:
git clone https://github.com/kenOfYugen/park-miller-carta-prng
- Enter the directory:
cd park-miller-carta-prng
- Build (add the
--release
flag for optimized builds)
- Rust-C static/dynamic libraries:
cargo b
- asm.js library:
cargo b --target asmjs-unknown-emscripten
- wasm library:
cargo b --target wasm32-unknown-emscripten
- standalone wasm library:
cargo b --target wasm32-unknown-unknown
- Node.js:
npm i && npm run build:all
Prerequisites
Checklist
- Rust API
- C API
- Node.js asm.js/wasm via
emscripten
- Node.js native Addon
- Browser asm.js/wasm via
emscripten
- wasm via
--target wasm32-unknown-unknown