pex-io
Basic file i/o for the pex library.
Works both in Plask and any browser.
Usage
npm install pex-io
var io = io //or import functions individually var loadImage =
Async
From v2 all methods are async if called without callback as a second parameter. e.g.:
Can be now written as
const text = await console
API
io.load(resources, callback)
Loads list of resources
provided as a hash map of { name: { type: url }}
.
var resources = hdrImg: binary: __dirname + '/tex.hdr' img: image: __dirname + '/tex.jpg' data: json: __dirname + '/data.json' hello: text: __dirname + '/hello.txt' io
io.loadBinary(url, callback)
Loads binary data as an ArrayBuffer from url
addess in a Browser or file path in Plask.
io
io.loadImage(url, callback)
Loads a HTML Image from an url in a Borwser or SkCanvas from a file path in Plask.
io
How to enable CORS:
io
io.loadJSON(url, callback)
Loads a JSON file from an url url in a Browser of from a file path in Plask.
io
io.loadText(url, callback)
Loads a text file from an url url in a Browser of from a file path in Plask.
io