aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/blob
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/blob')
-rw-r--r--node_modules/blob/.npmignore2
-rw-r--r--node_modules/blob/.zuul.yml14
-rw-r--r--node_modules/blob/Makefile14
-rw-r--r--node_modules/blob/README.md14
-rw-r--r--node_modules/blob/index.js96
-rw-r--r--node_modules/blob/package.json77
-rw-r--r--node_modules/blob/test/index.js94
7 files changed, 311 insertions, 0 deletions
diff --git a/node_modules/blob/.npmignore b/node_modules/blob/.npmignore
new file mode 100644
index 0000000..548a368
--- /dev/null
+++ b/node_modules/blob/.npmignore
@@ -0,0 +1,2 @@
+node_modules
+blob.js
diff --git a/node_modules/blob/.zuul.yml b/node_modules/blob/.zuul.yml
new file mode 100644
index 0000000..380c395
--- /dev/null
+++ b/node_modules/blob/.zuul.yml
@@ -0,0 +1,14 @@
+ui: mocha-bdd
+browsers:
+ - name: chrome
+ version: 8..latest
+ - name: firefox
+ version: 7..latest
+ - name: safari
+ version: 6..latest
+ - name: opera
+ version: 12.1..latest
+ - name: ie
+ version: 10..latest
+ - name: android
+ version: latest
diff --git a/node_modules/blob/Makefile b/node_modules/blob/Makefile
new file mode 100644
index 0000000..7d9601a
--- /dev/null
+++ b/node_modules/blob/Makefile
@@ -0,0 +1,14 @@
+REPORTER = dot
+
+build: blob.js
+
+blob.js:
+ @./node_modules/.bin/browserify --standalone blob index.js > blob.js
+
+test:
+ @./node_modules/.bin/zuul -- test/index.js
+
+clean:
+ rm blob.js
+
+.PHONY: test blob.js
diff --git a/node_modules/blob/README.md b/node_modules/blob/README.md
new file mode 100644
index 0000000..6915955
--- /dev/null
+++ b/node_modules/blob/README.md
@@ -0,0 +1,14 @@
+Blob
+====
+
+A module that exports a constructor that uses window.Blob when available, and a BlobBuilder with any vendor prefix in other cases. If neither is available, it exports undefined.
+
+Usage:
+
+```javascript
+var Blob = require('blob');
+var b = new Blob(['hi', 'constructing', 'a', 'blob']);
+```
+
+## Licence
+MIT
diff --git a/node_modules/blob/index.js b/node_modules/blob/index.js
new file mode 100644
index 0000000..cad3f84
--- /dev/null
+++ b/node_modules/blob/index.js
@@ -0,0 +1,96 @@
+/**
+ * Create a blob builder even when vendor prefixes exist
+ */
+
+var BlobBuilder = global.BlobBuilder
+ || global.WebKitBlobBuilder
+ || global.MSBlobBuilder
+ || global.MozBlobBuilder;
+
+/**
+ * Check if Blob constructor is supported
+ */
+
+var blobSupported = (function() {
+ try {
+ var a = new Blob(['hi']);
+ return a.size === 2;
+ } catch(e) {
+ return false;
+ }
+})();
+
+/**
+ * Check if Blob constructor supports ArrayBufferViews
+ * Fails in Safari 6, so we need to map to ArrayBuffers there.
+ */
+
+var blobSupportsArrayBufferView = blobSupported && (function() {
+ try {
+ var b = new Blob([new Uint8Array([1,2])]);
+ return b.size === 2;
+ } catch(e) {
+ return false;
+ }
+})();
+
+/**
+ * Check if BlobBuilder is supported
+ */
+
+var blobBuilderSupported = BlobBuilder
+ && BlobBuilder.prototype.append
+ && BlobBuilder.prototype.getBlob;
+
+/**
+ * Helper function that maps ArrayBufferViews to ArrayBuffers
+ * Used by BlobBuilder constructor and old browsers that didn't
+ * support it in the Blob constructor.
+ */
+
+function mapArrayBufferViews(ary) {
+ for (var i = 0; i < ary.length; i++) {
+ var chunk = ary[i];
+ if (chunk.buffer instanceof ArrayBuffer) {
+ var buf = chunk.buffer;
+
+ // if this is a subarray, make a copy so we only
+ // include the subarray region from the underlying buffer
+ if (chunk.byteLength !== buf.byteLength) {
+ var copy = new Uint8Array(chunk.byteLength);
+ copy.set(new Uint8Array(buf, chunk.byteOffset, chunk.byteLength));
+ buf = copy.buffer;
+ }
+
+ ary[i] = buf;
+ }
+ }
+}
+
+function BlobBuilderConstructor(ary, options) {
+ options = options || {};
+
+ var bb = new BlobBuilder();
+ mapArrayBufferViews(ary);
+
+ for (var i = 0; i < ary.length; i++) {
+ bb.append(ary[i]);
+ }
+
+ return (options.type) ? bb.getBlob(options.type) : bb.getBlob();
+};
+
+function BlobConstructor(ary, options) {
+ mapArrayBufferViews(ary);
+ return new Blob(ary, options || {});
+};
+
+module.exports = (function() {
+ if (blobSupported) {
+ return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
+ } else if (blobBuilderSupported) {
+ return BlobBuilderConstructor;
+ } else {
+ return undefined;
+ }
+})();
diff --git a/node_modules/blob/package.json b/node_modules/blob/package.json
new file mode 100644
index 0000000..b5611b4
--- /dev/null
+++ b/node_modules/blob/package.json
@@ -0,0 +1,77 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "blob@0.0.4",
+ "scope": null,
+ "escapedName": "blob",
+ "name": "blob",
+ "rawSpec": "0.0.4",
+ "spec": "0.0.4",
+ "type": "version"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io-parser"
+ ]
+ ],
+ "_from": "blob@0.0.4",
+ "_id": "blob@0.0.4",
+ "_inCache": true,
+ "_location": "/blob",
+ "_npmUser": {
+ "name": "rase-",
+ "email": "tonykovanen@hotmail.com"
+ },
+ "_npmVersion": "1.4.6",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "blob@0.0.4",
+ "scope": null,
+ "escapedName": "blob",
+ "name": "blob",
+ "rawSpec": "0.0.4",
+ "spec": "0.0.4",
+ "type": "version"
+ },
+ "_requiredBy": [
+ "/engine.io-parser"
+ ],
+ "_resolved": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz",
+ "_shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921",
+ "_shrinkwrap": null,
+ "_spec": "blob@0.0.4",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/engine.io-parser",
+ "bugs": {
+ "url": "https://github.com/rase-/blob/issues"
+ },
+ "dependencies": {},
+ "description": "Abstracts out Blob and uses BlobBulder in cases where it is supported with any vendor prefix.",
+ "devDependencies": {
+ "browserify": "3.30.1",
+ "expect.js": "0.2.0",
+ "mocha": "1.17.1",
+ "zuul": "1.5.4"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "bcf13052ca54463f30f9fc7e95b9a47630a94921",
+ "tarball": "https://registry.npmjs.org/blob/-/blob-0.0.4.tgz"
+ },
+ "homepage": "https://github.com/rase-/blob",
+ "maintainers": [
+ {
+ "name": "rase-",
+ "email": "tonykovanen@hotmail.com"
+ }
+ ],
+ "name": "blob",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+ssh://git@github.com/rase-/blob.git"
+ },
+ "scripts": {
+ "test": "make test"
+ },
+ "version": "0.0.4"
+}
diff --git a/node_modules/blob/test/index.js b/node_modules/blob/test/index.js
new file mode 100644
index 0000000..df9303f
--- /dev/null
+++ b/node_modules/blob/test/index.js
@@ -0,0 +1,94 @@
+var Blob = require('../');
+var expect = require('expect.js');
+
+describe('blob', function() {
+ if (!Blob) {
+ it('should not have a blob or a blob builder in the global namespace, or blob should not be a constructor function if the module exports false', function() {
+ try {
+ var ab = (new Uint8Array(5)).buffer;
+ global.Blob([ab]);
+ expect().fail('Blob shouldn\'t be constructable');
+ } catch (e) {}
+
+ var BlobBuilder = global.BlobBuilder
+ || global.WebKitBlobBuilder
+ || global.MSBlobBuilder
+ || global.MozBlobBuilder;
+ expect(BlobBuilder).to.be(undefined);
+ });
+ } else {
+ it('should encode a proper sized blob when given a string argument', function() {
+ var b = new Blob(['hi']);
+ expect(b.size).to.be(2);
+ });
+
+ it('should encode a blob with proper size when given two strings as arguments', function() {
+ var b = new Blob(['hi', 'hello']);
+ expect(b.size).to.be(7);
+ });
+
+ it('should encode arraybuffers with right content', function(done) {
+ var ary = new Uint8Array(5);
+ for (var i = 0; i < 5; i++) ary[i] = i;
+ var b = new Blob([ary.buffer]);
+ var fr = new FileReader();
+ fr.onload = function() {
+ var newAry = new Uint8Array(this.result);
+ for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
+ done();
+ };
+ fr.readAsArrayBuffer(b);
+ });
+
+ it('should encode typed arrays with right content', function(done) {
+ var ary = new Uint8Array(5);
+ for (var i = 0; i < 5; i++) ary[i] = i;
+ var b = new Blob([ary]);
+ var fr = new FileReader();
+ fr.onload = function() {
+ var newAry = new Uint8Array(this.result);
+ for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
+ done();
+ };
+ fr.readAsArrayBuffer(b);
+ });
+
+ it('should encode sliced typed arrays with right content', function(done) {
+ var ary = new Uint8Array(5);
+ for (var i = 0; i < 5; i++) ary[i] = i;
+ var b = new Blob([ary.subarray(2)]);
+ var fr = new FileReader();
+ fr.onload = function() {
+ var newAry = new Uint8Array(this.result);
+ for (var i = 0; i < 3; i++) expect(newAry[i]).to.be(i + 2);
+ done();
+ };
+ fr.readAsArrayBuffer(b);
+ });
+
+ it('should encode with blobs', function(done) {
+ var ary = new Uint8Array(5);
+ for (var i = 0; i < 5; i++) ary[i] = i;
+ var b = new Blob([new Blob([ary.buffer])]);
+ var fr = new FileReader();
+ fr.onload = function() {
+ var newAry = new Uint8Array(this.result);
+ for (var i = 0; i < 5; i++) expect(newAry[i]).to.be(i);
+ done();
+ };
+ fr.readAsArrayBuffer(b);
+ });
+
+ it('should enode mixed contents to right size', function() {
+ var ary = new Uint8Array(5);
+ for (var i = 0; i < 5; i++) ary[i] = i;
+ var b = new Blob([ary.buffer, 'hello']);
+ expect(b.size).to.be(10);
+ });
+
+ it('should accept mime type', function() {
+ var b = new Blob(['hi', 'hello'], { type: 'text/html' });
+ expect(b.type).to.be('text/html');
+ });
+ }
+});