@3plus/redux-api 1.1.0 → 1.1.3
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/lib/PubSub.js +16 -39
- package/lib/actionFn.js +156 -210
- package/lib/adapters/fetch.js +20 -27
- package/lib/async.js +6 -17
- package/lib/createHolder.js +8 -13
- package/lib/fetchResolver.js +3 -13
- package/lib/helpers.js +15 -43
- package/lib/index.js +72 -90
- package/lib/reducerFn.js +52 -50
- package/lib/transformers.js +7 -12
- package/lib/urlTransform.js +43 -50
- package/lib/utils/cache.js +29 -35
- package/lib/utils/get.js +3 -19
- package/lib/utils/merge.js +8 -18
- package/lib/utils/omit.js +6 -17
- package/package.json +6 -7
- package/module/PubSub.js +0 -39
- package/module/actionFn.js +0 -373
- package/module/adapters/fetch.js +0 -40
- package/module/async.js +0 -21
- package/module/createHolder.js +0 -27
- package/module/fetchResolver.js +0 -15
- package/module/helpers.js +0 -54
- package/module/index.js +0 -127
- package/module/reducerFn.js +0 -74
- package/module/transformers.js +0 -17
- package/module/urlTransform.js +0 -65
- package/module/utils/cache.js +0 -84
- package/module/utils/get.js +0 -19
- package/module/utils/merge.js +0 -32
- package/module/utils/omit.js +0 -17
package/lib/urlTransform.js
CHANGED
|
@@ -1,30 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
var _omit = _interopRequireDefault(require("./utils/omit"));
|
|
9
|
-
var _merge = _interopRequireDefault(require("./utils/merge"));
|
|
10
|
-
function _interopRequireDefault(e) { return e && e.__esModule ? e : { "default": e }; }
|
|
11
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
12
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
13
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
14
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
15
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
16
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
-
var rxClean = /(\(:[^\)]+\)|:[^\/]+\/?)/g;
|
|
18
|
-
function urlTransform(url, params, options) {
|
|
3
|
+
import * as qs from "qs";
|
|
4
|
+
import omit from "./utils/omit";
|
|
5
|
+
import merge from "./utils/merge";
|
|
6
|
+
const rxClean = /(\(:[^\)]+\)|:[^\/]+\/?)/g;
|
|
7
|
+
export default function urlTransform(url, params, options) {
|
|
19
8
|
if (!url) {
|
|
20
9
|
return "";
|
|
21
10
|
}
|
|
22
11
|
params || (params = {});
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
return url.replace(rx,
|
|
12
|
+
const usedKeys = {};
|
|
13
|
+
const urlWithParams = Object.keys(params).reduce((url, key) => {
|
|
14
|
+
const value = params[key];
|
|
15
|
+
const rx = new RegExp(`(\\(:${key}\\)|:${key})(\/?)`, "g");
|
|
16
|
+
return url.replace(rx, (_, _1, slash) => {
|
|
28
17
|
usedKeys[key] = value;
|
|
29
18
|
return value ? value + slash : value;
|
|
30
19
|
});
|
|
@@ -32,40 +21,44 @@ function urlTransform(url, params, options) {
|
|
|
32
21
|
if (!urlWithParams) {
|
|
33
22
|
return urlWithParams;
|
|
34
23
|
}
|
|
35
|
-
|
|
24
|
+
let protocol, host, pathname;
|
|
36
25
|
try {
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
26
|
+
({
|
|
27
|
+
protocol,
|
|
28
|
+
host,
|
|
29
|
+
pathname
|
|
30
|
+
} = new URL(urlWithParams));
|
|
41
31
|
} catch (error) {
|
|
42
|
-
|
|
32
|
+
({
|
|
33
|
+
protocol,
|
|
34
|
+
host,
|
|
35
|
+
pathname
|
|
36
|
+
} = {
|
|
43
37
|
pathname: urlWithParams
|
|
44
|
-
};
|
|
45
|
-
protocol = _pathname.protocol;
|
|
46
|
-
host = _pathname.host;
|
|
47
|
-
pathname = _pathname.pathname;
|
|
38
|
+
});
|
|
48
39
|
}
|
|
49
|
-
|
|
50
|
-
|
|
40
|
+
const cleanURL = host ? `${protocol}//${host}${pathname.replace(rxClean, "")}` : pathname.replace(rxClean, "");
|
|
41
|
+
const usedKeysArray = Object.keys(usedKeys);
|
|
51
42
|
if (usedKeysArray.length !== Object.keys(params).length) {
|
|
52
|
-
|
|
43
|
+
const urlObject = cleanURL.split("?");
|
|
53
44
|
options || (options = {});
|
|
54
|
-
|
|
55
|
-
arrayFormat
|
|
56
|
-
delimiter
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
45
|
+
const {
|
|
46
|
+
arrayFormat,
|
|
47
|
+
delimiter
|
|
48
|
+
} = options;
|
|
49
|
+
const qsParseOptions = {
|
|
50
|
+
arrayFormat,
|
|
51
|
+
delimiter,
|
|
52
|
+
...options.qsParseOptions
|
|
53
|
+
};
|
|
54
|
+
const mergeParams = merge(urlObject[1] && qs.parse(urlObject[1], qsParseOptions), omit(params, usedKeysArray));
|
|
55
|
+
const qsStringifyOptions = {
|
|
56
|
+
arrayFormat,
|
|
57
|
+
delimiter,
|
|
58
|
+
...options.qsStringifyOptions
|
|
59
|
+
};
|
|
60
|
+
const urlStringParams = qs.stringify(mergeParams, qsStringifyOptions);
|
|
61
|
+
return `${urlObject[0]}?${urlStringParams}`;
|
|
68
62
|
}
|
|
69
63
|
return cleanURL;
|
|
70
|
-
}
|
|
71
|
-
module.exports = exports.default;
|
|
64
|
+
}
|
package/lib/utils/cache.js
CHANGED
|
@@ -1,26 +1,11 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports.MockNowDate = exports.Manager = void 0;
|
|
7
|
-
exports["default"] = _default;
|
|
8
|
-
exports.getCacheManager = getCacheManager;
|
|
9
|
-
exports.setExpire = setExpire;
|
|
10
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
11
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
14
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
15
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
16
|
-
var MockNowDate = exports.MockNowDate = {
|
|
1
|
+
export const MockNowDate = {
|
|
17
2
|
date: undefined,
|
|
18
|
-
push
|
|
3
|
+
push(date) {
|
|
19
4
|
this.date = date;
|
|
20
5
|
},
|
|
21
|
-
pop
|
|
6
|
+
pop() {
|
|
22
7
|
if (this.date) {
|
|
23
|
-
|
|
8
|
+
const d = this.date;
|
|
24
9
|
this.date = undefined;
|
|
25
10
|
return new Date(d);
|
|
26
11
|
} else {
|
|
@@ -28,14 +13,16 @@ var MockNowDate = exports.MockNowDate = {
|
|
|
28
13
|
}
|
|
29
14
|
}
|
|
30
15
|
};
|
|
31
|
-
|
|
16
|
+
export const Manager = {
|
|
32
17
|
expire: false,
|
|
33
|
-
getData
|
|
18
|
+
getData(cache) {
|
|
34
19
|
if (!cache) {
|
|
35
20
|
return;
|
|
36
21
|
}
|
|
37
|
-
|
|
38
|
-
|
|
22
|
+
const {
|
|
23
|
+
expire,
|
|
24
|
+
data
|
|
25
|
+
} = cache;
|
|
39
26
|
if (expire === false || expire === undefined || expire === null) {
|
|
40
27
|
return data;
|
|
41
28
|
}
|
|
@@ -45,19 +32,17 @@ var Manager = exports.Manager = {
|
|
|
45
32
|
}
|
|
46
33
|
}
|
|
47
34
|
},
|
|
48
|
-
id
|
|
35
|
+
id(params) {
|
|
49
36
|
if (!params) {
|
|
50
37
|
return "";
|
|
51
38
|
}
|
|
52
|
-
return Object.keys(params).reduce(
|
|
53
|
-
return memo + "".concat(key, "=").concat(params[key], ";");
|
|
54
|
-
}, "");
|
|
39
|
+
return Object.keys(params).reduce((memo, key) => memo + `${key}=${params[key]};`, "");
|
|
55
40
|
}
|
|
56
41
|
};
|
|
57
|
-
function setExpire(value, oldDate) {
|
|
58
|
-
|
|
42
|
+
export function setExpire(value, oldDate) {
|
|
43
|
+
let expire = value;
|
|
59
44
|
if (typeof expire === "number" || expire instanceof Number) {
|
|
60
|
-
|
|
45
|
+
const d = MockNowDate.pop();
|
|
61
46
|
d.setSeconds(d.getSeconds() + expire);
|
|
62
47
|
expire = d;
|
|
63
48
|
}
|
|
@@ -68,26 +53,35 @@ function setExpire(value, oldDate) {
|
|
|
68
53
|
}
|
|
69
54
|
return expire;
|
|
70
55
|
}
|
|
71
|
-
function getCacheManager(expire, cache) {
|
|
56
|
+
export function getCacheManager(expire, cache) {
|
|
72
57
|
if (expire !== undefined) {
|
|
73
|
-
|
|
58
|
+
const ret = {
|
|
59
|
+
...Manager,
|
|
60
|
+
...cache
|
|
61
|
+
};
|
|
74
62
|
if (ret.expire !== false) {
|
|
75
63
|
ret.expire = setExpire(expire, ret.expire);
|
|
76
64
|
}
|
|
77
65
|
return ret;
|
|
78
66
|
} else if (cache) {
|
|
79
|
-
return
|
|
67
|
+
return {
|
|
68
|
+
...Manager,
|
|
69
|
+
...cache
|
|
70
|
+
};
|
|
80
71
|
} else {
|
|
81
72
|
return null;
|
|
82
73
|
}
|
|
83
74
|
}
|
|
84
|
-
function
|
|
75
|
+
export default function (cache) {
|
|
85
76
|
if (!cache) {
|
|
86
77
|
return null;
|
|
87
78
|
}
|
|
88
79
|
if (cache === true) {
|
|
89
80
|
return Manager;
|
|
90
81
|
} else {
|
|
91
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
...Manager,
|
|
84
|
+
...cache
|
|
85
|
+
};
|
|
92
86
|
}
|
|
93
87
|
}
|
package/lib/utils/get.js
CHANGED
|
@@ -1,24 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
value: true
|
|
4
|
-
});
|
|
5
|
-
exports["default"] = void 0;
|
|
6
|
-
function _toConsumableArray(r) { return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread(); }
|
|
7
|
-
function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
8
|
-
function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
|
|
9
|
-
function _iterableToArray(r) { if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r); }
|
|
10
|
-
function _arrayWithoutHoles(r) { if (Array.isArray(r)) return _arrayLikeToArray(r); }
|
|
11
|
-
function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
|
|
12
2
|
function isEmpty(name) {
|
|
13
3
|
return name === "" || name === null || name === void 0;
|
|
14
4
|
}
|
|
15
|
-
function get(obj) {
|
|
16
|
-
|
|
17
|
-
path[_key - 1] = arguments[_key];
|
|
18
|
-
}
|
|
19
|
-
return path.reduce(function (memo, name) {
|
|
20
|
-
return Array.isArray(name) ? get.apply(void 0, [memo].concat(_toConsumableArray(name))) : isEmpty(name) ? memo : memo && memo[name];
|
|
21
|
-
}, obj);
|
|
5
|
+
function get(obj, ...path) {
|
|
6
|
+
return path.reduce((memo, name) => Array.isArray(name) ? get(memo, ...name) : isEmpty(name) ? memo : memo && memo[name], obj);
|
|
22
7
|
}
|
|
23
|
-
|
|
24
|
-
module.exports = exports.default;
|
|
8
|
+
export default get;
|
package/lib/utils/merge.js
CHANGED
|
@@ -1,22 +1,15 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = _default;
|
|
7
|
-
exports.mergePair = mergePair;
|
|
8
|
-
var toString = Object.prototype.toString;
|
|
9
|
-
var OBJECT = "[object Object]";
|
|
10
|
-
var ARRAY = "[object Array]";
|
|
11
|
-
function mergePair(a, b) {
|
|
1
|
+
const toString = Object.prototype.toString;
|
|
2
|
+
const OBJECT = "[object Object]";
|
|
3
|
+
const ARRAY = "[object Array]";
|
|
4
|
+
export function mergePair(a, b) {
|
|
12
5
|
if (a === void 0) {
|
|
13
6
|
return b;
|
|
14
7
|
}
|
|
15
8
|
if (b === void 0) {
|
|
16
9
|
return a;
|
|
17
10
|
}
|
|
18
|
-
|
|
19
|
-
|
|
11
|
+
const aType = toString.call(a);
|
|
12
|
+
const bType = toString.call(b);
|
|
20
13
|
if (aType === ARRAY) {
|
|
21
14
|
return a.concat(b);
|
|
22
15
|
}
|
|
@@ -26,14 +19,11 @@ function mergePair(a, b) {
|
|
|
26
19
|
if (aType !== OBJECT || bType !== OBJECT) {
|
|
27
20
|
return b;
|
|
28
21
|
}
|
|
29
|
-
return Object.keys(b).reduce(
|
|
22
|
+
return Object.keys(b).reduce((memo, key) => {
|
|
30
23
|
memo[key] = mergePair(a[key], b[key]);
|
|
31
24
|
return memo;
|
|
32
25
|
}, a);
|
|
33
26
|
}
|
|
34
|
-
function
|
|
35
|
-
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
36
|
-
args[_key] = arguments[_key];
|
|
37
|
-
}
|
|
27
|
+
export default function (...args) {
|
|
38
28
|
return args.length ? args.reduce(mergePair) : null;
|
|
39
29
|
}
|
package/lib/utils/omit.js
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
Object.defineProperty(exports, "__esModule", {
|
|
4
|
-
value: true
|
|
5
|
-
});
|
|
6
|
-
exports["default"] = _default;
|
|
7
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
8
|
-
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
9
|
-
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
10
|
-
function _defineProperty(e, r, t) { return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, { value: t, enumerable: !0, configurable: !0, writable: !0 }) : e[r] = t, e; }
|
|
11
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
12
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
13
|
-
function _default(object, props) {
|
|
1
|
+
export default function (object, props) {
|
|
14
2
|
if (!Array.isArray(props)) {
|
|
15
|
-
return
|
|
3
|
+
return {
|
|
4
|
+
...object
|
|
5
|
+
};
|
|
16
6
|
}
|
|
17
|
-
return Object.keys(object || {}).reduce(
|
|
7
|
+
return Object.keys(object || {}).reduce((memo, key) => {
|
|
18
8
|
if (props.indexOf(key) === -1) {
|
|
19
9
|
memo[key] = object[key];
|
|
20
10
|
}
|
|
21
11
|
return memo;
|
|
22
12
|
}, {});
|
|
23
|
-
}
|
|
24
|
-
module.exports = exports.default;
|
|
13
|
+
}
|
package/package.json
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@3plus/redux-api",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.3",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "Efremov Alex",
|
|
6
6
|
"email": "lexich121@gmail.com",
|
|
7
7
|
"url": "https://github.com/lexich"
|
|
8
8
|
},
|
|
9
9
|
"main": "lib/index.js",
|
|
10
|
-
"
|
|
10
|
+
"type": "module",
|
|
11
11
|
"license": "MIT",
|
|
12
12
|
"description": "Flux REST API for redux infrastructure",
|
|
13
13
|
"repository": "http://github.com/3plus/redux-api",
|
|
14
|
+
"engines": {
|
|
15
|
+
"node": ">=18.0.0"
|
|
16
|
+
},
|
|
14
17
|
"scripts": {
|
|
15
18
|
"test": "npm run eslint && npm run mocha",
|
|
16
19
|
"mocha": "mocha --require @babel/register test/*_spec.js",
|
|
17
|
-
"build": "
|
|
18
|
-
"build:node": "babel src --out-dir lib --env-name node --no-comments --delete-dir-on-start --verbose",
|
|
19
|
-
"build:module": "babel src --out-dir module --env-name module --no-comments --delete-dir-on-start --verbose",
|
|
20
|
+
"build": "babel src --out-dir lib --no-comments --delete-dir-on-start --verbose",
|
|
20
21
|
"lint": "eslint --quiet ./src",
|
|
21
22
|
"lint:fix": "npm run lint -- --fix",
|
|
22
23
|
"prettier:fix": "prettier --write './src/**/*.js'",
|
|
@@ -31,7 +32,6 @@
|
|
|
31
32
|
"@babel/core": "^7.8.4",
|
|
32
33
|
"@babel/eslint-parser": "^7.24.7",
|
|
33
34
|
"@babel/preset-env": "^7.8.4",
|
|
34
|
-
"babel-plugin-add-module-exports": "^1.0.4",
|
|
35
35
|
"chai": "4.2.0",
|
|
36
36
|
"eslint": "^8.2.0",
|
|
37
37
|
"eslint-config-airbnb": "19.0.4",
|
|
@@ -60,7 +60,6 @@
|
|
|
60
60
|
"files": [
|
|
61
61
|
"LICENSE.md",
|
|
62
62
|
"README.md",
|
|
63
|
-
"module",
|
|
64
63
|
"lib"
|
|
65
64
|
]
|
|
66
65
|
}
|
package/module/PubSub.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
|
|
3
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
4
|
-
function _classCallCheck(a, n) { if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function"); }
|
|
5
|
-
function _defineProperties(e, r) { for (var t = 0; t < r.length; t++) { var o = r[t]; o.enumerable = o.enumerable || !1, o.configurable = !0, "value" in o && (o.writable = !0), Object.defineProperty(e, _toPropertyKey(o.key), o); } }
|
|
6
|
-
function _createClass(e, r, t) { return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", { writable: !1 }), e; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : i + ""; }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
-
var PubSub = function () {
|
|
10
|
-
function PubSub() {
|
|
11
|
-
_classCallCheck(this, PubSub);
|
|
12
|
-
this.container = [];
|
|
13
|
-
}
|
|
14
|
-
return _createClass(PubSub, [{
|
|
15
|
-
key: "push",
|
|
16
|
-
value: function push(cb) {
|
|
17
|
-
cb instanceof Function && this.container.push(cb);
|
|
18
|
-
}
|
|
19
|
-
}, {
|
|
20
|
-
key: "resolve",
|
|
21
|
-
value: function resolve(data) {
|
|
22
|
-
var container = this.container;
|
|
23
|
-
this.container = [];
|
|
24
|
-
container.forEach(function (cb) {
|
|
25
|
-
return cb(null, data);
|
|
26
|
-
});
|
|
27
|
-
}
|
|
28
|
-
}, {
|
|
29
|
-
key: "reject",
|
|
30
|
-
value: function reject(err) {
|
|
31
|
-
var container = this.container;
|
|
32
|
-
this.container = [];
|
|
33
|
-
container.forEach(function (cb) {
|
|
34
|
-
return cb(err);
|
|
35
|
-
});
|
|
36
|
-
}
|
|
37
|
-
}]);
|
|
38
|
-
}();
|
|
39
|
-
export { PubSub as default };
|