bfg-common 1.4.7 → 1.4.8
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/package.json +1 -1
- package/plugins/recursion.ts +18 -0
package/package.json
CHANGED
package/plugins/recursion.ts
CHANGED
|
@@ -282,6 +282,24 @@ export default defineNuxtPlugin(() => {
|
|
|
282
282
|
}
|
|
283
283
|
}
|
|
284
284
|
|
|
285
|
+
self.calcCount = function (
|
|
286
|
+
arr: any[],
|
|
287
|
+
itemsProp: string
|
|
288
|
+
): number {
|
|
289
|
+
if (!arr) return 0
|
|
290
|
+
let res = 0
|
|
291
|
+
|
|
292
|
+
for (let i = 0; i < arr.length; i++) {
|
|
293
|
+
const item: any = arr[i]
|
|
294
|
+
res++
|
|
295
|
+
|
|
296
|
+
if (item[itemsProp]?.length) {
|
|
297
|
+
res += self.findAndRemove(item[itemsProp], itemsProp)
|
|
298
|
+
}
|
|
299
|
+
}
|
|
300
|
+
return res
|
|
301
|
+
}
|
|
302
|
+
|
|
285
303
|
return self
|
|
286
304
|
}.call({})
|
|
287
305
|
|