summaryrefslogtreecommitdiff
path: root/node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js
diff options
context:
space:
mode:
authorrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
committerrxliuli <rxliuli@gmail.com>2025-11-04 05:03:50 +0800
commitbce557cc2dc767628bed6aac87301a1be7c5431b (patch)
treeb51a051228d01fe3306cd7626d4a96768aadb944 /node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js
init commit
Diffstat (limited to 'node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js')
-rw-r--r--node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js32
1 files changed, 32 insertions, 0 deletions
diff --git a/node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js b/node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js
new file mode 100644
index 0000000..57c8e84
--- /dev/null
+++ b/node_modules/@jet-app/app-store/tmp/src/foundation/util/array-util.js
@@ -0,0 +1,32 @@
+/**
+ * Creates an array containing multiple copies of the elements of another array.
+ *
+ * For example, if A = [Q, W, E, R, T, Y], then calling repeating(A, 3) would return
+ * [Q, W, E, R, T, Y, Q, W, E, R, T, Y, Q, W, E, R, T, Y]
+ *
+ * @param elements The elements that will be repeated
+ * @param times The number of times all of the elements should appear in the new array.
+ */
+export function arrayByRepeating(elements, times) {
+ if (times <= 0) {
+ return [];
+ }
+ let newArray = [];
+ for (let i = 0; i < times; i++) {
+ newArray = newArray.concat(elements);
+ }
+ return newArray;
+}
+export function partition(array, predicate) {
+ const part1 = [];
+ const part2 = [];
+ array.forEach((item) => (predicate(item) ? part1.push(item) : part2.push(item)));
+ return [part1, part2];
+}
+export function isEmpty(elements) {
+ return elements.length === 0;
+}
+export function isNotEmpty(elements) {
+ return !isEmpty(elements);
+}
+//# sourceMappingURL=array-util.js.map \ No newline at end of file