@makano/rew 1.2.81 → 1.2.82
Sign up to get free protection for your applications and to get access to all the features.
package/lib/rew/const/default.js
CHANGED
@@ -6,7 +6,7 @@ const sleep = require('../functions/sleep');
|
|
6
6
|
const { match } = require('../functions/match');
|
7
7
|
const { map } = require('../functions/map');
|
8
8
|
const { typex, typeis, typedef, typei, int, float, num, str, bool } = require('../functions/types');
|
9
|
-
const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry } = require('../functions/core');
|
9
|
+
const { isEmpty, clone, deepClone, merge, uniqueId, compose, curry, getters, setters } = require('../functions/core');
|
10
10
|
const { print, input, clear, printf } = require('../functions/stdout');
|
11
11
|
const { curl } = require('../functions/curl');
|
12
12
|
const { wait } = require('../functions/wait');
|
@@ -45,6 +45,8 @@ module.exports = {
|
|
45
45
|
uniqueId,
|
46
46
|
compose,
|
47
47
|
curry,
|
48
|
+
getters,
|
49
|
+
setters,
|
48
50
|
|
49
51
|
json,
|
50
52
|
jsons,
|
@@ -71,6 +71,30 @@ function curry(fn) {
|
|
71
71
|
return curried;
|
72
72
|
}
|
73
73
|
|
74
|
+
function getters(object, getters) {
|
75
|
+
for (let prop in getters) {
|
76
|
+
if (getters.hasOwnProperty(prop) && typeof getters[prop] === 'function') {
|
77
|
+
Object.defineProperty(object, prop, {
|
78
|
+
get: getters[prop],
|
79
|
+
enumerable: true,
|
80
|
+
configurable: true
|
81
|
+
});
|
82
|
+
}
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
function setters(object, setters) {
|
87
|
+
for (let prop in setters) {
|
88
|
+
if (setters.hasOwnProperty(prop) && typeof setters[prop] === 'function') {
|
89
|
+
Object.defineProperty(object, prop, {
|
90
|
+
set: setters[prop],
|
91
|
+
enumerable: true,
|
92
|
+
configurable: true
|
93
|
+
});
|
94
|
+
}
|
95
|
+
}
|
96
|
+
}
|
97
|
+
|
74
98
|
module.exports = {
|
75
99
|
isEmpty,
|
76
100
|
clone,
|
@@ -81,4 +105,6 @@ module.exports = {
|
|
81
105
|
reduce,
|
82
106
|
compose,
|
83
107
|
curry,
|
108
|
+
getters,
|
109
|
+
setters
|
84
110
|
};
|