1 | export var NOOP = function () { };
|
2 | export var IDENTITY = function (_) { return _; };
|
3 | export function fail(message) {
|
4 | throw new Error("[mobx-utils] " + message);
|
5 | }
|
6 | export function invariant(cond, message) {
|
7 | if (message === void 0) { message = "Illegal state"; }
|
8 | if (!cond)
|
9 | fail(message);
|
10 | }
|
11 | export function addHiddenProp(object, propName, value) {
|
12 | Object.defineProperty(object, propName, {
|
13 | enumerable: false,
|
14 | writable: true,
|
15 | configurable: true,
|
16 | value: value,
|
17 | });
|
18 | }
|
19 | var deepFields = function (x) {
|
20 | return (x &&
|
21 | x !== Object.prototype &&
|
22 | Object.getOwnPropertyNames(x).concat(deepFields(Object.getPrototypeOf(x)) || []));
|
23 | };
|
24 | var distinctDeepFields = function (x) {
|
25 | var deepFieldsIndistinct = deepFields(x);
|
26 | var deepFieldsDistinct = deepFieldsIndistinct.filter(function (item, index) { return deepFieldsIndistinct.indexOf(item) === index; });
|
27 | return deepFieldsDistinct;
|
28 | };
|
29 | export var getAllMethodsAndProperties = function (x) {
|
30 | return distinctDeepFields(x).filter(function (name) { return name !== "constructor" && !~name.indexOf("__"); });
|
31 | };
|