|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+var fs = require("fs")
|
|
|
2
|
+
|
|
|
3
|
+const builtins = {
|
|
|
4
|
+ readIn: function (path) {
|
|
|
5
|
+ let str = fs.readFileSync(path.value, { encoding: 'utf-8' })
|
|
|
6
|
+ return {
|
|
|
7
|
+ value: str
|
|
|
8
|
+ }
|
|
|
9
|
+ }
|
|
|
10
|
+}
|
|
|
11
|
+
|
|
|
12
|
+const my_handler = {
|
|
|
13
|
+ get: function (target, prop) {
|
|
|
14
|
+ let methods = Object.keys(builtins)
|
|
|
15
|
+ if (methods.includes(prop)) {
|
|
|
16
|
+ return builtins[prop]
|
|
|
17
|
+ } else {
|
|
|
18
|
+ console.error("Undefined function call! No such function: ", prop)
|
|
|
19
|
+ }
|
|
|
20
|
+ },
|
|
|
21
|
+}
|
|
|
22
|
+
|
|
|
23
|
+const proxy_obj = new Proxy({}, my_handler)
|
|
|
24
|
+let _
|
|
|
25
|
+
|
|
|
26
|
+module.exports = function (self) {
|
|
|
27
|
+ _ = self
|
|
|
28
|
+ return proxy_obj
|
|
|
29
|
+}
|