1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | var fs_promise_1 = require("fs-promise");
|
4 | var fs_1 = require("mz/fs");
|
5 |
|
6 |
|
7 |
|
8 | var FileService = (function () {
|
9 | function FileService() {
|
10 | }
|
11 | |
12 |
|
13 |
|
14 |
|
15 | FileService.prototype.exists = function (file) {
|
16 | return __awaiter(this, void 0, void 0, function () {
|
17 | return __generator(this, function (_a) {
|
18 | switch (_a.label) {
|
19 | case 0: return [4 , fs_promise_1.exists(file.path)];
|
20 | case 1: return [2 , _a.sent()];
|
21 | }
|
22 | });
|
23 | });
|
24 | };
|
25 | FileService.prototype.read = function (file, encoding) {
|
26 | if (encoding === void 0) { encoding = "UTF-8"; }
|
27 | return __awaiter(this, void 0, void 0, function () {
|
28 | return __generator(this, function (_a) {
|
29 | switch (_a.label) {
|
30 | case 0: return [4 , fs_promise_1.readFile(file.path, { encoding: encoding })];
|
31 | case 1: return [2 , _a.sent()];
|
32 | }
|
33 | });
|
34 | });
|
35 | };
|
36 | FileService.prototype.write = function (file, data, encoding) {
|
37 | return __awaiter(this, void 0, void 0, function () {
|
38 | return __generator(this, function (_a) {
|
39 | switch (_a.label) {
|
40 | case 0: return [4 , fs_1.writeFile(file.path, data, encoding)];
|
41 | case 1:
|
42 | _a.sent();
|
43 | return [2 ];
|
44 | }
|
45 | });
|
46 | });
|
47 | };
|
48 | FileService.prototype.remove = function (file) {
|
49 | return __awaiter(this, void 0, void 0, function () {
|
50 | return __generator(this, function (_a) {
|
51 | switch (_a.label) {
|
52 | case 0: return [4 , fs_promise_1.remove(file.path)];
|
53 | case 1: return [2 , _a.sent()];
|
54 | }
|
55 | });
|
56 | });
|
57 | };
|
58 | return FileService;
|
59 | }());
|
60 | exports.FileService = FileService;
|
61 |
|
\ | No newline at end of file |