@pisell/utils 1.0.29 → 1.0.31
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/es/arrayUtils.d.ts +1 -0
- package/es/arrayUtils.js +24 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/es/miniRedux.d.ts +2 -2
- package/es/miniRedux.js +5 -5
- package/lib/arrayUtils.d.ts +1 -0
- package/lib/arrayUtils.js +40 -0
- package/lib/index.d.ts +1 -0
- package/lib/index.js +3 -1
- package/lib/miniRedux.d.ts +2 -2
- package/lib/miniRedux.js +3 -3
- package/package.json +1 -1
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
|
package/es/arrayUtils.js
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
2
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
3
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
4
|
+
export var uniqueByKey = function uniqueByKey(arr, key) {
|
|
5
|
+
var seen = new Set();
|
|
6
|
+
var result = [];
|
|
7
|
+
var _iterator = _createForOfIteratorHelper(arr),
|
|
8
|
+
_step;
|
|
9
|
+
try {
|
|
10
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
11
|
+
var item = _step.value;
|
|
12
|
+
var keyValue = item[key];
|
|
13
|
+
if (!seen.has(keyValue)) {
|
|
14
|
+
seen.add(keyValue);
|
|
15
|
+
result.push(item);
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
} catch (err) {
|
|
19
|
+
_iterator.e(err);
|
|
20
|
+
} finally {
|
|
21
|
+
_iterator.f();
|
|
22
|
+
}
|
|
23
|
+
return result;
|
|
24
|
+
};
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/es/miniRedux.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface MiniReduxProps<State, Namespace> {
|
|
3
3
|
namespace?: Namespace;
|
|
4
4
|
state?: State;
|
|
@@ -12,6 +12,6 @@ export declare const miniRedux: <State extends Record<string, any>, Namespace ex
|
|
|
12
12
|
payload: any;
|
|
13
13
|
}) => void;
|
|
14
14
|
}>;
|
|
15
|
-
Provider: (ComponentUi: any) =>
|
|
15
|
+
Provider: (ComponentUi: any) => React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
|
|
16
16
|
};
|
|
17
17
|
export {};
|
package/es/miniRedux.js
CHANGED
|
@@ -10,11 +10,11 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
10
10
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
11
11
|
function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefined" != typeof Symbol && arr[Symbol.iterator] || arr["@@iterator"]; if (null != _i) { var _s, _e, _x, _r, _arr = [], _n = !0, _d = !1; try { if (_x = (_i = _i.call(arr)).next, 0 === i) { if (Object(_i) !== _i) return; _n = !1; } else for (; !(_n = (_s = _x.call(_i)).done) && (_arr.push(_s.value), _arr.length !== i); _n = !0); } catch (err) { _d = !0, _e = err; } finally { try { if (!_n && null != _i.return && (_r = _i.return(), Object(_r) !== _r)) return; } finally { if (_d) throw _e; } } return _arr; } }
|
|
12
12
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
13
|
-
import React, { createContext, useCallback, useReducer } from
|
|
13
|
+
import React, { createContext, useCallback, useReducer, forwardRef } from 'react';
|
|
14
14
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
15
15
|
export var miniRedux = function miniRedux(_ref2) {
|
|
16
16
|
var _ref2$namespace = _ref2.namespace,
|
|
17
|
-
namespace = _ref2$namespace === void 0 ?
|
|
17
|
+
namespace = _ref2$namespace === void 0 ? 'state' : _ref2$namespace,
|
|
18
18
|
state = _ref2.state,
|
|
19
19
|
_ref2$reducers = _ref2.reducers,
|
|
20
20
|
reducers = _ref2$reducers === void 0 ? {} : _ref2$reducers,
|
|
@@ -22,7 +22,7 @@ export var miniRedux = function miniRedux(_ref2) {
|
|
|
22
22
|
effects = _ref2$effects === void 0 ? {} : _ref2$effects;
|
|
23
23
|
var Context = /*#__PURE__*/createContext({});
|
|
24
24
|
var Provider = function Provider(ComponentUi) {
|
|
25
|
-
var Components = function
|
|
25
|
+
var Components = /*#__PURE__*/forwardRef(function (props, ref) {
|
|
26
26
|
var _objectSpread2, _ref5;
|
|
27
27
|
var _useReducer = useReducer(function (state, _ref3) {
|
|
28
28
|
var type = _ref3.type,
|
|
@@ -57,10 +57,10 @@ export var miniRedux = function miniRedux(_ref2) {
|
|
|
57
57
|
return /*#__PURE__*/_jsx(Context.Provider, {
|
|
58
58
|
value: (_ref5 = {}, _defineProperty(_ref5, namespace, providerState), _defineProperty(_ref5, "dispatch", _dispatch), _ref5),
|
|
59
59
|
children: /*#__PURE__*/_jsx(ComponentUi, _objectSpread(_objectSpread({}, _props), {}, {
|
|
60
|
-
ref:
|
|
60
|
+
ref: ref
|
|
61
61
|
}))
|
|
62
62
|
});
|
|
63
|
-
};
|
|
63
|
+
});
|
|
64
64
|
return Components;
|
|
65
65
|
};
|
|
66
66
|
return {
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const uniqueByKey: <T>(arr: T[], key: keyof T) => T[];
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
3
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
4
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
5
|
+
var __export = (target, all) => {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
+
};
|
|
9
|
+
var __copyProps = (to, from, except, desc) => {
|
|
10
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
+
for (let key of __getOwnPropNames(from))
|
|
12
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
+
}
|
|
15
|
+
return to;
|
|
16
|
+
};
|
|
17
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
+
|
|
19
|
+
// src/arrayUtils.ts
|
|
20
|
+
var arrayUtils_exports = {};
|
|
21
|
+
__export(arrayUtils_exports, {
|
|
22
|
+
uniqueByKey: () => uniqueByKey
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(arrayUtils_exports);
|
|
25
|
+
var uniqueByKey = (arr, key) => {
|
|
26
|
+
const seen = /* @__PURE__ */ new Set();
|
|
27
|
+
const result = [];
|
|
28
|
+
for (const item of arr) {
|
|
29
|
+
const keyValue = item[key];
|
|
30
|
+
if (!seen.has(keyValue)) {
|
|
31
|
+
seen.add(keyValue);
|
|
32
|
+
result.push(item);
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
return result;
|
|
36
|
+
};
|
|
37
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
38
|
+
0 && (module.exports = {
|
|
39
|
+
uniqueByKey
|
|
40
|
+
});
|
package/lib/index.d.ts
CHANGED
package/lib/index.js
CHANGED
|
@@ -28,6 +28,7 @@ __reExport(src_exports, require("./miniRedux"), module.exports);
|
|
|
28
28
|
__reExport(src_exports, require("./jsBridge"), module.exports);
|
|
29
29
|
__reExport(src_exports, require("./image"), module.exports);
|
|
30
30
|
__reExport(src_exports, require("./locales"), module.exports);
|
|
31
|
+
__reExport(src_exports, require("./arrayUtils"), module.exports);
|
|
31
32
|
// Annotate the CommonJS export names for ESM import in node:
|
|
32
33
|
0 && (module.exports = {
|
|
33
34
|
...require("./otherUtils"),
|
|
@@ -41,5 +42,6 @@ __reExport(src_exports, require("./locales"), module.exports);
|
|
|
41
42
|
...require("./miniRedux"),
|
|
42
43
|
...require("./jsBridge"),
|
|
43
44
|
...require("./image"),
|
|
44
|
-
...require("./locales")
|
|
45
|
+
...require("./locales"),
|
|
46
|
+
...require("./arrayUtils")
|
|
45
47
|
});
|
package/lib/miniRedux.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from
|
|
1
|
+
import React from 'react';
|
|
2
2
|
interface MiniReduxProps<State, Namespace> {
|
|
3
3
|
namespace?: Namespace;
|
|
4
4
|
state?: State;
|
|
@@ -12,6 +12,6 @@ export declare const miniRedux: <State extends Record<string, any>, Namespace ex
|
|
|
12
12
|
payload: any;
|
|
13
13
|
}) => void;
|
|
14
14
|
}>;
|
|
15
|
-
Provider: (ComponentUi: any) =>
|
|
15
|
+
Provider: (ComponentUi: any) => React.ForwardRefExoticComponent<Pick<any, string | number | symbol> & React.RefAttributes<unknown>>;
|
|
16
16
|
};
|
|
17
17
|
export {};
|
package/lib/miniRedux.js
CHANGED
|
@@ -41,7 +41,7 @@ var miniRedux = ({
|
|
|
41
41
|
}) => {
|
|
42
42
|
const Context = (0, import_react.createContext)({});
|
|
43
43
|
const Provider = (ComponentUi) => {
|
|
44
|
-
const Components = (props) => {
|
|
44
|
+
const Components = (0, import_react.forwardRef)((props, ref) => {
|
|
45
45
|
const [providerState, dispatch] = (0, import_react.useReducer)(
|
|
46
46
|
(state2, { type, payload }) => {
|
|
47
47
|
if (reducers[type]) {
|
|
@@ -74,9 +74,9 @@ var miniRedux = ({
|
|
|
74
74
|
{
|
|
75
75
|
value: { [namespace]: providerState, dispatch: _dispatch }
|
|
76
76
|
},
|
|
77
|
-
/* @__PURE__ */ import_react.default.createElement(ComponentUi, { ..._props, ref
|
|
77
|
+
/* @__PURE__ */ import_react.default.createElement(ComponentUi, { ..._props, ref })
|
|
78
78
|
);
|
|
79
|
-
};
|
|
79
|
+
});
|
|
80
80
|
return Components;
|
|
81
81
|
};
|
|
82
82
|
return {
|