Added npm dependency
This commit is contained in:
1 parent
888dd9af1e
commit
8dfc6caa7e
21061 files changed
+3885381
No files matched your search
+89
@@ -0,0 +1,89 @@
|
||||
"use strict";
|
||||
|
||||
Object.defineProperty(exports, "__esModule", {
|
||||
value: true
|
||||
});
|
||||
exports.readLines = undefined;
|
||||
exports.readText = readText;
|
||||
exports.readLine = readLine;
|
||||
exports.enumerateFileSystemEntries = enumerateFileSystemEntries;
|
||||
exports.isFile = isFile;
|
||||
exports.isDirectory = isDirectory;
|
||||
exports.enumerateFiles = enumerateFiles;
|
||||
|
||||
var _Node = require("./Node");
|
||||
|
||||
var _fs = require("fs");
|
||||
|
||||
var fs = _interopRequireWildcard(_fs);
|
||||
|
||||
var _CurriedLambda = require("../fable-core/CurriedLambda");
|
||||
|
||||
var _CurriedLambda2 = _interopRequireDefault(_CurriedLambda);
|
||||
|
||||
var _Seq = require("../fable-core/Seq");
|
||||
|
||||
var _String = require("../fable-core/String");
|
||||
|
||||
var _path = require("path");
|
||||
|
||||
var path_2 = _interopRequireWildcard(_path);
|
||||
|
||||
var _List = require("../fable-core/List");
|
||||
|
||||
var _Option = require("../fable-core/Option");
|
||||
|
||||
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
||||
|
||||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) newObj[key] = obj[key]; } } newObj.default = obj; return newObj; } }
|
||||
|
||||
function readText(file) {
|
||||
const path = _Node.Fs.PathLikeModule.ofString(file);
|
||||
|
||||
const encoding = "utf-8";
|
||||
return fs.readFileSync(path, encoding);
|
||||
}
|
||||
|
||||
const readLines = exports.readLines = (0, _CurriedLambda2.default)($var1 => function (text) {
|
||||
return (0, _Seq.ofArray)((0, _String.split)(text, "\n"));
|
||||
}(readText($var1)));
|
||||
|
||||
function readLine(num, file) {
|
||||
return (0, _Seq.item)(num - 1, readLines(file));
|
||||
}
|
||||
|
||||
function enumerateFileSystemEntries(dir) {
|
||||
const encoding = "utf8";
|
||||
|
||||
const t = _Node.Fs.PathLikeModule.ofString(dir);
|
||||
|
||||
return (0, _Seq.map)(function (str) {
|
||||
return path_2.join(...Array.from((0, _List.ofArray)([dir, str])));
|
||||
}, fs.readdirSync(t, (0, _Option.makeSome)(encoding)));
|
||||
}
|
||||
|
||||
function isFile(path) {
|
||||
const stats = fs.lstatSync.bind(fs)(_Node.Fs.PathLikeModule.ofString(path));
|
||||
return stats.isFile();
|
||||
}
|
||||
|
||||
function isDirectory(path) {
|
||||
const stats = fs.lstatSync.bind(fs)(_Node.Fs.PathLikeModule.ofString(path));
|
||||
return stats.isDirectory();
|
||||
}
|
||||
|
||||
function enumerateFiles(dirs) {
|
||||
if ((0, _Seq.isEmpty)(dirs)) {
|
||||
return (0, _Seq.empty)();
|
||||
} else {
|
||||
return (0, _Seq.delay)(function () {
|
||||
return (0, _Seq.append)((0, _Seq.collect)($var2 => function (source) {
|
||||
return (0, _Seq.filter)(isFile, source);
|
||||
}(enumerateFileSystemEntries($var2)), dirs), (0, _Seq.delay)(function () {
|
||||
return enumerateFiles((0, _Seq.collect)($var3 => function (source_1) {
|
||||
return (0, _Seq.filter)(isDirectory, source_1);
|
||||
}(enumerateFileSystemEntries($var3)), dirs));
|
||||
}));
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user