Skip to content

Instantly share code, notes, and snippets.

@josephfrazier
Created March 19, 2015 18:10
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save josephfrazier/71cdf43bf92f7ac369f7 to your computer and use it in GitHub Desktop.
Save josephfrazier/71cdf43bf92f7ac369f7 to your computer and use it in GitHub Desktop.
requirebin sketch
var browsersavefile = require( 'browsersavefile' );
var someHTML = [ '<div>HELLO WORLD</div>' ],
blobData = new Blob( someHTML, {type : 'text/html'});
browsersavefile( 'my file', blobData );
require=function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({browsersavefile:[function(require,module,exports){var URL=window.URL||window.webkitURL;module.exports=function browsersavefile(fileName,blob){if(!URL)throw new Error("URL is not supported cannot download file");var url=URL.createObjectURL(blob);var clickEV=document.createEvent("Event");clickEV.initEvent("click",true,true);var link=document.createElement("a");link.href=url;link.download=fileName;link.dispatchEvent(clickEV)}},{}]},{},[]);var browsersavefile=require("browsersavefile");var someHTML=["<div>HELLO WORLD</div>"],blobData=new Blob(someHTML,{type:"text/html"});browsersavefile("my file",blobData);
{
"name": "requirebin-sketch",
"version": "1.0.0",
"dependencies": {
"browsersavefile": "0.0.5"
}
}
<!-- contents of this file will be placed inside the <body> -->
<!-- contents of this file will be placed inside the <head> -->
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment