Comparing version 1.2.1 to 1.3.0
@@ -187,3 +187,3 @@ (function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.blobUtil = f()}})(function(){var define,module,exports;return (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})({1:[function(_dereq_,module,exports){ | ||
module.exports = exports = Promise; | ||
module.exports = Promise; | ||
@@ -294,3 +294,3 @@ function Promise(resolver) { | ||
var then = obj && obj.then; | ||
if (obj && typeof obj === 'object' && typeof then === 'function') { | ||
if (obj && (typeof obj === 'object' || typeof obj === 'function') && typeof then === 'function') { | ||
return function appyThen() { | ||
@@ -343,3 +343,3 @@ then.apply(obj, arguments); | ||
exports.resolve = resolve; | ||
Promise.resolve = resolve; | ||
function resolve(value) { | ||
@@ -352,3 +352,3 @@ if (value instanceof this) { | ||
exports.reject = reject; | ||
Promise.reject = reject; | ||
function reject(reason) { | ||
@@ -359,3 +359,3 @@ var promise = new this(INTERNAL); | ||
exports.all = all; | ||
Promise.all = all; | ||
function all(iterable) { | ||
@@ -399,3 +399,3 @@ var self = this; | ||
exports.race = race; | ||
Promise.race = race; | ||
function race(iterable) { | ||
@@ -635,2 +635,15 @@ var self = this; | ||
/** | ||
* Convert a <code>Blob</code> to a data URL string | ||
* (e.g. <code>'data:image/png;base64,iVBORw0KG...'</code>). | ||
* Returns a Promise. | ||
* @param {Blob} blob | ||
* @returns {Promise} Promise that resolves with the data URL string | ||
*/ | ||
function blobToDataURL(blob) { | ||
return blobToBase64String(blob).then(function (base64String) { | ||
return 'data:' + blob.type + ';base64,' + base64String; | ||
}); | ||
} | ||
/** | ||
* Convert an image's <code>src</code> URL to a data URL by loading the image and painting | ||
@@ -742,2 +755,3 @@ * it to a <code>canvas</code>. Returns a Promise. | ||
dataURLToBlob : dataURLToBlob, | ||
blobToDataURL : blobToDataURL, | ||
blobToBase64String : blobToBase64String, | ||
@@ -744,0 +758,0 @@ base64StringToBlob : base64StringToBlob, |
@@ -1,1 +0,1 @@ | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.blobUtil=e()}}(function(){return function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[u]={exports:{}};t[u][0].call(l.exports,function(e){var n=t[u][1][e];return o(n?n:e)},l,l.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){(function(e){function n(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.buffer instanceof ArrayBuffer){var r=n.buffer;if(n.byteLength!==r.byteLength){var o=new Uint8Array(n.byteLength);o.set(new Uint8Array(r,n.byteOffset,n.byteLength)),r=o.buffer}e[t]=r}}}function r(e,t){t=t||{};var r=new i;n(e);for(var o=0;o<e.length;o++)r.append(e[o]);return t.type?r.getBlob(t.type):r.getBlob()}function o(e,t){return n(e),new Blob(e,t||{})}var i=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,u=function(){try{var e=new Blob(["hi"]);return 2===e.size}catch(t){return!1}}(),f=u&&function(){try{var e=new Blob([new Uint8Array([1,2])]);return 2===e.size}catch(t){return!1}}(),a=i&&i.prototype.append&&i.prototype.getBlob;t.exports=function(){return u?f?e.Blob:o:a?r:void 0}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){(function(e){"use strict";function n(){l=!0;for(var e,t,n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}l=!1}function r(e){1!==s.push(e)||l||o()}var o,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var u=0,f=new i(n),a=e.document.createTextNode("");f.observe(a,{characterData:!0}),o=function(){a.data=u=++u%2}}else if(e.setImmediate||"undefined"==typeof e.MessageChannel)o="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var c=new e.MessageChannel;c.port1.onmessage=n,o=function(){c.port2.postMessage(0)}}var l,s=[];t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){"use strict";function r(){}function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=w,this.queue=[],this.outcome=void 0,e!==r&&a(this,e)}function i(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function u(e,t,n){p(function(){var r;try{r=t(n)}catch(o){return v.reject(e,o)}r===e?v.reject(e,new TypeError("Cannot resolve promise with itself")):v.resolve(e,r)})}function f(e){var t=e&&e.then;return e&&"object"==typeof e&&"function"==typeof t?function(){t.apply(e,arguments)}:void 0}function a(e,t){function n(t){i||(i=!0,v.reject(e,t))}function r(t){i||(i=!0,v.resolve(e,t))}function o(){t(r,n)}var i=!1,u=c(o);"error"===u.status&&n(u.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(r){n.status="error",n.value=r}return n}function l(e){return e instanceof this?e:v.resolve(new this(r),e)}function s(e){var t=new this(r);return v.reject(t,e)}function h(e){function t(e,t){function r(e){u[t]=e,++f!==o||i||(i=!0,v.resolve(c,u))}n.resolve(e).then(r,function(e){i||(i=!0,v.reject(c,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,i=!1;if(!o)return this.resolve([]);for(var u=new Array(o),f=0,a=-1,c=new this(r);++a<o;)t(e[a],a);return c}function d(e){function t(e){n.resolve(e).then(function(e){i||(i=!0,v.resolve(f,e))},function(e){i||(i=!0,v.reject(f,e))})}var n=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var o=e.length,i=!1;if(!o)return this.resolve([]);for(var u=-1,f=new this(r);++u<o;)t(e[u]);return f}var p=e(2),v={},y=["REJECTED"],b=["FULFILLED"],w=["PENDING"];t.exports=n=o,o.prototype["catch"]=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===b||"function"!=typeof t&&this.state===y)return this;var n=new this.constructor(r);if(this.state!==w){var o=this.state===b?e:t;u(n,o,this.outcome)}else this.queue.push(new i(n,e,t));return n},i.prototype.callFulfilled=function(e){v.resolve(this.promise,e)},i.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},i.prototype.callRejected=function(e){v.reject(this.promise,e)},i.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},v.resolve=function(e,t){var n=c(f,t);if("error"===n.status)return v.reject(e,n.value);var r=n.value;if(r)a(e,r);else{e.state=b,e.outcome=t;for(var o=-1,i=e.queue.length;++o<i;)e.queue[o].callFulfilled(t)}return e},v.reject=function(e,t){e.state=y,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},n.resolve=l,n.reject=s,n.all=h,n.race=d},{2:2}],4:[function(e,t,n){t.exports="function"==typeof Promise?Promise:e(3)},{3:3}],5:[function(e,t,n){"use strict";function r(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=-1;++o<t;)r[o]=e.charCodeAt(o);return n}function o(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=-1;++o<r;)t+=String.fromCharCode(n[o]);return t}function i(e,t){return new B(function(n,r){var o=new Image;t&&(o.crossOrigin=t),o.onload=function(){n(o)},o.onerror=r,o.src=e})}function u(e){var t=document.createElement("canvas");t.width=e.width,t.height=e.height;var n=t.getContext("2d");return n.drawImage(e,0,0,e.width,e.height,0,0,e.width,e.height),t}function f(e,t){return t=t||{},"string"==typeof t&&(t={type:t}),new m(e,t)}function a(e){return(window.URL||window.webkitURL).createObjectURL(e)}function c(e){return(window.URL||window.webkitURL).revokeObjectURL(e)}function l(e){return new B(function(t,n){var r=new FileReader,i="function"==typeof r.readAsBinaryString;r.onloadend=function(e){var n=e.target.result||"";return i?t(n):void t(o(n))},r.onerror=n,i?r.readAsBinaryString(e):r.readAsArrayBuffer(e)})}function s(e,t){return B.resolve().then(function(){var n=[r(atob(e))];return t?f(n,{type:t}):f(n)})}function h(e,t){return B.resolve().then(function(){return s(btoa(e),t)})}function d(e){return l(e).then(function(e){return btoa(e)})}function p(e){return B.resolve().then(function(){var t=e.match(/data:([^;]+)/)[1],n=e.replace(/^[^,]+,/,""),o=r(atob(n));return f([o],{type:t})})}function v(e,t,n,r){return t=t||"image/png",i(e,n).then(function(e){return u(e)}).then(function(e){return e.toDataURL(t,r)})}function y(e,t,n){return B.resolve().then(function(){return"function"==typeof e.toBlob?new B(function(r){e.toBlob(r,t,n)}):p(e.toDataURL(t,n))})}function b(e,t,n,r){return t=t||"image/png",i(e,n).then(function(e){return u(e)}).then(function(e){return y(e,t,r)})}function w(e,t){return B.resolve().then(function(){return f([e],t)})}function g(e){return new B(function(t,n){var r=new FileReader;r.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},r.onerror=n,r.readAsArrayBuffer(e)})}var m=e(1),B=e(4);t.exports={createBlob:f,createObjectURL:a,revokeObjectURL:c,imgSrcToBlob:b,imgSrcToDataURL:v,canvasToBlob:y,dataURLToBlob:p,blobToBase64String:d,base64StringToBlob:s,binaryStringToBlob:h,blobToBinaryString:l,arrayBufferToBlob:w,blobToArrayBuffer:g}},{1:1,4:4}]},{},[5])(5)}); | ||
!function(e){if("object"==typeof exports&&"undefined"!=typeof module)module.exports=e();else if("function"==typeof define&&define.amd)define([],e);else{var t;t="undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:this,t.blobUtil=e()}}(function(){return function e(t,n,r){function o(u,f){if(!n[u]){if(!t[u]){var a="function"==typeof require&&require;if(!f&&a)return a(u,!0);if(i)return i(u,!0);var c=new Error("Cannot find module '"+u+"'");throw c.code="MODULE_NOT_FOUND",c}var l=n[u]={exports:{}};t[u][0].call(l.exports,function(e){var n=t[u][1][e];return o(n||e)},l,l.exports,e,t,n,r)}return n[u].exports}for(var i="function"==typeof require&&require,u=0;u<r.length;u++)o(r[u]);return o}({1:[function(e,t,n){(function(e){function n(e){for(var t=0;t<e.length;t++){var n=e[t];if(n.buffer instanceof ArrayBuffer){var r=n.buffer;if(n.byteLength!==r.byteLength){var o=new Uint8Array(n.byteLength);o.set(new Uint8Array(r,n.byteOffset,n.byteLength)),r=o.buffer}e[t]=r}}}function r(e,t){t=t||{};var r=new i;n(e);for(var o=0;o<e.length;o++)r.append(e[o]);return t.type?r.getBlob(t.type):r.getBlob()}function o(e,t){return n(e),new Blob(e,t||{})}var i=e.BlobBuilder||e.WebKitBlobBuilder||e.MSBlobBuilder||e.MozBlobBuilder,u=function(){try{return 2===new Blob(["hi"]).size}catch(e){return!1}}(),f=u&&function(){try{return 2===new Blob([new Uint8Array([1,2])]).size}catch(e){return!1}}(),a=i&&i.prototype.append&&i.prototype.getBlob;t.exports=function(){return u?f?e.Blob:o:a?r:void 0}()}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],2:[function(e,t,n){(function(e){"use strict";function n(){l=!0;for(var e,t,n=s.length;n;){for(t=s,s=[],e=-1;++e<n;)t[e]();n=s.length}l=!1}function r(e){1!==s.push(e)||l||o()}var o,i=e.MutationObserver||e.WebKitMutationObserver;if(i){var u=0,f=new i(n),a=e.document.createTextNode("");f.observe(a,{characterData:!0}),o=function(){a.data=u=++u%2}}else if(e.setImmediate||void 0===e.MessageChannel)o="document"in e&&"onreadystatechange"in e.document.createElement("script")?function(){var t=e.document.createElement("script");t.onreadystatechange=function(){n(),t.onreadystatechange=null,t.parentNode.removeChild(t),t=null},e.document.documentElement.appendChild(t)}:function(){setTimeout(n,0)};else{var c=new e.MessageChannel;c.port1.onmessage=n,o=function(){c.port2.postMessage(0)}}var l,s=[];t.exports=r}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{}],3:[function(e,t,n){"use strict";function r(){}function o(e){if("function"!=typeof e)throw new TypeError("resolver must be a function");this.state=w,this.queue=[],this.outcome=void 0,e!==r&&a(this,e)}function i(e,t,n){this.promise=e,"function"==typeof t&&(this.onFulfilled=t,this.callFulfilled=this.otherCallFulfilled),"function"==typeof n&&(this.onRejected=n,this.callRejected=this.otherCallRejected)}function u(e,t,n){p(function(){var r;try{r=t(n)}catch(t){return v.reject(e,t)}r===e?v.reject(e,new TypeError("Cannot resolve promise with itself")):v.resolve(e,r)})}function f(e){var t=e&&e.then;if(e&&("object"==typeof e||"function"==typeof e)&&"function"==typeof t)return function(){t.apply(e,arguments)}}function a(e,t){function n(t){i||(i=!0,v.reject(e,t))}function r(t){i||(i=!0,v.resolve(e,t))}function o(){t(r,n)}var i=!1,u=c(o);"error"===u.status&&n(u.value)}function c(e,t){var n={};try{n.value=e(t),n.status="success"}catch(e){n.status="error",n.value=e}return n}function l(e){return e instanceof this?e:v.resolve(new this(r),e)}function s(e){var t=new this(r);return v.reject(t,e)}function h(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,o=!1;if(!n)return this.resolve([]);for(var i=new Array(n),u=0,f=-1,a=new this(r);++f<n;)!function(e,r){function f(e){i[r]=e,++u!==n||o||(o=!0,v.resolve(a,i))}t.resolve(e).then(f,function(e){o||(o=!0,v.reject(a,e))})}(e[f],f);return a}function d(e){var t=this;if("[object Array]"!==Object.prototype.toString.call(e))return this.reject(new TypeError("must be an array"));var n=e.length,o=!1;if(!n)return this.resolve([]);for(var i=-1,u=new this(r);++i<n;)!function(e){t.resolve(e).then(function(e){o||(o=!0,v.resolve(u,e))},function(e){o||(o=!0,v.reject(u,e))})}(e[i]);return u}var p=e(2),v={},y=["REJECTED"],b=["FULFILLED"],w=["PENDING"];t.exports=o,o.prototype.catch=function(e){return this.then(null,e)},o.prototype.then=function(e,t){if("function"!=typeof e&&this.state===b||"function"!=typeof t&&this.state===y)return this;var n=new this.constructor(r);if(this.state!==w){u(n,this.state===b?e:t,this.outcome)}else this.queue.push(new i(n,e,t));return n},i.prototype.callFulfilled=function(e){v.resolve(this.promise,e)},i.prototype.otherCallFulfilled=function(e){u(this.promise,this.onFulfilled,e)},i.prototype.callRejected=function(e){v.reject(this.promise,e)},i.prototype.otherCallRejected=function(e){u(this.promise,this.onRejected,e)},v.resolve=function(e,t){var n=c(f,t);if("error"===n.status)return v.reject(e,n.value);var r=n.value;if(r)a(e,r);else{e.state=b,e.outcome=t;for(var o=-1,i=e.queue.length;++o<i;)e.queue[o].callFulfilled(t)}return e},v.reject=function(e,t){e.state=y,e.outcome=t;for(var n=-1,r=e.queue.length;++n<r;)e.queue[n].callRejected(t);return e},o.resolve=l,o.reject=s,o.all=h,o.race=d},{2:2}],4:[function(e,t,n){t.exports="function"==typeof Promise?Promise:e(3)},{3:3}],5:[function(e,t,n){"use strict";function r(e){for(var t=e.length,n=new ArrayBuffer(t),r=new Uint8Array(n),o=-1;++o<t;)r[o]=e.charCodeAt(o);return n}function o(e){for(var t="",n=new Uint8Array(e),r=n.byteLength,o=-1;++o<r;)t+=String.fromCharCode(n[o]);return t}function i(e,t){return new j(function(n,r){var o=new Image;t&&(o.crossOrigin=t),o.onload=function(){n(o)},o.onerror=r,o.src=e})}function u(e){var t=document.createElement("canvas");return t.width=e.width,t.height=e.height,t.getContext("2d").drawImage(e,0,0,e.width,e.height,0,0,e.width,e.height),t}function f(e,t){return t=t||{},"string"==typeof t&&(t={type:t}),new B(e,t)}function a(e){return(window.URL||window.webkitURL).createObjectURL(e)}function c(e){return(window.URL||window.webkitURL).revokeObjectURL(e)}function l(e){return new j(function(t,n){var r=new FileReader,i="function"==typeof r.readAsBinaryString;r.onloadend=function(e){var n=e.target.result||"";if(i)return t(n);t(o(n))},r.onerror=n,i?r.readAsBinaryString(e):r.readAsArrayBuffer(e)})}function s(e,t){return j.resolve().then(function(){var n=[r(atob(e))];return t?f(n,{type:t}):f(n)})}function h(e,t){return j.resolve().then(function(){return s(btoa(e),t)})}function d(e){return l(e).then(function(e){return btoa(e)})}function p(e){return j.resolve().then(function(){var t=e.match(/data:([^;]+)/)[1],n=e.replace(/^[^,]+,/,"");return f([r(atob(n))],{type:t})})}function v(e){return d(e).then(function(t){return"data:"+e.type+";base64,"+t})}function y(e,t,n,r){return t=t||"image/png",i(e,n).then(function(e){return u(e)}).then(function(e){return e.toDataURL(t,r)})}function b(e,t,n){return j.resolve().then(function(){return"function"==typeof e.toBlob?new j(function(r){e.toBlob(r,t,n)}):p(e.toDataURL(t,n))})}function w(e,t,n,r){return t=t||"image/png",i(e,n).then(function(e){return u(e)}).then(function(e){return b(e,t,r)})}function g(e,t){return j.resolve().then(function(){return f([e],t)})}function m(e){return new j(function(t,n){var r=new FileReader;r.onloadend=function(e){var n=e.target.result||new ArrayBuffer(0);t(n)},r.onerror=n,r.readAsArrayBuffer(e)})}var B=e(1),j=e(4);t.exports={createBlob:f,createObjectURL:a,revokeObjectURL:c,imgSrcToBlob:w,imgSrcToDataURL:y,canvasToBlob:b,dataURLToBlob:p,blobToDataURL:v,blobToBase64String:d,base64StringToBlob:s,binaryStringToBlob:h,blobToBinaryString:l,arrayBufferToBlob:g,blobToArrayBuffer:m}},{1:1,4:4}]},{},[5])(5)}); |
@@ -197,2 +197,15 @@ 'use strict'; | ||
/** | ||
* Convert a <code>Blob</code> to a data URL string | ||
* (e.g. <code>'data:image/png;base64,iVBORw0KG...'</code>). | ||
* Returns a Promise. | ||
* @param {Blob} blob | ||
* @returns {Promise} Promise that resolves with the data URL string | ||
*/ | ||
function blobToDataURL(blob) { | ||
return blobToBase64String(blob).then(function (base64String) { | ||
return 'data:' + blob.type + ';base64,' + base64String; | ||
}); | ||
} | ||
/** | ||
* Convert an image's <code>src</code> URL to a data URL by loading the image and painting | ||
@@ -304,2 +317,3 @@ * it to a <code>canvas</code>. Returns a Promise. | ||
dataURLToBlob : dataURLToBlob, | ||
blobToDataURL : blobToDataURL, | ||
blobToBase64String : blobToBase64String, | ||
@@ -306,0 +320,0 @@ base64StringToBlob : base64StringToBlob, |
{ | ||
"name": "blob-util", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Utilities for working with Blob objects in the browser", | ||
@@ -26,12 +26,11 @@ "main": "lib/index.js", | ||
"test-local": "zuul ./test/test.js --local 9000", | ||
"test-phantom": "zuul ./test/test.js --phantom", | ||
"build": "mkdirp dist && npm run browserify && npm run min", | ||
"browserify": "browserify . -p bundle-collapser/plugin -s blobUtil | ./bin/es3ify.js | derequire > dist/blob-util.js", | ||
"min": "uglifyjs dist/blob-util.js -mc > dist/blob-util.min.js", | ||
"jsdoc2md": "jsdoc2md --heading-depth 3 ./lib/index.js > api.md", | ||
"jsdoc": "jsdoc -d doc ./lib/index.js" | ||
"jsdoc2md": "jsdoc2md --heading-depth 3 ./lib/index.js > README.md", | ||
"jsdoc": "jsdoc -d docs ./lib/index.js && mv -f docs/global.html docs/index.html" | ||
}, | ||
"dependencies": { | ||
"blob": "0.0.4", | ||
"native-or-lie": "1.0.0" | ||
"native-or-lie": "1.0.2" | ||
}, | ||
@@ -51,7 +50,6 @@ "devDependencies": { | ||
"mocha": "~1.18", | ||
"phantomjs": "^1.9.7-5", | ||
"phantomjs-polyfill": "0.0.1", | ||
"request": "^2.36.0", | ||
"uglify-js": "^2.4.13", | ||
"zuul": "^3.10.1" | ||
"zuul": "^3.10.1", | ||
"zuul-ngrok": "nolanlawson/zuul-ngrok#patch-1" | ||
}, | ||
@@ -58,0 +56,0 @@ "files": [ |
@@ -6,3 +6,3 @@ blob-util [![Build Status](https://travis-ci.org/nolanlawson/blob-util.svg)](https://travis-ci.org/nolanlawson/blob-util) | ||
It offers a tiny (~3.5KB min+gz) set of cross-browser utilities for translating Blobs to and from different formats: | ||
It offers a small set of cross-browser utilities for translating Blobs to and from different formats: | ||
@@ -59,3 +59,3 @@ * `<img/>` tags | ||
* iOS 6+ | ||
* Android 4.4+ | ||
* Android 4+ | ||
* Any browser with either `Blob` or the older `BlobBuilder`; see [caniuse](http://caniuse.com/#search=blob) for details. | ||
@@ -105,3 +105,3 @@ | ||
<img src="./doc/blob-util.gif"/> | ||
<img src="blob-util.gif"/> | ||
@@ -114,3 +114,3 @@ | ||
###Overview | ||
### Overview | ||
@@ -125,2 +125,3 @@ * [createBlob(parts, options)](#createBlob) | ||
* [dataURLToBlob(dataURL)](#dataURLToBlob) | ||
* [blobToDataURL(blob)](#blobToDataURL) | ||
* [imgSrcToDataURL(src, type, crossOrigin, quality)](#imgSrcToDataURL) | ||
@@ -133,3 +134,3 @@ * [canvasToBlob(canvas, type, quality)](#canvasToBlob) | ||
<a name="createBlob"></a> | ||
###createBlob(parts, options) | ||
### createBlob(parts, options) | ||
Shim for | ||
@@ -154,3 +155,3 @@ [new Blob()](https://developer.mozilla.org/en-US/docs/Web/API/Blob.Blob) | ||
<a name="createObjectURL"></a> | ||
###createObjectURL(blob) | ||
### createObjectURL(blob) | ||
Shim for | ||
@@ -174,3 +175,3 @@ [URL.createObjectURL()](https://developer.mozilla.org/en-US/docs/Web/API/URL.createObjectURL) | ||
<a name="revokeObjectURL"></a> | ||
###revokeObjectURL(url) | ||
### revokeObjectURL(url) | ||
Shim for | ||
@@ -192,3 +193,3 @@ [URL.revokeObjectURL()](https://developer.mozilla.org/en-US/docs/Web/API/URL.revokeObjectURL) | ||
<a name="blobToBinaryString"></a> | ||
###blobToBinaryString(blob) | ||
### blobToBinaryString(blob) | ||
Convert a <code>Blob</code> to a binary string. Returns a Promise. | ||
@@ -213,3 +214,3 @@ | ||
<a name="base64StringToBlob"></a> | ||
###base64StringToBlob(base64, type) | ||
### base64StringToBlob(base64, type) | ||
Convert a base64-encoded string to a <code>Blob</code>. Returns a Promise. | ||
@@ -235,3 +236,3 @@ | ||
<a name="binaryStringToBlob"></a> | ||
###binaryStringToBlob(binary, type) | ||
### binaryStringToBlob(binary, type) | ||
Convert a binary string to a <code>Blob</code>. Returns a Promise. | ||
@@ -257,3 +258,3 @@ | ||
<a name="blobToBase64String"></a> | ||
###blobToBase64String(blob) | ||
### blobToBase64String(blob) | ||
Convert a <code>Blob</code> to a binary string. Returns a Promise. | ||
@@ -279,3 +280,3 @@ | ||
<a name="dataURLToBlob"></a> | ||
###dataURLToBlob(dataURL) | ||
### dataURLToBlob(dataURL) | ||
Convert a data URL string | ||
@@ -300,5 +301,25 @@ (e.g. <code>'data:image/png;base64,iVBORw0KG...'</code>) | ||
``` | ||
<a name="blobToDataURL"></a> | ||
###blobToDataURL(blob) | ||
Convert a <code>Blob</code> to a data URL string | ||
(e.g. <code>'data:image/png;base64,iVBORw0KG...'</code>). | ||
Returns a Promise. | ||
**Params** | ||
- blob `Blob` | ||
**Returns**: `Promise` - Promise that resolves with the data URL string | ||
**Example**: | ||
```js | ||
blobUtil.blobToDataURL(blob).then(function (dataURL) { | ||
// success | ||
}).catch(function (err) { | ||
// error | ||
}); | ||
``` | ||
<a name="imgSrcToDataURL"></a> | ||
###imgSrcToDataURL(src, type, crossOrigin, quality) | ||
### imgSrcToDataURL(src, type, crossOrigin, quality) | ||
Convert an image's <code>src</code> URL to a data URL by loading the image and painting | ||
@@ -333,3 +354,3 @@ it to a <code>canvas</code>. Returns a Promise. | ||
blobUtil.imgSrcToDataURL('http://some-other-site.com/img.jpg', 'image/jpeg', | ||
{crossOrigin: 'Anonymous'}).then(function (dataURL) { | ||
'Anonymous', 1.0).then(function (dataURL) { | ||
// success | ||
@@ -342,3 +363,3 @@ }).catch(function (err) { | ||
<a name="canvasToBlob"></a> | ||
###canvasToBlob(canvas, type, quality) | ||
### canvasToBlob(canvas, type, quality) | ||
Convert a <code>canvas</code> to a <code>Blob</code>. Returns a Promise. | ||
@@ -378,3 +399,3 @@ | ||
<a name="imgSrcToBlob"></a> | ||
###imgSrcToBlob(src, type, crossOrigin, quality) | ||
### imgSrcToBlob(src, type, crossOrigin, quality) | ||
Convert an image's <code>src</code> URL to a <code>Blob</code> by loading the image and painting | ||
@@ -409,3 +430,3 @@ it to a <code>canvas</code>. Returns a Promise. | ||
blobUtil.imgSrcToBlob('http://some-other-site.com/img.jpg', 'image/jpeg', | ||
{crossOrigin: 'Anonymous'}).then(function (blob) { | ||
'Anonymous', 1.0).then(function (blob) { | ||
// success | ||
@@ -418,3 +439,3 @@ }).catch(function (err) { | ||
<a name="arrayBufferToBlob"></a> | ||
###arrayBufferToBlob(buffer, type) | ||
### arrayBufferToBlob(buffer, type) | ||
Convert an <code>ArrayBuffer</code> to a <code>Blob</code>. Returns a Promise. | ||
@@ -440,3 +461,3 @@ | ||
<a name="blobToArrayBuffer"></a> | ||
###blobToArrayBuffer(blob) | ||
### blobToArrayBuffer(blob) | ||
Convert a <code>Blob</code> to an <code>ArrayBuffer</code>. Returns a Promise. | ||
@@ -483,7 +504,5 @@ | ||
* `api.md` to `README.md` | ||
* `index.html` to `doc/global.html` | ||
* `README.md` to its previous version (make sure to keep the code samples, which were manually added) | ||
* `docs` to its previous version | ||
Update: I also manually added a bunch of code samples to `README.md` because jsdoc didn't seem to support that. So... yeah, jsdoc might not be so helpful anymore. | ||
Testing the library | ||
@@ -501,5 +520,1 @@ ---- | ||
npm run test-local | ||
Or to test in PhantomJS: | ||
npm run test-phantom |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
65617
16
1003
499
0
+ Addednative-or-lie@1.0.2(transitive)
- Removednative-or-lie@1.0.0(transitive)
Updatednative-or-lie@1.0.2