Comparing version 0.0.2 to 0.1.0
# Release notes for `m-io` | ||
<a name="current-release"></a> | ||
# Version 0.1.0 (Fri, 22 Jul 2016 23:36:27 GMT) | ||
* [40ccb35](https://github.com/nknapp/m-io/commit/40ccb35), | ||
[2837463](https://github.com/nknapp/m-io/commit/2837463), | ||
[3c1c31e](https://github.com/nknapp/m-io/commit/3c1c31e) Node 0.10 compatibility (replace const by var) - Nils Knappmeier | ||
[6309a47](https://github.com/nknapp/m-io/commit/6309a47) Travis (and code) setup for node 0.10 to 6 - Nils Knappmeier | ||
* [2bfe98e](https://github.com/nknapp/m-io/commit/2bfe98e) Setup "travis" for npm-deployment - Nils Knappmeier | ||
* [22382c3](https://github.com/nknapp/m-io/commit/22382c3) Added "q"-dependency - Nils Knappmeier | ||
* [ccac480](https://github.com/nknapp/m-io/commit/ccac480) Added documentation and tests - Nils Knappmeier | ||
# Version 0.0.2 (Fri, 22 Jul 2016 14:01:23 GMT) | ||
@@ -5,0 +17,0 @@ |
52
fs.js
@@ -14,2 +14,6 @@ /*! | ||
/** | ||
* | ||
* @module | ||
*/ | ||
module.exports = { | ||
@@ -20,3 +24,3 @@ /** | ||
* @param {string} directoryPath the base path | ||
* @param {function(string,fs.Stats):boolean} filter a function that returns true, false or null to show that a file | ||
* @param {function(string,fs.Stats):boolean=} filter a function that returns true, false or null to show that a file | ||
* should be included or ignored and that a directory should be ignored completely (null) | ||
@@ -31,3 +35,3 @@ * @returns {Promise<string[]>} a promise for the collector, that is fulfilled after traversal | ||
* @param {string} aPath the directory to be created | ||
* @param {number} mode (e.g. 0644) | ||
* @param {number=} mode (e.g. 0644) | ||
*/ | ||
@@ -45,3 +49,4 @@ makeTree: function makeTree (aPath, mode) { | ||
read: function read (aPath, options) { | ||
const flags = optionsFrom(options).flags | ||
var flags = optionsFrom(options).flags | ||
console.log(flags) | ||
return Q.ninvoke(fs, 'readFile', aPath, { | ||
@@ -76,2 +81,3 @@ encoding: flags === 'b' ? null : 'utf-8' | ||
* @param optionsOrFlags | ||
* @private | ||
* @returns {*} | ||
@@ -83,3 +89,3 @@ */ | ||
} | ||
if (optionsOrFlags instanceof String) { | ||
if (typeof optionsOrFlags === 'string') { | ||
return { | ||
@@ -98,2 +104,3 @@ flags: optionsOrFlags | ||
* @param {string[]} collector array to collect the filenames into | ||
* @private | ||
* @returns {Promise<string[]>} a promise for the collector, that is fulfilled after traversal | ||
@@ -107,25 +114,24 @@ */ | ||
} | ||
var filterResult = filter(directoryPath, stat) | ||
// Call filter to get result, "true" if no filter is set | ||
var filterResult = !filter || filter(directoryPath, stat) | ||
if (filterResult) { | ||
collector.push(directoryPath) | ||
} | ||
if (stat.isDirectory()) { | ||
// false/true => iterate directory | ||
if (filterResult !== null) { | ||
fs.readdir(directoryPath, function (err, filenames) { | ||
if (err) { | ||
return defer.reject(err) | ||
} | ||
var paths = filenames.map(function (name) { | ||
return path.join(directoryPath, name) | ||
// false/true => iterate directory | ||
if (stat.isDirectory() && filterResult !== null) { | ||
fs.readdir(directoryPath, function (err, filenames) { | ||
if (err) { | ||
return defer.reject(err) | ||
} | ||
var paths = filenames.map(function (name) { | ||
return path.join(directoryPath, name) | ||
}) | ||
// Walk all files/subdirs | ||
Q.all(paths.map(function (filepath) { | ||
return walk(filepath, filter, collector) | ||
})) | ||
.then(function () { | ||
defer.fulfill(collector) | ||
}) | ||
// Walk all files/subdirs | ||
Q.all(paths.map(function (filepath) { | ||
return walk(filepath, filter, collector) | ||
})) | ||
.then(function () { | ||
defer.fulfill(collector) | ||
}) | ||
}) | ||
} | ||
}) | ||
} else { | ||
@@ -132,0 +138,0 @@ // No recursive call with a file |
12
index.js
@@ -7,12 +7,2 @@ /*! | ||
*/ | ||
'use strict' | ||
module.exports = mIo | ||
/** | ||
* Describe your module here | ||
* @public | ||
*/ | ||
function mIo () { | ||
// body | ||
} | ||
throw new Error('Please use q-io/fs instead') |
{ | ||
"name": "m-io", | ||
"version": "0.0.2", | ||
"description": "(Incomplete) replacement for `q-io`", | ||
"version": "0.1.0", | ||
"description": "(Incomplete) replacement for q-io", | ||
"repository": { | ||
@@ -33,5 +33,8 @@ "type": "git", | ||
"mkdirp": "^0.5.1", | ||
"q": "^1.4.1", | ||
"rimraf": "^2.5.3" | ||
}, | ||
"devDependencies": { | ||
"chai": "^3.5.0", | ||
"chai-as-promised": "^5.3.0", | ||
"ghooks": "^1.0.3", | ||
@@ -38,0 +41,0 @@ "mocha": "^2.3.3", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
No README
QualityPackage does not have a README. This may indicate a failed publish or a low quality package.
Found 1 instance in 1 package
14309
7
0
160
3
5
132