local-uri

Generates a local URI from a String or Typed Array, with fallbacks for older browsers

Usage no npm install needed!

<script type="module">
  import localUri from 'https://cdn.skypack.dev/local-uri';
</script>

README

local-uri

Generates a local URI from a String or Typed Array, with fallbacks for older browsers.

Usage

NPM

uri = createURI(data, type)

data is a String or Typed Array (e.g. Float32Array), and will be the content recieved when the uri is requested.

type is the mime type to use for the URI. Defaults to text/plain;charset=US-ASCII.

var createURI = require('local-uri')
var xhr       = require('xhr')

var uri = createURI('hello world!')

xhr({ uri: uri }, function(err, res, body) {
  console.log(body) // "hello world!"
})

License

MIT. See LICENSE.md for details.