onchain-utility 0.0.11 → 0.0.12

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.
@@ -1231,7 +1231,12 @@ function getSiblings({
1231
1231
  return item[signKey] === key;
1232
1232
  }
1233
1233
  });
1234
- const keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
1234
+ let keys = [];
1235
+ if (data.length === 1) {
1236
+ keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
1237
+ } else {
1238
+ keys = (parent ? parent[childrenKey] : data).map(item => item[signKey]);
1239
+ }
1235
1240
  return keys;
1236
1241
  }
1237
1242
 
@@ -1229,7 +1229,12 @@ function getSiblings({
1229
1229
  return item[signKey] === key;
1230
1230
  }
1231
1231
  });
1232
- const keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
1232
+ let keys = [];
1233
+ if (data.length === 1) {
1234
+ keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
1235
+ } else {
1236
+ keys = (parent ? parent[childrenKey] : data).map(item => item[signKey]);
1237
+ }
1233
1238
  return keys;
1234
1239
  }
1235
1240
 
package/dist/Tree.js CHANGED
@@ -210,7 +210,12 @@ function getSiblings({
210
210
  return item[signKey] === key;
211
211
  }
212
212
  });
213
- const keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
213
+ let keys = [];
214
+ if (data.length === 1) {
215
+ keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
216
+ } else {
217
+ keys = (parent ? parent[childrenKey] : data).map(item => item[signKey]);
218
+ }
214
219
  return keys;
215
220
  }
216
221
 
package/dist/Tree.mjs CHANGED
@@ -208,7 +208,12 @@ function getSiblings({
208
208
  return item[signKey] === key;
209
209
  }
210
210
  });
211
- const keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
211
+ let keys = [];
212
+ if (data.length === 1) {
213
+ keys = parent ? parent[childrenKey].map(item => item[signKey]) : [];
214
+ } else {
215
+ keys = (parent ? parent[childrenKey] : data).map(item => item[signKey]);
216
+ }
212
217
  return keys;
213
218
  }
214
219
 
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "onchain-utility",
3
3
  "description": "This package contains misc utilities for onchain.",
4
4
  "license": "MIT",
5
- "version": "0.0.11",
5
+ "version": "0.0.12",
6
6
  "files": [
7
7
  "dist",
8
8
  "src"
package/src/Tree/index.ts CHANGED
@@ -258,9 +258,16 @@ export function getSiblings<T extends Item>({
258
258
  return item[signKey] === key;
259
259
  },
260
260
  });
261
- const keys: string[] = parent
262
- ? (parent[childrenKey] as T[]).map((item) => item[signKey])
263
- : [];
261
+ let keys: string[] = [];
262
+ if (data.length === 1) {
263
+ keys = parent
264
+ ? (parent[childrenKey] as T[]).map((item) => item[signKey])
265
+ : [];
266
+ } else {
267
+ keys = (parent ? (parent[childrenKey] as T[]) : data).map(
268
+ (item) => item[signKey],
269
+ );
270
+ }
264
271
  return keys;
265
272
  }
266
273