@karmaniverous/jsonmap 0.2.5 → 0.2.6
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.
|
@@ -18,6 +18,7 @@ var _lodash11 = _interopRequireDefault(require("lodash.mapvalues"));
|
|
|
18
18
|
var _lodash12 = _interopRequireDefault(require("lodash.pickby"));
|
|
19
19
|
var _lodash13 = _interopRequireDefault(require("lodash.set"));
|
|
20
20
|
var _lodash14 = _interopRequireDefault(require("lodash.size"));
|
|
21
|
+
var _lodash15 = _interopRequireDefault(require("lodash.sortby"));
|
|
21
22
|
var _nanoid = require("nanoid");
|
|
22
23
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
23
24
|
// npm imports
|
|
@@ -153,8 +154,11 @@ class JsonMap {
|
|
|
153
154
|
// Creates an empty array or object based on whether the current node is an array or not
|
|
154
155
|
const transformedNode = (0, _lodash5.default)(node) ? [] : {};
|
|
155
156
|
|
|
156
|
-
// Iterates over each key-value pair in the current node
|
|
157
|
-
for (const [key, value] of Object.entries(node)
|
|
157
|
+
// Iterates over each key-value pair in the current node in ascending order by key
|
|
158
|
+
for (const [key, value] of (0, _lodash15.default)(Object.entries(node), _ref => {
|
|
159
|
+
let [key] = _ref;
|
|
160
|
+
return key;
|
|
161
|
+
})) {
|
|
158
162
|
// Constructs the current path by appending the current key to the previous path (if any)
|
|
159
163
|
const currentPath = path ? `${path}.${key}` : key;
|
|
160
164
|
|
|
@@ -198,20 +202,20 @@ class JsonMap {
|
|
|
198
202
|
|
|
199
203
|
// Defines special patterns and their corresponding resolution functions
|
|
200
204
|
const patterns = {
|
|
201
|
-
'^\\$\\.(?<obj>lib|input|output)\\.?(?<path>.*)':
|
|
205
|
+
'^\\$\\.(?<obj>lib|input|output)\\.?(?<path>.*)': _ref2 => {
|
|
202
206
|
let {
|
|
203
207
|
obj,
|
|
204
208
|
path
|
|
205
|
-
} =
|
|
209
|
+
} = _ref2;
|
|
206
210
|
return {
|
|
207
211
|
obj: this[obj],
|
|
208
212
|
path
|
|
209
213
|
};
|
|
210
214
|
},
|
|
211
|
-
'^\\$(?<path>\\[\\d+\\].*)':
|
|
215
|
+
'^\\$(?<path>\\[\\d+\\].*)': _ref3 => {
|
|
212
216
|
let {
|
|
213
217
|
path
|
|
214
|
-
} =
|
|
218
|
+
} = _ref3;
|
|
215
219
|
return {
|
|
216
220
|
obj: results,
|
|
217
221
|
path
|
package/lib/JsonMap/JsonMap.js
CHANGED
|
@@ -13,6 +13,7 @@ import mapValues from 'lodash.mapvalues';
|
|
|
13
13
|
import pickBy from 'lodash.pickby';
|
|
14
14
|
import set from 'lodash.set';
|
|
15
15
|
import size from 'lodash.size';
|
|
16
|
+
import sortBy from 'lodash.sortby';
|
|
16
17
|
import { nanoid } from 'nanoid';
|
|
17
18
|
|
|
18
19
|
const getJsonFns = () => {
|
|
@@ -156,8 +157,8 @@ class JsonMap {
|
|
|
156
157
|
// Creates an empty array or object based on whether the current node is an array or not
|
|
157
158
|
const transformedNode = isArray(node) ? [] : {};
|
|
158
159
|
|
|
159
|
-
// Iterates over each key-value pair in the current node
|
|
160
|
-
for (const [key, value] of Object.entries(node)) {
|
|
160
|
+
// Iterates over each key-value pair in the current node in ascending order by key
|
|
161
|
+
for (const [key, value] of sortBy(Object.entries(node), ([key]) => key)) {
|
|
161
162
|
// Constructs the current path by appending the current key to the previous path (if any)
|
|
162
163
|
const currentPath = path ? `${path}.${key}` : key;
|
|
163
164
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karmaniverous/jsonmap",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.6",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
"lodash.pickby": "^4.6.0",
|
|
37
37
|
"lodash.set": "^4.3.2",
|
|
38
38
|
"lodash.size": "^4.2.0",
|
|
39
|
+
"lodash.sortby": "^4.7.0",
|
|
39
40
|
"nanoid": "^4.0.2"
|
|
40
41
|
},
|
|
41
42
|
"devDependencies": {
|