Comparing version 1.0.1 to 1.0.2
@@ -14,3 +14,3 @@ { | ||
], | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"author": "Alan K <ack@modeswitch.org> (http://blog.modeswitch.org)", | ||
@@ -17,0 +17,0 @@ "homepage": "http://filerjs.github.io/filer", |
[![NPM](https://nodei.co/npm/filer.png?downloads=true&stars=true)](https://nodei.co/npm/filer/) | ||
[![Build Status](https://secure.travis-ci.org/filerjs/filer.png?branch=develop)](http://travis-ci.org/filerjs/filer) | ||
[![Build Status](https://secure.travis-ci.org/filerjs/filer.png?branch=develop)](http://travis-ci.org/filerjs/filer) [![codecov](https://codecov.io/gh/filerjs/filer/branch/master/graph/badge.svg)](https://codecov.io/gh/filerjs/filer) | ||
[![codecov](https://codecov.io/gh/filerjs/filer/branch/master/graph/badge.svg)](https://codecov.io/gh/filerjs/filer) | ||
### Filer | ||
Filer is a POSIX-like file system interface for node.js and browser-based JavaScript. | ||
Filer is a POSIX-like file system for browsers. | ||
@@ -35,5 +33,4 @@ ### Compatibility | ||
1. npm - `npm install filer` | ||
2. bower - `bower install filer` | ||
3. download pre-built versions: [filer.js](https://raw.github.com/filerjs/filer/develop/dist/filer.js), [filer.min.js](https://raw.github.com/filerjs/filer/develop/dist/filer.min.js) | ||
1. Via npm: `npm install filer` | ||
3. Via unpkg: `<script src="https://unpkg.com/filer"></script>` or specify a version directly, for example: [https://unpkg.com/filer@1.0.1/dist/filer.min.js](https://unpkg.com/filer@1.0.1/dist/filer.min.js) | ||
@@ -45,3 +42,3 @@ ### Loading and Usage | ||
```javascript | ||
// Option 1: Filer loaded via require() in node/browserify | ||
// Option 1: Filer loaded via require() | ||
var Filer = require('filer'); | ||
@@ -105,3 +102,3 @@ | ||
Filer also supports node's Path module. See the [Filer.Path](#FilerPath) section below. | ||
Filer also includes node's `path` and `Buffer` modules. See the [Filer.Path](#FilerPath) and [Filer.Buffer](#FilerBuffer) sections below. | ||
@@ -119,5 +116,5 @@ In addition, common shell operations (e.g., rm, touch, cat, etc.) are supported via the | ||
#### Support for Promises | ||
The Promise based API mimics the way Node [implements](https://nodejs.org/api/fs.html#fs_fs_promises_api) them. Both `Shell` and `FileSystem` now have a `promises` object attached alongside the regular callback style methods. Method names are identical to their callback counterparts with the difference that instead of receiving a final argument as a callback, they return a Promise that is resolved or rejected based on the success of method execution. | ||
> Please note that `exists` method will always throw, since it was [deprecated](https://nodejs.org/api/fs.html#fs_fs_exists_path_callback) by Node. | ||
The Promise based API mimics the way node [implements](https://nodejs.org/api/fs.html#fs_fs_promises_api) them. Both `Shell` and `FileSystem` now have a `promises` property, which gives access to Promise based versions of methods in addition to the regular callback style methods. Method names are identical to their callback counterparts with the difference that instead of receiving a final argument as a callback, they return a Promise that is resolved or rejected based on the success of method execution. | ||
See example below: | ||
@@ -127,9 +124,8 @@ | ||
const fs = new Filer.FileSystem().promises; | ||
fs.open('/myfile', 'w+') | ||
.then(fd => fs.close(fd)) | ||
fs.writeFile('/myfile', 'some data') | ||
.then(() => fs.stat('/myfile')) | ||
.then(stats => { console.log(`stats: ${JSON.stringify(stats)}`); }) | ||
.catch(err => { console.error(err); }) | ||
.catch(err => { console.error(err); }); | ||
``` | ||
> The callback style usage could be found [here](#overviewExample). | ||
#### Filer.FileSystem(options, callback) constructor | ||
@@ -247,5 +243,8 @@ | ||
The node.js [path module](http://nodejs.org/api/path.html) is available via the `Filer.Path` object. It is | ||
identical to the node.js version with the following differences: | ||
* No notion of a current working directory in `resolve` (the root dir is used instead) | ||
identical to the node.js (see [https://github.com/browserify/path-browserify](https://github.com/browserify/path-browserify)) version with the following differences: | ||
* The CWD always defaults to `/` | ||
* No support for Windows style paths | ||
* Additional utility methods (see below) | ||
```javascript | ||
@@ -267,3 +266,3 @@ var path = Filer.Path; | ||
For more info see the docs in the [path module](http://nodejs.org/api/path.html) for a particular method: | ||
* `path.normalize(p)` | ||
* `path.normalize(p)` - NOTE: Filer.Path.normalize does *not* add a trailing slash | ||
* `path.join([path1], [path2], [...])` | ||
@@ -273,3 +272,3 @@ * `path.resolve([from ...], to)` | ||
* `path.dirname(p)` | ||
* `path.basename(p, [ext])` | ||
* `path.basename(p, [ext])` - NOTE: Filer.Path.basename will return `'/'` vs. `''` | ||
* `path.extname(p)` | ||
@@ -279,2 +278,8 @@ * `path.sep` | ||
Filer.Path also includes the following extra methods: | ||
* `isNull(p)` returns `true` or `false` if the path contains a null character (`'\u0000'`) | ||
* `addTrailing(p)` returns the path `p` with a single trailing slash added | ||
* `removeTrailing(p)` returns the path `p` with trailing slash(es) removed | ||
#### Filer.Errors<a name="Errors"></a> | ||
@@ -281,0 +286,0 @@ |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is too big to display
1317432
12545
1646