Skip to content

matthewbauer/plugin-raw

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

70 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

raw plugin for SystemJS

Loads raw array buffers in a way that can be imported in SystemJS projects.

Basic Use

System.import('./data.exe!raw').then(function(data) {})

'data' out will be an ArrayBuffer. For more info on the ArrayBuffer, see the MDN article. You cannot modify the ArrayBuffer, instead you must create a view on it with:

var view = new Uint8Array(data)

This will give you an 8-bit view where each index in the buffer object is an unsigned 8 bit integer.

Note: this data will not be bundled with the SystemJS builder. If you need this data, make sure the URL can correctly resolve to it after you've bundled.

Text Usage

You can convert the data from an ArrayBuffer to a JS String using the TextDecoder interface. Like so:

var text = TextDecoder('utf-8').decode(new Uint8Array(data))

The polyfill and more detailed examples are available in @inexorabletash's text-encoding library.

Testing

The tests should work in both Node and on the web. The page "test.html" should load the tests (you can run the server with python -m SimpleHTTPServer). You can compare them to: http://matthewbauer.us/plugin-raw/test.html

To run in node:

mocha --compilers js:babel/register test.js

License

MIT

About

raw loader plugin

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 90.7%
  • HTML 9.3%