A cross-browser Blob
that falls back to BlobBuilder
when appropriate.
If neither is available, it exports undefined
.
$ npm install blob
var Blob = require('blob');
var b = new Blob(['hi', 'constructing', 'a', 'blob']);
MIT
A cross-browser Blob that falls back to BlobBuilder when appropriate
License: MIT License
Kind of surprised there is a 0.0.5 version since it isn't a release in this repo. However 0.0.5 in npm include several development environment files. Shown in bold below.
$ tar -tzvf blob-0.0.5.tgz
-rw-rw-rw- 0/0 533 1985-10-26 03:15 package/package.json
-rw-rw-rw- 0/0 276 1985-10-26 03:15 package/.zuul.yml
-rw-rw-rw- 0/0 274 1985-10-26 03:15 package/component.json
-rw-rw-rw- 0/0 2531 1985-10-26 03:15 package/index.js
-rw-rw-rw- 0/0 1083 1985-10-26 03:15 package/LICENSE
-rw-rw-rw- 0/0 218 1985-10-26 03:15 package/Makefile
-rw-rw-rw- 0/0 326 1985-10-26 03:15 package/README.md
-rw-rw-rw- 0/0 469 1985-10-26 03:15 package/.idea/blob.iml
-rw-rw-rw- 0/0 128 1985-10-26 03:15 package/.idea/inspectionProfiles/profiles_settings.xml
-rw-rw-rw- 0/0 4796 1985-10-26 03:15 package/.idea/markdown-navigator.xml
-rw-rw-rw- 0/0 106 1985-10-26 03:15 package/.idea/markdown-navigator/profiles_settings.xml
-rw-rw-rw- 0/0 267 1985-10-26 03:15 package/.idea/modules.xml
-rw-rw-rw- 0/0 185 1985-10-26 03:15 package/.idea/vcs.xml
-rw-rw-rw- 0/0 16028 1985-10-26 03:15 package/.idea/workspace.xml
-rw-rw-rw- 0/0 3391 1985-10-26 03:15 package/test/index.js
Use some nice module for blob support in node.
Please consider adding this fallback version if blob is unsupported
function FakeBlobBuilder() {
function toUTF8Array(str) {
var utf8 = [];
for (var i=0; i < str.length; i++) {
var charcode = str.charCodeAt(i);
if (charcode < 0x80) utf8.push(charcode);
else if (charcode < 0x800) {
utf8.push(0xc0 | (charcode >> 6),
0x80 | (charcode & 0x3f));
}
else if (charcode < 0xd800 || charcode >= 0xe000) {
utf8.push(0xe0 | (charcode >> 12),
0x80 | ((charcode>>6) & 0x3f),
0x80 | (charcode & 0x3f));
}
// surrogate pair
else {
i++;
// UTF-16 encodes 0x10000-0x10FFFF by
// subtracting 0x10000 and splitting the
// 20 bits of 0x0-0xFFFFF into two halves
charcode = 0x10000 + (((charcode & 0x3ff)<<10)
| (str.charCodeAt(i) & 0x3ff));
utf8.push(0xf0 | (charcode >>18),
0x80 | ((charcode>>12) & 0x3f),
0x80 | ((charcode>>6) & 0x3f),
0x80 | (charcode & 0x3f));
}
}
return utf8;
}
function Blob(chunks, opts) {
for (var i = 0, len = chunks.length; i < len; i++) {
var chunk = chunks[i]
chunks[i] =
chunk instanceof Blob ? chunk._buffer :
typeof chunk === 'string' ? toUTF8Array(chunk) : chunk
}
this._buffer = [].concat.apply([], chunks)
this.size = this._buffer.length
this.type = opts ? opts.type || '' : ''
}
Blob.prototype.slice = function(start, end, type) {
var slice = this._buffer.slice(start || 0, end || this._buffer.length)
return new Blob([slice], type || '')
}
Blob.prototype.toString = function() {
return '[object Blob]'
}
if (typeof Symbol !== 'undefined') {
Blob.prototype[Symbol.toStringTag] = 'Blob'
}
return Blob
}
module.exports = (function() {
if (blobSupported) {
return blobSupportsArrayBufferView ? global.Blob : BlobConstructor;
} else if (blobBuilderSupported) {
return BlobBuilderConstructor;
} else {
return FakeBlobBuilder();
}
})();
how to covert base64 to blob
there's a component.json
, but this module doesn't support component currently. any way we could do something like:
var global = get_global_scope()
rather than assuming it's defined here?
Hi, I recently uploaded this Node.js module as a Debian package and we noticed that the license file is outdated. Can you please provide more details on the author(s) and the copyright holder(s)? This may seem a mundane task, but it makes the world better in protecting your work and the freedoms of the users. Many thanks, Paolo
This repo is practically abandoned. The latest versions published to NPM are at https://github.com/amitport/blob.
(I don't have github repo permissions but I do have NPM package permissions)
I'm kind of confused since this project has only 10 stars, while at the same time there have been "77.762 downloads in the last day" and the last update was "rase- published 2 years ago".
So it looks like this project has been picked up again after some time and a few things were update. Would be sick to call it 1.0.0 and publish to npm so people know they can use it. Thanks!
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.