GithubHelp home page GithubHelp logo

url4data's Introduction

url4data

Get a URL for the given data

Usage:

var url4data = require('url4data');

url4data('hello world', 'name', {type: 'text/plain', scheme: ['filesystem', 'blob', 'data']}, function(url) {
    console.log(url);
});

The scheme option can be used to choose the URL scheme, either a single value or an array of schemes to try in order (returning first supported by the browser, so you can fallback to alternative schemes if necessary). See demo.js for more examples.

Supported schemes

filesystem: from the HTML5 FileSystem API, supported by Chrome. These URLs are predictable and semi-persistent. url4data uses the "temporary" not "persistent" filesystem storage, but the URL persists across page reloads (although it can be deleted by the browser at any time).

blob: from the HTML5 File API, supported by most modern browsers. Not predictable (random GUID), but url4data stores the generated URLs in localStorage in an attempt at providing consistency across multiple invocations. Blob URLs might expire on page load or otherwise fairly frequently.

data: URLs are widely supported, but cannot be used everywhere filesystem: and blob: URLs can be used. They encode the data directly within the URL itself.

Why?

Useful, for example, for SharedWorkers which require the same URL to access the same shared worker across multiple browser tabs.

License

MIT

url4data's People

Contributors

deathcap avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.