Skip to content

Commit 6334642

Browse files
committed
chore(package) v3.2.0
1 parent 3214ff3 commit 6334642

File tree

5 files changed

+48
-24
lines changed

5 files changed

+48
-24
lines changed

ChangeLog

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
2016.11.21, v3.2.0
2+
3+
feature:
4+
- (package) add eslint
5+
- (readify) add support of "raw" results
6+
7+
18
2016.11.16, v3.1.2
29

310
feature:

dist/readify.js

Lines changed: 38 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -25132,15 +25132,11 @@ var zames = require('zames/legacy');
2513225132
var WIN = process.platform === 'win32';
2513325133
var BROWSER = typeof window !== 'undefined';
2513425134

25135-
var map = currify(function (fn, array) {
25136-
return array.map(fn);
25137-
});
2513825135
var sort = currify(function (fn, array) {
2513925136
return array.sort(fn);
2514025137
});
25141-
var parseStats = map(parseStat);
25142-
25143-
var getStat_ = currify(getStat);
25138+
var getStat = currify(_getStat);
25139+
var parseAllStats = currify(_parseAllStats);
2514425140

2514525141
var getAllStats = zames(_getAllStats);
2514625142

@@ -25173,10 +25169,15 @@ var good = function good(f) {
2517325169

2517425170
module.exports = readify;
2517525171

25176-
function readify(path, fn) {
25172+
function readify(path, type, fn) {
25173+
if (!fn) {
25174+
fn = type;
25175+
type = '';
25176+
}
25177+
2517725178
check(path, fn);
2517825179

25179-
readdir(path).then(getAllStats(path)).then(good(fn)).catch(fn);
25180+
readdir(path).then(getAllStats(path, type)).then(good(fn)).catch(fn);
2518025181
}
2518125182

2518225183
function check(path, callback) {
@@ -25192,14 +25193,14 @@ function check(path, callback) {
2519225193
* @param path
2519325194
* @param names
2519425195
*/
25195-
function _getAllStats(path, names, callback) {
25196+
function _getAllStats(path, type, names, callback) {
2519625197
var length = names.length;
2519725198
var dir = format.addSlashToEnd(path);
2519825199

25199-
if (!length) return fillJSON(dir, [], callback);
25200+
if (!length) return fillJSON(dir, [], type, callback);
2520025201

2520125202
var funcs = names.map(function (name) {
25202-
return getStat_(name, dir + name);
25203+
return getStat(name, dir + name);
2520325204
});
2520425205

2520525206
exec.parallel(funcs, function () {
@@ -25208,7 +25209,7 @@ function _getAllStats(path, names, callback) {
2520825209
}
2520925210

2521025211
var files = args.slice(1);
25211-
fillJSON(dir, files, callback);
25212+
fillJSON(dir, files, type, callback);
2521225213
});
2521325214
}
2521425215

@@ -25221,7 +25222,7 @@ function emptyStat() {
2522125222
};
2522225223
}
2522325224

25224-
function getStat(name, path, callback) {
25225+
function _getStat(name, path, callback) {
2522525226
fs.stat(path, function (error) {
2522625227
var data = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : emptyStat();
2522725228

@@ -25231,7 +25232,21 @@ function getStat(name, path, callback) {
2523125232
});
2523225233
}
2523325234

25234-
function parseStat(stat) {
25235+
function _parseAllStats(type, array) {
25236+
return array.map(function (item) {
25237+
return parseStat(type, item);
25238+
});
25239+
}
25240+
25241+
function parseStat(type, stat) {
25242+
if (type === 'raw') return {
25243+
name: stat.name,
25244+
size: stat.size,
25245+
date: stat.mtime,
25246+
owner: stat.uid,
25247+
mode: stat.mode
25248+
};
25249+
2523525250
/* Переводим права доступа в 8-ричную систему */
2523625251
var modeStr = Number(stat.mode).toString(8);
2523725252
var owner = stat.uid || '';
@@ -25243,11 +25258,11 @@ function parseStat(stat) {
2524325258
});
2524425259

2524525260
return {
25246-
'name': stat.name,
25247-
'size': format.size(size),
25248-
'date': mtime,
25249-
'owner': owner,
25250-
'mode': mode && format.permissions.symbolic(mode)
25261+
name: stat.name,
25262+
size: format.size(size),
25263+
date: mtime,
25264+
owner: owner,
25265+
mode: mode && format.permissions.symbolic(mode)
2525125266
};
2525225267
}
2525325268

@@ -25256,15 +25271,17 @@ function parseStat(stat) {
2525625271
*
2525725272
* @param params - { files, stats, path }
2525825273
*/
25259-
function fillJSON(path, stats, callback) {
25260-
var processFiles = squad(changeOrder, sortFiles, parseStats);
25274+
function fillJSON(path, stats, type, callback) {
25275+
var processFiles = squad(changeOrder, sortFiles, parseAllStats(type));
2526125276
var json = {
2526225277
path: '',
2526325278
files: processFiles(stats)
2526425279
};
2526525280

2526625281
json.path = format.addSlashToEnd(path);
2526725282

25283+
if (type === 'raw') return callback(null, json);
25284+
2526825285
changeUIDToName(json, function (error, files) {
2526925286
json.files = files;
2527025287
callback(null, json);

dist/readify.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

dist/readify.min.js.map

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "readify",
3-
"version": "3.1.2",
3+
"version": "3.2.0",
44
"author": "coderaiser <mnemonic.enemy@gmail.com> (https://github.com/coderaiser)",
55
"description": "Read directory content with file attributes: size, date, owner, mode",
66
"homepage": "http://github.com/coderaiser/readify",

0 commit comments

Comments
 (0)