Git Product home page Git Product logo

browserify-fs's Introduction

browserify-fs

fs for the browser using level-filesystem, level.js and browserify

npm install browserify-fs

dat

Usage

To use simply require it and use it as you would fs

var fs = require('browserify-fs');

fs.mkdir('/home', function() {
	fs.writeFile('/home/hello-world.txt', 'Hello world!\n', function() {
		fs.readFile('/home/hello-world.txt', 'utf-8', function(err, data) {
			console.log(data);
		});
	});
});

You can also make browserify replace require('fs') with browserify-fs using

browserify -r fs:browserify-fs

Using the replacement you can browserify modules like tar-fs and mkdirp!

Checkout level-filesystem and level.js to see which browsers are supported

License

MIT

browserify-fs's People

Contributors

kevinxh avatar mafintosh avatar mvayngrib avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

browserify-fs's Issues

createWriteStream in the browser??

hi

i try to make a pipe on a creatWritestream with the module ut always have the same error when the download finish

Uncaught TypeError: Invalid non-string/buffer chunk

is it possible to download a file thru/with a pipe with this module?

thanks

RangeError: Maximum call stack size exceeded

I'm attempting to create a bundle like so:

var fs = require('fs');
var browserify = require('browserify');

var b = browserify();
b.require('browserify-fs', { expose: 'fs' });

b.add('./test.js');
b.bundle()
    .pipe(fs.createWriteStream('bundle.js'));

test.js contains the hello-world example from the browserify-fs readme. When I run this to build the bundle I get the max call stack error... any ideas? I'm not sure what I'm doing wrong.

full code here: https://github.com/chevett/browserify-fs-problem

Thanks!

writable stream issue

Hi,

I'm having this problem:

When I create a writable stream with fs.createWriteStream, all write requests are buffered until the stream is closed, even if I specify a low highWaterMark (in fact seems like it's ignored).

I would expect that write calls would eventually cause data to be persisted (if buffer >= highWaterMark), before calling end.

Thanks

browser-fs path

when i run the code in documentation every thing works fine , but where i can find /home directory on my pc ???

Addressing NPM security errors by updating `levelup` to ^4.2.0

Security report

                       === npm audit security report ===                        
                                                                                
SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Regular Expression Denial of Service                         │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ semver                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ semver                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ semver                                                       │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/31                              │
└───────────────┴──────────────────────────────────────────────────────────────┘


SEMVER WARNING: Recommended action is a potentially breaking change
┌───────────────┬──────────────────────────────────────────────────────────────┐
│ Moderate      │ Memory Exposure                                              │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Package       │ bl                                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Dependency of │ bl                                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ Path          │ bl                                                           │
├───────────────┼──────────────────────────────────────────────────────────────┤
│ More info     │ https://npmjs.com/advisories/596                             │
└───────────────┴──────────────────────────────────────────────────────────────┘

Undefined is not a function in readable-stream this.once

Hey! I'm not sure if this bug belongs here, but if I do:

npm i browserify browserify-fs through2 beefy --save

and have a file like test.js:

var fs = require('browserify-fs')
var through = require('through2')
var t = through()

When I run beefy or testling I get in any readable-stream module the error:

Uncaught TypeError: undefined is not a function in _stream_duplex.js at line 71:
this.once('end', onend);

This error doesn't occur If I don't use browserify-fs or if I use and old version of browserify like 3.6.41.

My versions in package.json are:

  "dependencies": {
    "beefy": "^2.1.0",
    "browserify": "^5.10.0",
    "browserify-fs": "^1.0.0",
    "through2": "^0.6.1"
  }

Errors while executing browserify-fs

I'm seeing below error while accessing - https://tonicdev.com/npm/browserify-fs on FF/Chrome on windows 7

ReferenceError: self is not defined
message: "self is not defined"
stack (getter): function()
stack (setter): function()
ReferenceError Prototype

...

While executing it on command line:
D:>node test-bfs.js
D:\node_modules\browserify-fs\node_modules\level-js\node_modules\idb-wrapper\idb
store.js:129
var env = typeof window == 'object' ? window : self;
^

ReferenceError: self is not defined
at new IDBStore (D:\node_modules\browserify-fs\node_modules\level-js\node_mo
dules\idb-wrapper\idbstore.js:129:56)
at Level._open (D:\node_modules\browserify-fs\node_modules\level-js\index.js
:37:14)
at Level.AbstractLevelDOWN.open (D:\node_modules\browserify-fs\node_modules
level-js\node_modules\abstract-leveldown\abstract-leveldown.js:28:17)
at LevelUP.open (D:\node_modules\browserify-fs\node_modules\levelup\lib\leve
lup.js:112:6)
at new LevelUP (D:\node_modules\browserify-fs\node_modules\levelup\lib\level
up.js:82:8)
at LevelUP (D:\node_modules\browserify-fs\node_modules\levelup\lib\levelup.j
s:44:12)
at Object. (D:\node_modules\browserify-fs\index.js:5:10)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
at Module.load (module.js:356:32)

help

hi

sorry to disturb you ans asking you but i think you re the only who can answer me

i try to reproduce this but with browserify

here are my functions in my node-webkit app (used to download and decode files from mega.co):

exemple:

downloadFromMega('https://gfs270n086.userstorage.mega.co.nz/dl/n_q5Mx7CnwjT6QKwF6_WISPiDz3225V4h8QFMpmdgbUjui8PWss5E0r8TubFuRHjR73L0mHn6LJwCz19FjwF2RILwqEjRDupTzF1bRzOhj51XiLJyA','XeXpDxWDCJDOuFCER24vxJowsZFcTL1PgvSU_5E_oKk','11169423')

(can find up to date link here: http://ubukey.fr:3000/getfolder/ydbWqKtrZGaex8uSj5zSkaPdklp8hrOCx5vdi4SmWWOsktGGbWJ6naPcyIW4m7iWnMywfK0%3D)

function downloadFromMega(link,key,size) {
var id = ((Math.random() * 1e6) | 0);
var m = new mega.File({downloadId:id,key:key});
var stream = mega.decrypt(m.key);
var r = request(link);
r.pipe(stream);
var i = 0;
r.on('data', function(d) {
i += d.length;
stream.emit('progress', {bytesLoaded: i, bytesTotal: size })
});
r.on('end', function(d) {
console.log("download end");
});
return stream
}

var startTime = (new Date()).getTime();
var target = download_dir+'/'+title+'.'+startTime;
var file = fs.createWriteStream(target);
var contentLength = length;
current_download= downloadFromMega(link,key,length);
current_download.pipe(file);
.....

is it possible to recreate it from browserify, i have some working scripts but chrome or firefox crash once the maximum blob size is reached ... i m lost between blobs, filesystem and all storage things... :(

sorry again and thanks

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.