From 9f3a4f926eb2a09a046f0f7db65d47b9824b1c0e Mon Sep 17 00:00:00 2001 From: Nolan Lawson Date: Sat, 16 Jan 2016 15:01:47 -0500 Subject: [PATCH] 1.2.0 --- README.md | 2 +- bower.json | 2 +- dist/blob-util.js | 478 +++++++++++++++++++++++++----------------- dist/blob-util.min.js | 2 +- package.json | 2 +- 5 files changed, 292 insertions(+), 194 deletions(-) diff --git a/README.md b/README.md index eb821f0..450b968 100644 --- a/README.md +++ b/README.md @@ -5,7 +5,7 @@ blob-util `blob-util` is a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob?redirectlocale=en-US&redirectslug=DOM%2FBlob) library for busy people. -It offers a tiny (~3KB min+gz) set of cross-browser utilities for translating Blobs to and from different formats: +It offers a tiny (~3.5KB min+gz) set of cross-browser utilities for translating Blobs to and from different formats: * `` tags * base 64 strings diff --git a/bower.json b/bower.json index 27aa001..471d7ad 100644 --- a/bower.json +++ b/bower.json @@ -1,6 +1,6 @@ { "name": "blob-util", - "version": "1.1.2", + "version": "1.2.0", "description": "Utilities for working with Blob objects in the browser", "homepage": "https://github.com/nolanlawson/blob-util", "authors": [ diff --git a/dist/blob-util.js b/dist/blob-util.js index 530ea69..8c05c99 100644 --- a/dist/blob-util.js +++ b/dist/blob-util.js @@ -99,28 +99,194 @@ module.exports = (function() { }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) },{}],2:[function(_dereq_,module,exports){ - -},{}],3:[function(_dereq_,module,exports){ -(function (global){ -if (typeof global.Promise === 'function') { - module.exports = global.Promise; -} else { - module.exports = _dereq_(7); +'use strict'; +var types = [ + _dereq_(5), + _dereq_(4), + _dereq_(3), + _dereq_(6), + _dereq_(7) +]; +var draining; +var currentQueue; +var queueIndex = -1; +var queue = []; +var scheduled = false; +function cleanUpNextTick() { + draining = false; + if (currentQueue && currentQueue.length) { + queue = currentQueue.concat(queue); + } else { + queueIndex = -1; + } + if (queue.length) { + nextTick(); + } } + +//named nextTick for less confusing stack traces +function nextTick() { + scheduled = false; + draining = true; + var len = queue.length; + var timeout = setTimeout(cleanUpNextTick); + while (len) { + currentQueue = queue; + queue = []; + while (++queueIndex < len) { + currentQueue[queueIndex].run(); + } + queueIndex = -1; + len = queue.length; + } + queueIndex = -1; + draining = false; + clearTimeout(timeout); +} +var scheduleDrain; +var i = -1; +var len = types.length; +while (++i < len) { + if (types[i] && types[i].test && types[i].test()) { + scheduleDrain = types[i].install(nextTick); + break; + } +} +// v8 likes predictible objects +function Item(fun, array) { + this.fun = fun; + this.array = array; +} +Item.prototype.run = function () { + this.fun.apply(null, this.array); +}; +module.exports = immediate; +function immediate(task) { + var args = new Array(arguments.length - 1); + if (arguments.length > 1) { + for (var i = 1; i < arguments.length; i++) { + args[i - 1] = arguments[i]; + } + } + queue.push(new Item(task, args)); + if (!scheduled && !draining) { + scheduled = true; + scheduleDrain(); + } +} + +},{"3":3,"4":4,"5":5,"6":6,"7":7}],3:[function(_dereq_,module,exports){ +(function (global){ +'use strict'; + +exports.test = function () { + if (global.setImmediate) { + // we can only get here in IE10 + // which doesn't handel postMessage well + return false; + } + return typeof global.MessageChannel !== 'undefined'; +}; + +exports.install = function (func) { + var channel = new global.MessageChannel(); + channel.port1.onmessage = func; + return function () { + channel.port2.postMessage(0); + }; +}; }).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) -},{"7":7}],4:[function(_dereq_,module,exports){ +},{}],4:[function(_dereq_,module,exports){ +(function (global){ +'use strict'; +//based off rsvp https://github.com/tildeio/rsvp.js +//license https://github.com/tildeio/rsvp.js/blob/master/LICENSE +//https://github.com/tildeio/rsvp.js/blob/master/lib/rsvp/asap.js + +var Mutation = global.MutationObserver || global.WebKitMutationObserver; + +exports.test = function () { + return Mutation; +}; + +exports.install = function (handle) { + var called = 0; + var observer = new Mutation(handle); + var element = global.document.createTextNode(''); + observer.observe(element, { + characterData: true + }); + return function () { + element.data = (called = ++called % 2); + }; +}; +}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {}) +},{}],5:[function(_dereq_,module,exports){ +(function (process){ +'use strict'; +exports.test = function () { + // Don't get fooled by e.g. browserify environments. + return (typeof process !== 'undefined') && !process.browser; +}; + +exports.install = function (func) { + return function () { + process.nextTick(func); + }; +}; + +}).call(this,_dereq_(21)) +},{"21":21}],6:[function(_dereq_,module,exports){ +(function (global){ +'use strict'; + +exports.test = function () { + return 'document' in global && 'onreadystatechange' in global.document.createElement('script'); +}; + +exports.install = function (handle) { + return function () { + + // Create a