├── .gitignore ├── LICENSE ├── README.md ├── example.js ├── index.js └── package.json /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules 2 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2019 Tradle 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # react-native-level-fs 2 | 3 | [fs](http://nodejs.org/api/fs.html) in react-native using [level-filesystem](https://github.com/mafintosh/level-filesystem) and [asyncstorage-down](https://github.com/tradle/asyncstorage-down) 4 | 5 | npm install react-native-level-fs 6 | 7 | ## Usage 8 | 9 | To use simply require it and use it as you would fs 10 | 11 | (package.json) 12 | 13 | ```json 14 | { 15 | ... 16 | "browser": { 17 | "fs": "react-native-level-fs" 18 | } 19 | ... 20 | } 21 | ``` 22 | 23 | ``` js 24 | var fs = require('fs'); 25 | 26 | fs.mkdir('/home', function() { 27 | fs.writeFile('/home/hello-world.txt', 'Hello world!\n', function() { 28 | fs.readFile('/home/hello-world.txt', 'utf-8', function(err, data) { 29 | console.log(data); 30 | }); 31 | }); 32 | }); 33 | ``` 34 | 35 | ## License 36 | 37 | MIT 38 | -------------------------------------------------------------------------------- /example.js: -------------------------------------------------------------------------------- 1 | 2 | // to write require('fs'), add "browser" mapping in package.json 3 | var fs = require('react-native-level-fs'); 4 | 5 | fs.mkdir('/home', function() { 6 | fs.writeFile('/home/hello-world.txt', 'Hello world!\n', function() { 7 | fs.readFile('/home/hello-world.txt', 'utf-8', function(err, data) { 8 | console.log(data); 9 | }); 10 | }); 11 | }); 12 | -------------------------------------------------------------------------------- /index.js: -------------------------------------------------------------------------------- 1 | var leveldown = require('asyncstorage-down'); 2 | var levelup = require('levelup'); 3 | var fs = require('level-filesystem'); 4 | 5 | var db = levelup('level-fs', { db: leveldown }); 6 | module.exports = fs(db); -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "react-native-level-fs", 3 | "version": "3.0.1", 4 | "description": "fs for react-native using level-filesystem and asyncstorage-down", 5 | "repository": { 6 | "type": "git", 7 | "url": "git+https://github.com/tradle/react-native-level-fs.git" 8 | }, 9 | "keywords": [ 10 | "react-component", 11 | "react-native", 12 | "iOS", 13 | "fs", 14 | "level", 15 | "filesystem" 16 | ], 17 | "dependencies": { 18 | "level-filesystem": "^1.0.1", 19 | "levelup": "^0.18.2" 20 | }, 21 | "peerDependencies": { 22 | "asyncstorage-down": ">=3.0.0 <5.0.0" 23 | } 24 | } 25 | --------------------------------------------------------------------------------