alchemymvc 1.1.8 → 1.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +458 -454
- package/lib/app/conduit/http_conduit.js +173 -192
- package/lib/class/conduit.js +2474 -2412
- package/lib/class/inode_file.js +112 -113
- package/lib/class/model.js +1773 -1772
- package/package.json +73 -73
package/lib/class/inode_file.js
CHANGED
|
@@ -1,114 +1,113 @@
|
|
|
1
|
-
const fs = alchemy.use('fs');
|
|
2
|
-
|
|
3
|
-
/**
|
|
4
|
-
* The File class
|
|
5
|
-
*
|
|
6
|
-
* @constructor
|
|
7
|
-
*
|
|
8
|
-
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
|
-
* @since 1.1.0
|
|
10
|
-
* @version 1.1.0
|
|
11
|
-
*
|
|
12
|
-
* @param {String} path Path to the file
|
|
13
|
-
*/
|
|
14
|
-
var File = Function.inherits('Alchemy.Inode', function File(path) {
|
|
15
|
-
|
|
16
|
-
if (typeof path == 'object') {
|
|
17
|
-
return File.from(path);
|
|
18
|
-
}
|
|
19
|
-
|
|
20
|
-
this.type = null;
|
|
21
|
-
this.hash = null;
|
|
22
|
-
|
|
23
|
-
File.super.call(this, path);
|
|
24
|
-
});
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Files are obviously files
|
|
28
|
-
*
|
|
29
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
30
|
-
* @since 1.1.0
|
|
31
|
-
* @version 1.1.0
|
|
32
|
-
*
|
|
33
|
-
* @type {Boolean}
|
|
34
|
-
*/
|
|
35
|
-
File.setProperty('is_file', true);
|
|
36
|
-
|
|
37
|
-
/**
|
|
38
|
-
* Create a File instance from the given variable
|
|
39
|
-
*
|
|
40
|
-
* @author Jelle De Loecker <jelle@develry.be>
|
|
41
|
-
* @since 1.1.0
|
|
42
|
-
* @version 1.
|
|
43
|
-
*/
|
|
44
|
-
File.setStatic(function from(obj) {
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
file.
|
|
64
|
-
file.
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @
|
|
75
|
-
* @
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
*
|
|
102
|
-
*
|
|
103
|
-
* @
|
|
104
|
-
* @
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
return this.read({encoding: encoding});
|
|
1
|
+
const fs = alchemy.use('fs');
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* The File class
|
|
5
|
+
*
|
|
6
|
+
* @constructor
|
|
7
|
+
*
|
|
8
|
+
* @author Jelle De Loecker <jelle@elevenways.be>
|
|
9
|
+
* @since 1.1.0
|
|
10
|
+
* @version 1.1.0
|
|
11
|
+
*
|
|
12
|
+
* @param {String} path Path to the file
|
|
13
|
+
*/
|
|
14
|
+
var File = Function.inherits('Alchemy.Inode', function File(path) {
|
|
15
|
+
|
|
16
|
+
if (typeof path == 'object') {
|
|
17
|
+
return File.from(path);
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
this.type = null;
|
|
21
|
+
this.hash = null;
|
|
22
|
+
|
|
23
|
+
File.super.call(this, path);
|
|
24
|
+
});
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Files are obviously files
|
|
28
|
+
*
|
|
29
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
30
|
+
* @since 1.1.0
|
|
31
|
+
* @version 1.1.0
|
|
32
|
+
*
|
|
33
|
+
* @type {Boolean}
|
|
34
|
+
*/
|
|
35
|
+
File.setProperty('is_file', true);
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Create a File instance from the given variable
|
|
39
|
+
*
|
|
40
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
41
|
+
* @since 1.1.0
|
|
42
|
+
* @version 1.2.0
|
|
43
|
+
*/
|
|
44
|
+
File.setStatic(function from(obj) {
|
|
45
|
+
|
|
46
|
+
let path;
|
|
47
|
+
|
|
48
|
+
if (typeof obj == 'string') {
|
|
49
|
+
path = obj;
|
|
50
|
+
obj = null;
|
|
51
|
+
} else {
|
|
52
|
+
path = obj.path;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
let file = new File(path);
|
|
56
|
+
|
|
57
|
+
if (obj) {
|
|
58
|
+
file.stat = {
|
|
59
|
+
size : obj.size
|
|
60
|
+
};
|
|
61
|
+
|
|
62
|
+
file.name = obj.name;
|
|
63
|
+
file.type = obj.type;
|
|
64
|
+
file.hash = obj.hash;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return file;
|
|
68
|
+
});
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Read and return the contents
|
|
72
|
+
*
|
|
73
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
74
|
+
* @since 1.1.0
|
|
75
|
+
* @version 1.1.8
|
|
76
|
+
*/
|
|
77
|
+
File.setMethod(function read(options) {
|
|
78
|
+
|
|
79
|
+
let pledge = new Pledge();
|
|
80
|
+
|
|
81
|
+
if (!options) {
|
|
82
|
+
options = {flag: 'r'};
|
|
83
|
+
} else if (!options.flag) {
|
|
84
|
+
options.flag = 'r';
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
fs.readFile(this.path, options, function done(err, data) {
|
|
88
|
+
|
|
89
|
+
if (err) {
|
|
90
|
+
return pledge.reject(err);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
pledge.resolve(data);
|
|
94
|
+
});
|
|
95
|
+
|
|
96
|
+
return pledge;
|
|
97
|
+
});
|
|
98
|
+
|
|
99
|
+
/**
|
|
100
|
+
* Read and return the contents as a string
|
|
101
|
+
*
|
|
102
|
+
* @author Jelle De Loecker <jelle@develry.be>
|
|
103
|
+
* @since 1.1.0
|
|
104
|
+
* @version 1.1.0
|
|
105
|
+
*/
|
|
106
|
+
File.setMethod(function readString(encoding) {
|
|
107
|
+
|
|
108
|
+
if (!encoding) {
|
|
109
|
+
encoding = 'utf8';
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return this.read({encoding: encoding});
|
|
114
113
|
});
|