aboutsummaryrefslogtreecommitdiff
path: root/node_modules/fs-extra/docs
diff options
context:
space:
mode:
authorFlorian Dold <florian.dold@gmail.com>2017-08-14 05:01:11 +0200
committerFlorian Dold <florian.dold@gmail.com>2017-08-14 05:02:09 +0200
commit363723fc84f7b8477592e0105aeb331ec9a017af (patch)
tree29f92724f34131bac64d6a318dd7e30612e631c7 /node_modules/fs-extra/docs
parent5634e77ad96bfe1818f6b6ee70b7379652e5487f (diff)
node_modules
Diffstat (limited to 'node_modules/fs-extra/docs')
-rw-r--r--node_modules/fs-extra/docs/fs-read-write.md39
-rw-r--r--node_modules/fs-extra/docs/outputJson-sync.md4
-rw-r--r--node_modules/fs-extra/docs/outputJson.md4
-rw-r--r--node_modules/fs-extra/docs/writeJson-sync.md6
-rw-r--r--node_modules/fs-extra/docs/writeJson.md6
5 files changed, 53 insertions, 6 deletions
diff --git a/node_modules/fs-extra/docs/fs-read-write.md b/node_modules/fs-extra/docs/fs-read-write.md
new file mode 100644
index 000000000..5e5f42070
--- /dev/null
+++ b/node_modules/fs-extra/docs/fs-read-write.md
@@ -0,0 +1,39 @@
+# About `fs.read()` & `fs.write()`
+
+[`fs.read()`](https://nodejs.org/api/fs.html#fs_fs_read_fd_buffer_offset_length_position_callback) & [`fs.write()`](https://nodejs.org/api/fs.html#fs_fs_write_fd_buffer_offset_length_position_callback) are different from other `fs` methods in that their callbacks are called with 3 arguments instead of the usual 2 arguments.
+
+If you're using them with callbacks, they will behave as usual. However, their promise usage is a little different. `fs-extra` promisifies these methods like [`util.promisify()`](https://nodejs.org/api/util.html#util_util_promisify_original) (only availible in Node 8+) does.
+
+Here's the example promise usage:
+
+## `fs.read()`
+
+```js
+// Basic promises
+fs.read(fd, buffer, offset, length, position)
+ .then(results => {
+ console.log(results)
+ // { bytesRead: 20, buffer: <Buffer 0f 34 5d ...> }
+ })
+
+// Async/await usage:
+async function example () {
+ const { bytesRead, buffer } = await fs.read(fd, Buffer.alloc(length), offset, length, position)
+}
+```
+
+## `fs.write()`
+
+```js
+// Basic promises
+fs.write(fd, buffer, offset, length, position)
+ .then(results => {
+ console.log(results)
+ // { bytesWritten: 20, buffer: <Buffer 0f 34 5d ...> }
+ })
+
+// Async/await usage:
+async function example () {
+ const { bytesWritten, buffer } = await fs.write(fd, Buffer.alloc(length), offset, length, position)
+}
+```
diff --git a/node_modules/fs-extra/docs/outputJson-sync.md b/node_modules/fs-extra/docs/outputJson-sync.md
index cab6316b5..13c214d1b 100644
--- a/node_modules/fs-extra/docs/outputJson-sync.md
+++ b/node_modules/fs-extra/docs/outputJson-sync.md
@@ -1,13 +1,15 @@
# outputJsonSync(file, object, [options])
Almost the same as [`writeJsonSync`](writeJson-sync.md), except that if the directory does not exist, it's created.
-`options` are what you'd pass to [`jsonFile.writeFileSync()`](https://github.com/jprichardson/node-jsonfile#writefilesyncfilename-obj-options).
**Alias:** `outputJSONSync()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
+ - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+ - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
+ - Also accepts [`fs.writeFileSync` options](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
## Example:
diff --git a/node_modules/fs-extra/docs/outputJson.md b/node_modules/fs-extra/docs/outputJson.md
index fc6f2fe51..d3fbe670f 100644
--- a/node_modules/fs-extra/docs/outputJson.md
+++ b/node_modules/fs-extra/docs/outputJson.md
@@ -1,13 +1,15 @@
# outputJson(file, object, [options, callback])
Almost the same as [`writeJson`](writeJson.md), except that if the directory does not exist, it's created.
-`options` are what you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
**Alias:** `outputJSON()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
+ - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+ - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
+ - Also accepts [`fs.writeFile` options](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback)
- `callback` `<Function>`
## Example:
diff --git a/node_modules/fs-extra/docs/writeJson-sync.md b/node_modules/fs-extra/docs/writeJson-sync.md
index 9e649bbc1..d2a3ef642 100644
--- a/node_modules/fs-extra/docs/writeJson-sync.md
+++ b/node_modules/fs-extra/docs/writeJson-sync.md
@@ -1,13 +1,15 @@
# writeJsonSync(file, object, [options])
-Writes an object to a JSON file. `options` are the same that
-you'd pass to [`jsonFile.writeFileSync()`](https://github.com/jprichardson/node-jsonfile#writefilesyncfilename-obj-options).
+Writes an object to a JSON file.
**Alias:** `writeJSONSync()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
+ - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+ - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
+ - Also accepts [`fs.writeFileSync` options](https://nodejs.org/api/fs.html#fs_fs_writefilesync_file_data_options)
## Example:
diff --git a/node_modules/fs-extra/docs/writeJson.md b/node_modules/fs-extra/docs/writeJson.md
index 0e9c39319..af94ffc52 100644
--- a/node_modules/fs-extra/docs/writeJson.md
+++ b/node_modules/fs-extra/docs/writeJson.md
@@ -1,13 +1,15 @@
# writeJson(file, object, [options, callback])
-Writes an object to a JSON file. `options` are the same that
-you'd pass to [`jsonFile.writeFile()`](https://github.com/jprichardson/node-jsonfile#writefilefilename-options-callback).
+Writes an object to a JSON file.
**Alias:** `writeJSON()`
- `file` `<String>`
- `object` `<Object>`
- `options` `<Object>`
+ - `spaces` `<Number|String>` Number of spaces to indent; or a string to use for indentation (i.e. pass `'\t'` for tab indentation). See [the docs](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_space_argument) for more info.
+ - `replacer` [JSON replacer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify#The_replacer_parameter)
+ - Also accepts [`fs.writeFile` options](https://nodejs.org/api/fs.html#fs_fs_writefile_file_data_options_callback)
- `callback` `<Function>`
## Example: