@splitsoftware/splitio-commons 1.0.1-rc.4 → 1.0.1-rc.5
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/cjs/evaluator/index.js
CHANGED
|
@@ -5,7 +5,6 @@ var tslib_1 = require("tslib");
|
|
|
5
5
|
var Engine_1 = tslib_1.__importDefault(require("./Engine"));
|
|
6
6
|
var thenable_1 = tslib_1.__importDefault(require("../utils/promise/thenable"));
|
|
7
7
|
var LabelsConstants = tslib_1.__importStar(require("../utils/labels"));
|
|
8
|
-
var lang_1 = require("../utils/lang");
|
|
9
8
|
var constants_1 = require("../utils/constants");
|
|
10
9
|
var treatmentException = {
|
|
11
10
|
treatment: constants_1.CONTROL,
|
|
@@ -66,17 +65,17 @@ function getEvaluation(log, stringifiedSplit, key, attributes, storage) {
|
|
|
66
65
|
var splitJSON_1 = JSON.parse(stringifiedSplit);
|
|
67
66
|
var split_1 = Engine_1.default.parse(log, splitJSON_1, storage);
|
|
68
67
|
evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
|
|
69
|
-
// If the storage is async
|
|
68
|
+
// If the storage is async and the evaluated split uses segment, evaluation is thenable
|
|
70
69
|
if (thenable_1.default(evaluation)) {
|
|
71
70
|
return evaluation.then(function (result) {
|
|
72
71
|
result.changeNumber = split_1.getChangeNumber();
|
|
73
|
-
result.config =
|
|
72
|
+
result.config = splitJSON_1.configurations && splitJSON_1.configurations[result.treatment] || null;
|
|
74
73
|
return result;
|
|
75
74
|
});
|
|
76
75
|
}
|
|
77
76
|
else {
|
|
78
77
|
evaluation.changeNumber = split_1.getChangeNumber(); // Always sync and optional
|
|
79
|
-
evaluation.config =
|
|
78
|
+
evaluation.config = splitJSON_1.configurations && splitJSON_1.configurations[evaluation.treatment] || null;
|
|
80
79
|
}
|
|
81
80
|
}
|
|
82
81
|
return evaluation;
|
package/cjs/utils/MinEvents.js
CHANGED
|
@@ -31,33 +31,31 @@
|
|
|
31
31
|
// OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
|
|
32
32
|
// USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
33
33
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
34
|
+
exports.EventEmitter = void 0;
|
|
34
35
|
var R = typeof Reflect === 'object' ? Reflect : null;
|
|
35
36
|
var ReflectApply = R && typeof R.apply === 'function'
|
|
36
37
|
? R.apply
|
|
37
38
|
: function ReflectApply(target, receiver, args) {
|
|
38
39
|
return Function.prototype.apply.call(target, receiver, args);
|
|
39
40
|
};
|
|
40
|
-
function EventEmitter() {
|
|
41
|
+
exports.EventEmitter = function EventEmitter() {
|
|
41
42
|
EventEmitter.init.call(this);
|
|
42
|
-
}
|
|
43
|
-
exports.
|
|
44
|
-
|
|
45
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
46
|
-
EventEmitter.prototype._events = undefined;
|
|
47
|
-
EventEmitter.prototype._eventsCount = 0;
|
|
43
|
+
};
|
|
44
|
+
exports.EventEmitter.prototype._events = undefined;
|
|
45
|
+
exports.EventEmitter.prototype._eventsCount = 0;
|
|
48
46
|
function checkListener(listener) {
|
|
49
47
|
if (typeof listener !== 'function') {
|
|
50
48
|
throw new TypeError('The "listener" argument must be of type Function. Received type ' + typeof listener);
|
|
51
49
|
}
|
|
52
50
|
}
|
|
53
|
-
EventEmitter.init = function () {
|
|
51
|
+
exports.EventEmitter.init = function () {
|
|
54
52
|
if (this._events === undefined ||
|
|
55
53
|
this._events === Object.getPrototypeOf(this)._events) {
|
|
56
54
|
this._events = Object.create(null);
|
|
57
55
|
this._eventsCount = 0;
|
|
58
56
|
}
|
|
59
57
|
};
|
|
60
|
-
EventEmitter.prototype.emit = function emit(type) {
|
|
58
|
+
exports.EventEmitter.prototype.emit = function emit(type) {
|
|
61
59
|
var args = [];
|
|
62
60
|
for (var i = 1; i < arguments.length; i++)
|
|
63
61
|
args.push(arguments[i]);
|
|
@@ -137,10 +135,10 @@ function _addListener(target, type, listener, prepend) {
|
|
|
137
135
|
}
|
|
138
136
|
return target;
|
|
139
137
|
}
|
|
140
|
-
EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
138
|
+
exports.EventEmitter.prototype.addListener = function addListener(type, listener) {
|
|
141
139
|
return _addListener(this, type, listener, false);
|
|
142
140
|
};
|
|
143
|
-
EventEmitter.prototype.on = EventEmitter.prototype.addListener;
|
|
141
|
+
exports.EventEmitter.prototype.on = exports.EventEmitter.prototype.addListener;
|
|
144
142
|
function onceWrapper() {
|
|
145
143
|
if (!this.fired) {
|
|
146
144
|
this.target.removeListener(this.type, this.wrapFn);
|
|
@@ -157,13 +155,13 @@ function _onceWrap(target, type, listener) {
|
|
|
157
155
|
state.wrapFn = wrapped;
|
|
158
156
|
return wrapped;
|
|
159
157
|
}
|
|
160
|
-
EventEmitter.prototype.once = function once(type, listener) {
|
|
158
|
+
exports.EventEmitter.prototype.once = function once(type, listener) {
|
|
161
159
|
checkListener(listener);
|
|
162
160
|
this.on(type, _onceWrap(this, type, listener));
|
|
163
161
|
return this;
|
|
164
162
|
};
|
|
165
163
|
// Emits a 'removeListener' event if and only if the listener was removed.
|
|
166
|
-
EventEmitter.prototype.removeListener =
|
|
164
|
+
exports.EventEmitter.prototype.removeListener =
|
|
167
165
|
function removeListener(type, listener) {
|
|
168
166
|
var list, events, position, i, originalListener;
|
|
169
167
|
checkListener(listener);
|
|
@@ -205,8 +203,8 @@ EventEmitter.prototype.removeListener =
|
|
|
205
203
|
}
|
|
206
204
|
return this;
|
|
207
205
|
};
|
|
208
|
-
EventEmitter.prototype.off = EventEmitter.prototype.removeListener;
|
|
209
|
-
EventEmitter.prototype.removeAllListeners =
|
|
206
|
+
exports.EventEmitter.prototype.off = exports.EventEmitter.prototype.removeListener;
|
|
207
|
+
exports.EventEmitter.prototype.removeAllListeners =
|
|
210
208
|
function removeAllListeners(type) {
|
|
211
209
|
var listeners, events, i;
|
|
212
210
|
events = this._events;
|
package/esm/evaluator/index.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Engine from './Engine';
|
|
2
2
|
import thenable from '../utils/promise/thenable';
|
|
3
3
|
import * as LabelsConstants from '../utils/labels';
|
|
4
|
-
import { get } from '../utils/lang';
|
|
5
4
|
import { CONTROL } from '../utils/constants';
|
|
6
5
|
var treatmentException = {
|
|
7
6
|
treatment: CONTROL,
|
|
@@ -60,17 +59,17 @@ function getEvaluation(log, stringifiedSplit, key, attributes, storage) {
|
|
|
60
59
|
var splitJSON_1 = JSON.parse(stringifiedSplit);
|
|
61
60
|
var split_1 = Engine.parse(log, splitJSON_1, storage);
|
|
62
61
|
evaluation = split_1.getTreatment(key, attributes, evaluateFeature);
|
|
63
|
-
// If the storage is async
|
|
62
|
+
// If the storage is async and the evaluated split uses segment, evaluation is thenable
|
|
64
63
|
if (thenable(evaluation)) {
|
|
65
64
|
return evaluation.then(function (result) {
|
|
66
65
|
result.changeNumber = split_1.getChangeNumber();
|
|
67
|
-
result.config =
|
|
66
|
+
result.config = splitJSON_1.configurations && splitJSON_1.configurations[result.treatment] || null;
|
|
68
67
|
return result;
|
|
69
68
|
});
|
|
70
69
|
}
|
|
71
70
|
else {
|
|
72
71
|
evaluation.changeNumber = split_1.getChangeNumber(); // Always sync and optional
|
|
73
|
-
evaluation.config =
|
|
72
|
+
evaluation.config = splitJSON_1.configurations && splitJSON_1.configurations[evaluation.treatment] || null;
|
|
74
73
|
}
|
|
75
74
|
}
|
|
76
75
|
return evaluation;
|
package/esm/utils/MinEvents.js
CHANGED
|
@@ -35,12 +35,9 @@ var ReflectApply = R && typeof R.apply === 'function'
|
|
|
35
35
|
: function ReflectApply(target, receiver, args) {
|
|
36
36
|
return Function.prototype.apply.call(target, receiver, args);
|
|
37
37
|
};
|
|
38
|
-
function EventEmitter() {
|
|
38
|
+
export var EventEmitter = function EventEmitter() {
|
|
39
39
|
EventEmitter.init.call(this);
|
|
40
|
-
}
|
|
41
|
-
export default EventEmitter;
|
|
42
|
-
// Backwards-compat with node 0.10.x
|
|
43
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
40
|
+
};
|
|
44
41
|
EventEmitter.prototype._events = undefined;
|
|
45
42
|
EventEmitter.prototype._eventsCount = 0;
|
|
46
43
|
function checkListener(listener) {
|
package/package.json
CHANGED
package/src/evaluator/index.ts
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import Engine from './Engine';
|
|
2
2
|
import thenable from '../utils/promise/thenable';
|
|
3
3
|
import * as LabelsConstants from '../utils/labels';
|
|
4
|
-
import { get } from '../utils/lang';
|
|
5
4
|
import { CONTROL } from '../utils/constants';
|
|
6
5
|
import { ISplit, MaybeThenable } from '../dtos/types';
|
|
7
6
|
import { IStorageAsync, IStorageSync } from '../storages/types';
|
|
@@ -106,17 +105,17 @@ function getEvaluation(
|
|
|
106
105
|
const split = Engine.parse(log, splitJSON, storage);
|
|
107
106
|
evaluation = split.getTreatment(key, attributes, evaluateFeature);
|
|
108
107
|
|
|
109
|
-
// If the storage is async
|
|
108
|
+
// If the storage is async and the evaluated split uses segment, evaluation is thenable
|
|
110
109
|
if (thenable(evaluation)) {
|
|
111
110
|
return evaluation.then(result => {
|
|
112
111
|
result.changeNumber = split.getChangeNumber();
|
|
113
|
-
result.config =
|
|
112
|
+
result.config = splitJSON.configurations && splitJSON.configurations[result.treatment] || null;
|
|
114
113
|
|
|
115
114
|
return result;
|
|
116
115
|
});
|
|
117
116
|
} else {
|
|
118
117
|
evaluation.changeNumber = split.getChangeNumber(); // Always sync and optional
|
|
119
|
-
evaluation.config =
|
|
118
|
+
evaluation.config = splitJSON.configurations && splitJSON.configurations[evaluation.treatment] || null;
|
|
120
119
|
}
|
|
121
120
|
}
|
|
122
121
|
|
package/src/utils/MinEvents.ts
CHANGED
|
@@ -39,14 +39,9 @@ var ReflectApply = R && typeof R.apply === 'function'
|
|
|
39
39
|
return Function.prototype.apply.call(target, receiver, args);
|
|
40
40
|
};
|
|
41
41
|
|
|
42
|
-
function EventEmitter() {
|
|
42
|
+
export const EventEmitter: { new(): IEventEmitter } = function EventEmitter() {
|
|
43
43
|
EventEmitter.init.call(this);
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
export default EventEmitter as new () => IEventEmitter;
|
|
47
|
-
|
|
48
|
-
// Backwards-compat with node 0.10.x
|
|
49
|
-
EventEmitter.EventEmitter = EventEmitter;
|
|
44
|
+
};
|
|
50
45
|
|
|
51
46
|
EventEmitter.prototype._events = undefined;
|
|
52
47
|
EventEmitter.prototype._eventsCount = 0;
|