summaryrefslogtreecommitdiff
path: root/docs/v3/reject.js.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/v3/reject.js.html')
-rw-r--r--docs/v3/reject.js.html48
1 files changed, 41 insertions, 7 deletions
diff --git a/docs/v3/reject.js.html b/docs/v3/reject.js.html
index ddad843..18048d9 100644
--- a/docs/v3/reject.js.html
+++ b/docs/v3/reject.js.html
@@ -98,14 +98,48 @@ import awaitify from './internal/awaitify'
* @returns {Promise} a promise, if no callback is passed
* @example
*
- * async.reject(['file1','file2','file3'], function(filePath, callback) {
- * fs.access(filePath, function(err) {
- * callback(null, !err)
- * });
- * }, function(err, results) {
- * // results now equals an array of missing files
- * createFiles(results);
+ * // dir1 is a directory that contains file1.txt, file2.txt
+ * // dir2 is a directory that contains file3.txt, file4.txt
+ * // dir3 is a directory that contains file5.txt
+ *
+ * const fileList = ['dir1/file1.txt','dir2/file3.txt','dir3/file6.txt'];
+ *
+ * // asynchronous function that checks if a file exists
+ * function fileExists(file, callback) {
+ * fs.access(file, fs.constants.F_OK, (err) => {
+ * callback(null, !err);
+ * });
+ * }
+ *
+ * // Using callbacks
+ * async.reject(fileList, fileExists, function(err, results) {
+ * // [ 'dir3/file6.txt' ]
+ * // results now equals an array of the non-existing files
* });
+ *
+ * // Using Promises
+ * async.reject(fileList, fileExists)
+ * .then( results => {
+ * console.log(results);
+ * // [ 'dir3/file6.txt' ]
+ * // results now equals an array of the non-existing files
+ * }).catch( err => {
+ * console.log(err);
+ * });
+ *
+ * // Using async/await
+ * async () => {
+ * try {
+ * let results = await async.reject(fileList, fileExists);
+ * console.log(results);
+ * // [ 'dir3/file6.txt' ]
+ * // results now equals an array of the non-existing files
+ * }
+ * catch (err) {
+ * console.log(err);
+ * }
+ * }
+ *
*/
function reject (coll, iteratee, callback) {
return _reject(eachOf, coll, iteratee, callback)