methods 
Async directoryToStream
@param {string} directory : directory to work with
@param {string} separator : used to separate content (can be "")
@param {function|null} callback : operation's result
@returns {void}
559510
function _directoryToStream (directory, separator, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}

			else if ("undefined" === typeof callback && "undefined" === typeof separator) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof separator) {
					throw new TypeError("\"callback\" argument is not a function");
				}

			else {

				extractFiles(directory, (err, files) => {
					const _callback = "undefined" === typeof callback ? separator : callback;
					return err ? _callback(err) : filesToStream(files, separator, _callback);
				});

			}

		}
1272743
function mkdirSyncRecursive(dir, mode) {
	try {
		fs.mkdirSync(dir, mode);
	}
	catch (err) {
		if (err.code === 'ENOENT') {
			mkdirSyncRecursive(path.dirname(dir), mode);
			mkdirSyncRecursive(dir, mode);
		}
		else if (err.code === 'EEXIST') {
			return;
		}
		else {
			throw err;
		}
	}
}
971863
function mkdirSync (path) {
  const dir = Path.resolve(path)
  if (existsSync(dir)) {
    return true
  }

  Fs.mkdirSync(dir)
  return existsSync(dir)
}
179452
function foreachInDir (dirpath, fnc, done) {
	// Read the files
	fs.readdir(dirpath, function (err, files) {
		// Return error
		if (err) {
			return done(err);
		}

		// Process each file
		parallel(files.map(function (f) {
			return fnc.bind(null, f);
		}), done);
	});
}
1368760
function (path) {
    var pathSep = require('path').sep;
    var dirs = path.split(pathSep);
    var root = '';

    while (dirs.length > 0) {
      var dir = dirs.shift();
      if (dir === '') {
        root = pathSep;
      }
      if (!fs.existsSync(root + dir)) {
        fs.mkdirSync(root + dir);
      }
      root += dir + pathSep;
    }
  }
802499
function mkdirp(con, p, callback) {
  p = path.normalize(p);
  var dirs = p.split('/').slice(1); // remove empty string at the start.

  // console.log('dirs', dirs);

  var tasks = [];
  dirs.forEach(function(dir, i) {
    var subpath = '/' + dirs.slice(0, i).join('/') + '/' + dir;
    subpath = path.normalize(subpath); // remove extra `/` in first iteration
    tasks.push(async.apply(create, con, subpath));
  });
  async.waterfall(tasks, function(err, results) {
    if(err) return callback(err);
    // succeeded!
    return callback(null, true);
  });
}
1351842
function makeDir(path, callback) {
  fs.mkdir(path, err => {
    if (err) {
      // check if directory exists
      fs.stat(path, (err2, stat) => {
        if (err2 || !stat.isDirectory()) {
          callback(err);
        } else {
          callback();
        }
      });
    } else {
      callback();
    }
  });
}
166855
function init (directory, callback) {
  var source = path.join(__dirname, 'template');
  ncp(source, directory, callback);
}
1028607
function processDir (err) {
      // Fail if any error other then 550 is present, 550 is Directory Already Exists
      // these directories must exist to continue
      if (err) {
        if (err.code !== 550) { grunt.fail.warn(err); }
      } else {
        grunt.log.ok(messages.directoryCreated(directories[index]));
      }

      ++index;
      // If there is more directories to process then keep going
      if (index < directories.length) {
        server.raw('mkd', directories[index], processDir);
      } else {
        callback();
      }
    }
1068008
function _mkdirp (directory, mode, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" !== typeof callback && "number" !== typeof mode) {
				throw new TypeError("\"mode\" argument is not a number");
			}
			else if ("undefined" === typeof callback && "undefined" === typeof mode) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof mode) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				let _callback = callback;
				let _mode = mode;

				if ("undefined" === typeof _callback) {
					_callback = mode;
					_mode = DEFAULT_OPTION;
				}

				isDirectoryProm(directory).then((exists) => {

					return exists ? Promise.resolve() : Promise.resolve().then(() => {

						const SUB_DIRECTORY = dirname(directory);

						return isDirectoryProm(SUB_DIRECTORY).then((_exists) => {

							return _exists ? new Promise((resolve, reject) => {

								mkdir(directory, _mode, (err) => {
									return err ? reject(err) : resolve();
								});

							}) : new Promise((resolve, reject) => {

								_mkdirp(SUB_DIRECTORY, _mode, (err) => {

									return err ? reject(err) : mkdir(directory, _mode, (_err) => {
										return _err ? reject(_err) : resolve();
									});

								});

							});

						});

					});

				}).then(() => {
					_callback(null);
				}).catch(callback);

			}

		}
159623
async function (directory, filesInSassTree, exclusions) {
  const filesInDirectory = (await recursive(directory));

  const unusedFiles = filesInDirectory
    .filter((file) => isUnused(file, filesInSassTree, exclusions));

  return unusedFiles;
}
844526
function _rmdirp (directory, callback) {

			if ("undefined" === typeof directory) {
				throw new ReferenceError("missing \"directory\" argument");
			}
				else if ("string" !== typeof directory) {
					throw new TypeError("\"directory\" argument is not a string");
				}
				else if ("" === directory.trim()) {
					throw new Error("\"directory\" argument is empty");
				}
			else if ("undefined" === typeof callback) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				isDirectoryProm(directory).then((exists) => {

					return !exists ? Promise.resolve() : _emptyDirectoryProm(directory).then(() => {

						return new Promise((resolve, reject) => {

							rmdir(directory, (err) => {
								return err ? reject(err) : resolve();
							});

						});

					});

				}).then(() => {
					callback(null);
				}).catch(callback);

			}

		}
1017156
function(folderPath, callback, level) {
        level = level || 1;
        if (typeof callback !== 'function') {
            throw 'The callback argument must be a valid function.';
        }

        var treeTraversed = _promise.deferred();
        var dirContentsReady = _promise.deferred();

        function _rejectTraversal() {
            treeTraversed.reject(folderPath);
        };

        // Attempt to read the contents of the folder.
        _fs.readdir(folderPath, dirContentsReady.getResolver());

        // Handler to handle when the folder contents are ready.
        dirContentsReady.success(function(data) {
            // Create a resolver that will complete the promise after all
            // items have been processed.
            var resolver = treeTraversed.getMultiStepResolver(data.length);

            // The contents of the folder have been read. Process them.
            data.forEach(function(item) {
                var itemStats = _promise.deferred();
                var itemPath = _path.join(folderPath, item);

                _fs.lstat(itemPath, itemStats.getResolver());

                itemStats.success(function(data) {
                    if (data.isDirectory()) {
                        // Let the listener know that we found an item.
                        callback(itemPath, level, true);

                        // Traverse the child folder, and only mark this
                        // activity as completed once the child is finished.
                        mod.traverse(itemPath, callback, level + 1)
                            .success(resolver.stepComplete)
                            .fail(resolver.reject);
                    } else {
                        // Let the listener know that we found an item.
                        callback(itemPath, level, false);

                        // Nothing to wait for. Mark the step as completed.
                        resolver.stepComplete();
                    }

                    //Could not get child item stats. Traversal failed.
                }).fail(_rejectTraversal);
            });

            // Could not read child items. Traversal failed.
        }).fail(_rejectTraversal);

        return treeTraversed.promise();
    }
1081903
function(callback) {
    //process first all directories and then all files.
    async.mapSeries(['getDirectories', 'getFiles'], (nodeSource, cbMap) => {
      syncDb[nodeSource]((err, nodes) => {
        async.eachSeries(nodes, (node, cb) => {
          if(node.localActions && node.localActions.create) {
            var nodePath = utility.joinPath(node.parent, node.name);

            syncDb.findByPath(nodePath, (err, syncedNode) => {
              try {
                var stat = fsWrap.lstatSync(nodePath);
              } catch(e) {
                logger.warning('resolveConflicts got lstat error on node', {category: 'sync-local-delta', nodePath, code: e.code});
                throw new BlnDeltaError(e.message);
              }

              //deleted and recreated at same path
              if(syncedNode.localActions && syncedNode.localActions.delete) {
                syncedNode.ino = stat.ino;

                delete syncedNode.localActions.delete;

                if(syncedNode.directory) {
                  syncedNode.ctime = stat.ctime;
                  syncedNode.mtime = stat.mtime;
                  syncedNode.size = stat.size;
                } else {
                  syncedNode.localActions.create = node.localActions.create;
                }

                async.parallel([
                  (cbParallel) => {
                    syncDb.update(syncedNode._id, syncedNode, cbParallel);
                  },
                  (cbParallel) => {
                    syncDb.remove(node._id, cbParallel);
                  }
                ], cb);
              } else {
                cb(null);
              }
            });
          } else {
            cb(null);
          }
        }, cbMap);
      });
    }, callback);
  }
948153
function(callback) {
        grunt.log.writeln('Prepare tmp path...');
        if (!grunt.file.isDir(tmpPath)) {
          if (grunt.file.exists(tmpPath)) {
            callback(new Error(util.format('"%s" is not a directory', tmpPath)));
          }
          else {
            grunt.file.mkdir(tmpPath);
            callback(null);
          }
        }
        else {
          callback(null);
        }
      }
557835
function _filesToFile (files, target, separator, callback) {

			if ("undefined" === typeof files) {
				throw new ReferenceError("missing \"files\" argument");
			}
				else if ("object" !== typeof files || !(files instanceof Array)) {
					throw new TypeError("\"files\" argument is not an Array");
				}
			else if ("undefined" === typeof target) {
				throw new ReferenceError("missing \"target\" argument");
			}
				else if ("string" !== typeof target) {
					throw new TypeError("\"target\" argument is not a string");
				}
			else if ("undefined" === typeof callback && "undefined" === typeof separator) {
				throw new ReferenceError("missing \"callback\" argument");
			}
				else if ("function" !== typeof callback && "function" !== typeof separator) {
					throw new TypeError("\"callback\" argument is not a function");
				}
			else {

				const _target = target.trim();

				if ("" === _target) {
					throw new Error("\"target\" argument is empty");
				}
				else {

					const _callback = "undefined" === typeof callback ? separator : callback;

					Promise.resolve().then(() => {
						return isFileProm(_target);
					}).then((exists) => {

						return !exists ? Promise.resolve() : new Promise((resolve, reject) => {

							fs.unlink(_target, (err) => {
								return err ? reject(err) : resolve();
							});

						});

					}).then(() => {

						if (!files.length) {

							return new Promise((resolve, reject) => {

								fs.writeFile(_target, "", (err) => {
									return err ? reject(err) : resolve();
								});

							});

						}
						else {

							return filesToStreamProm(files, "string" === typeof separator ? separator : " ").then((readStream) => {

								return new Promise((resolve, reject) => {

									let error = false;
									readStream.once("error", (_err) => {
										error = true; reject(_err);
									}).pipe(fs.createWriteStream(_target, { "flags": "a" }).once("error", (_err) => {
										error = true; reject(_err);
									}).once("close", () => {

										if (!error) {
											resolve();
										}

									}));

								});

							});

						}

					}).then(() => {
						_callback(null);
					}).catch(_callback);

				}

			}

		}
244437
function(/**string*/ outDir, /**string*/ fileName, /**string*/ content) {
		fs.writeFileSync(outDir + "/" + fileName, content, IO.encoding);
	}