├── .gitignore ├── README.md ├── example ├── build.js ├── run.sh └── test.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | *.sw* 3 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | 2 | # level-fs-browser 3 | 4 | [level-fs](https://github.com/juliangruber/level-fs) as drop-in 5 | [fs](nodejs.org/api/fs.html) replacement for the browser, to be used 6 | with [browserify](https://github.com/substack/node-browserify). 7 | 8 | ## Usage 9 | 10 | With this file, stored as `test.js`: 11 | 12 | ```js 13 | var fs = require('fs'); 14 | 15 | fs.readFile('foo', function () { 16 | console.log(arguments); 17 | }); 18 | ``` 19 | 20 | you can bundle it up to use `level-fs` instead of `fs`, either using 21 | browserify's api: 22 | 23 | ```js 24 | var browserify = require('browserify'); 25 | var fs = require('fs'); 26 | 27 | var b = browserify(); 28 | b.require('level-fs-browser', { expose: 'fs' }); 29 | b.add(__dirname + '/test.js'); 30 | b.bundle().pipe(process.stdout); 31 | ``` 32 | 33 | or browserify's cli: 34 | 35 | ```bash 36 | $ browserify -r level-fs-browser:fs test.js 37 | ``` 38 | 39 | **level-fs-browser** will (create and) use a database called `level-fs`. 40 | 41 | ## Installation 42 | 43 | With [npm](http://npmjs.org) do 44 | 45 | ```bash 46 | $ npm install level-fs-browser 47 | ``` 48 | 49 | ## License 50 | 51 | Copyright (c) 2013 Julian Gruber <julian@juliangruber.com> 52 | 53 | Permission is hereby granted, free of charge, to any person obtaining a copy 54 | of this software and associated documentation files (the "Software"), to deal 55 | in the Software without restriction, including without limitation the rights 56 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 57 | copies of the Software, and to permit persons to whom the Software is 58 | furnished to do so, subject to the following conditions: 59 | 60 | The above copyright notice and this permission notice shall be included in 61 | all copies or substantial portions of the Software. 62 | 63 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 64 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 65 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 66 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 67 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 68 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 69 | THE SOFTWARE. 70 | -------------------------------------------------------------------------------- /example/build.js: -------------------------------------------------------------------------------- 1 | var browserify = require('browserify'); 2 | var fs = require('fs'); 3 | 4 | var b = browserify(); 5 | b.require(__dirname + '/../index.js', { expose: 'fs' }); 6 | b.add(__dirname + '/test.js'); 7 | b.bundle().pipe(process.stdout); 8 | -------------------------------------------------------------------------------- /example/run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | node build.js | browser-run --port 3001 4 | -------------------------------------------------------------------------------- /example/test.js: -------------------------------------------------------------------------------- 1 | var fs = require('fs'); 2 | 3 | fs.readFile('foo', function () { 4 | console.log(arguments); 5 | }); 6 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var leveljs = require('level-js'); 2 | var levelup = require('levelup'); 3 | var fs = require('level-fs'); 4 | 5 | var db = levelup('level-fs', { db: leveljs }); 6 | module.exports = fs(db); 7 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "level-fs-browser", 3 | "description": "level-fs as drop-in fs replacement for the browser", 4 | "version": "1.0.0", 5 | "repository": { 6 | "type": "git", 7 | "url": "git://github.com/juliangruber/level-fs-browser.git" 8 | }, 9 | "homepage": "https://github.com/juliangruber/level-fs-browser", 10 | "main": "index.js", 11 | "scripts": { 12 | "test": "tap test/*.js" 13 | }, 14 | "dependencies": { 15 | "level-fs": "~0.11.2", 16 | "level-js": "~2.2.4", 17 | "levelup": "~1.3.3" 18 | }, 19 | "devDependencies": { 20 | "tap": "*", 21 | "browserify": "~13.1.1" 22 | }, 23 | "keywords": [ 24 | "level-fs", 25 | "browser", 26 | "leveldb", 27 | "levelup", 28 | "fs" 29 | ], 30 | "author": { 31 | "name": "Julian Gruber", 32 | "email": "mail@juliangruber.com", 33 | "url": "http://juliangruber.com" 34 | }, 35 | "license": "MIT" 36 | } 37 | --------------------------------------------------------------------------------