@karmaniverous/entity-manager 2.2.0 → 2.2.1
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/README.md
CHANGED
|
@@ -315,7 +315,7 @@ Condense an index object into a delimited string.
|
|
|
315
315
|
| Param | Type | Default | Description |
|
|
316
316
|
| --- | --- | --- | --- |
|
|
317
317
|
| entityToken | <code>string</code> | | Entity token. |
|
|
318
|
-
| indexToken | <code>string</code> | | Index token. |
|
|
318
|
+
| indexToken | <code>string</code> \| <code>Array.<string></code> | | Index token or array of key tokens. |
|
|
319
319
|
| index | <code>object</code> | | Index object. |
|
|
320
320
|
| [delimiter] | <code>string</code> | <code>"~"</code> | Delimiter. |
|
|
321
321
|
|
|
@@ -5,7 +5,6 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
5
5
|
});
|
|
6
6
|
exports.EntityManager = void 0;
|
|
7
7
|
var _zipObject2 = _interopRequireDefault(require("lodash/zipObject"));
|
|
8
|
-
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
|
|
9
8
|
var _map2 = _interopRequireDefault(require("lodash/map"));
|
|
10
9
|
var _size2 = _interopRequireDefault(require("lodash/size"));
|
|
11
10
|
var _isEmpty2 = _interopRequireDefault(require("lodash/isEmpty"));
|
|
@@ -18,6 +17,7 @@ var _entries2 = _interopRequireDefault(require("lodash/entries"));
|
|
|
18
17
|
var _sortBy2 = _interopRequireDefault(require("lodash/sortBy"));
|
|
19
18
|
var _sortedUniqBy2 = _interopRequireDefault(require("lodash/sortedUniqBy"));
|
|
20
19
|
var _isFunction2 = _interopRequireDefault(require("lodash/isFunction"));
|
|
20
|
+
var _isArray2 = _interopRequireDefault(require("lodash/isArray"));
|
|
21
21
|
var _forEach2 = _interopRequireDefault(require("lodash/forEach"));
|
|
22
22
|
var _isNil2 = _interopRequireDefault(require("lodash/isNil"));
|
|
23
23
|
var _cloneDeep2 = _interopRequireDefault(require("lodash/cloneDeep"));
|
|
@@ -130,7 +130,7 @@ class EntityManager {
|
|
|
130
130
|
* Condense an index object into a delimited string.
|
|
131
131
|
*
|
|
132
132
|
* @param {string} entityToken - Entity token.
|
|
133
|
-
* @param {string} indexToken - Index token.
|
|
133
|
+
* @param {string|string[]} indexToken - Index token or array of key tokens.
|
|
134
134
|
* @param {object} index - Index object.
|
|
135
135
|
* @param {string} [delimiter] - Delimiter.
|
|
136
136
|
* @returns {string} Dehydrated index.
|
|
@@ -142,7 +142,7 @@ class EntityManager {
|
|
|
142
142
|
let delimiter = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : '~';
|
|
143
143
|
// Validate item.
|
|
144
144
|
_classPrivateFieldGet(this, _entityManager).validateItem(index);
|
|
145
|
-
const indexComponents = _classPrivateFieldGet(this, _entityManager).getIndexComponents(entityToken, indexToken);
|
|
145
|
+
const indexComponents = (0, _isArray2.default)(indexToken) ? indexToken : _classPrivateFieldGet(this, _entityManager).getIndexComponents(entityToken, indexToken);
|
|
146
146
|
const indexProperties = indexComponents.reduce((properties, component) => {
|
|
147
147
|
const {
|
|
148
148
|
decode
|
|
@@ -93,7 +93,7 @@ export class EntityManager {
|
|
|
93
93
|
* Condense an index object into a delimited string.
|
|
94
94
|
*
|
|
95
95
|
* @param {string} entityToken - Entity token.
|
|
96
|
-
* @param {string} indexToken - Index token.
|
|
96
|
+
* @param {string|string[]} indexToken - Index token or array of key tokens.
|
|
97
97
|
* @param {object} index - Index object.
|
|
98
98
|
* @param {string} [delimiter] - Delimiter.
|
|
99
99
|
* @returns {string} Dehydrated index.
|
|
@@ -105,10 +105,9 @@ export class EntityManager {
|
|
|
105
105
|
// Validate item.
|
|
106
106
|
this.#entityManager.validateItem(index);
|
|
107
107
|
|
|
108
|
-
const indexComponents =
|
|
109
|
-
|
|
110
|
-
indexToken
|
|
111
|
-
);
|
|
108
|
+
const indexComponents = _.isArray(indexToken)
|
|
109
|
+
? indexToken
|
|
110
|
+
: this.#entityManager.getIndexComponents(entityToken, indexToken);
|
|
112
111
|
|
|
113
112
|
const indexProperties = indexComponents.reduce((properties, component) => {
|
|
114
113
|
const { decode } = this.#entityManager.getKey(entityToken, component);
|