Skip to content

Commit

Permalink
update readme
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Mar 30, 2022
1 parent db974b8 commit f2b7a88
Showing 1 changed file with 25 additions and 2 deletions.
27 changes: 25 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,34 @@
node like `fs` API for the browser that uses indexedDB/ fs access browser APIs for persistence.

## Installation
The library can be either installed using npm or using the CDN link (See usage in browser below ).

### Getting the code locally
Install the library can be downloaded locally with the following command:

```bash
npm install @phcode/fs
```

Once installed, the `virtualfs.js` lib will be present in the following location
```bash
<project_root>/node_modules/@phcode/fs/dist/virtualfs.js
```
### Usage in browser
Put the below script tag in your html file. A Global `fs` object
will be created with the necessary fs APIs.
* The fs apis have compatibility with nodejs like fs APIs.
See filer docs for API docs: https://filer.js.org/

```js
<script src="path/to/dist/virtualfs.js"/>
// using CDN link in your html file
<script src="https://unpkg.com/@phcode/fs@latest/dist/virtualfs.js"/>

// OR to get a particular version, change latest to the version you need:
<script src="https://unpkg.com/@phcode/[email protected]/dist/virtualfs.js"/>

// OR if you did npm install
<script src="<project_root>/node_modules/@phcode/fs/dist/virtualfs.js"/>
```

### Usage in web-worker in browser
Expand All @@ -21,7 +41,10 @@ started supporting the API yet.
2. Use fs.mountNativeFolder to mount a local directory.
3. After mounting, access the files using the mountPath returned
```js
importScripts('path/to/dist/virtualfs.js');
importScripts('<project_root>/node_modules/@phcode/fs/dist/virtualfs.js');
// OR from CDN directly as
importScripts('https://unpkg.com/@phcode/fs@latest/dist/virtualfs.js');

fs.mountNativeFolder((err, mountPathArray)=>{
console.log(err, mountPathArray);
});
Expand Down

0 comments on commit f2b7a88

Please sign in to comment.