@wavy/fn 0.0.14 → 0.0.15
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/dist/main.cjs +7 -6
- package/dist/main.js +7 -6
- package/package.json +1 -1
- package/prepend.js +0 -14
- package/publish.js +0 -37
package/dist/main.cjs
CHANGED
|
@@ -659,9 +659,10 @@ function undefinedIfEmpty(value) {
|
|
|
659
659
|
if (value.length > 0) return value;
|
|
660
660
|
}
|
|
661
661
|
function ifEmpty(value, fallback) {
|
|
662
|
-
return isEmpty(value) ? fallback : value;
|
|
662
|
+
return isEmpty(value) || !value ? fallback : value;
|
|
663
663
|
}
|
|
664
664
|
function windowed(arr, count2) {
|
|
665
|
+
if (!arr) return arr;
|
|
665
666
|
const newArr = Array.from(
|
|
666
667
|
Array(Math.floor(arr.length / count2 + arr.length % count2))
|
|
667
668
|
).map(() => []);
|
|
@@ -670,7 +671,7 @@ function windowed(arr, count2) {
|
|
|
670
671
|
}
|
|
671
672
|
function group(arr, isGroup) {
|
|
672
673
|
const groups = [];
|
|
673
|
-
arr
|
|
674
|
+
arr?.forEach?.((value) => {
|
|
674
675
|
const groupIdx = groups.findIndex(
|
|
675
676
|
(group2) => group2.every((groupVal) => isGroup(value, groupVal))
|
|
676
677
|
);
|
|
@@ -683,20 +684,20 @@ function group(arr, isGroup) {
|
|
|
683
684
|
return groups;
|
|
684
685
|
}
|
|
685
686
|
function strictArray(arr) {
|
|
686
|
-
return arr
|
|
687
|
+
return arr?.filter?.(
|
|
687
688
|
(val) => typeof val === "string" ? val.trim().length > 0 : val !== void 0 && val !== null
|
|
688
689
|
);
|
|
689
690
|
}
|
|
690
691
|
function maxOf(arr) {
|
|
691
|
-
const fmtArr = strictArray(arr);
|
|
692
|
+
const fmtArr = strictArray(arr || []);
|
|
692
693
|
return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
|
|
693
694
|
}
|
|
694
695
|
function minOf(arr) {
|
|
695
|
-
const fmtArr = strictArray(arr);
|
|
696
|
+
const fmtArr = strictArray(arr || []);
|
|
696
697
|
return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
|
|
697
698
|
}
|
|
698
699
|
function averageOf(arr) {
|
|
699
|
-
const fmtArr = strictArray(arr);
|
|
700
|
+
const fmtArr = strictArray(arr || []);
|
|
700
701
|
return isEmpty(fmtArr) ? 0 : sumOf(fmtArr) / fmtArr.length;
|
|
701
702
|
}
|
|
702
703
|
function run(value, fn) {
|
package/dist/main.js
CHANGED
|
@@ -562,9 +562,10 @@ function undefinedIfEmpty(value) {
|
|
|
562
562
|
if (value.length > 0) return value;
|
|
563
563
|
}
|
|
564
564
|
function ifEmpty(value, fallback) {
|
|
565
|
-
return isEmpty(value) ? fallback : value;
|
|
565
|
+
return isEmpty(value) || !value ? fallback : value;
|
|
566
566
|
}
|
|
567
567
|
function windowed(arr, count2) {
|
|
568
|
+
if (!arr) return arr;
|
|
568
569
|
const newArr = Array.from(
|
|
569
570
|
Array(Math.floor(arr.length / count2 + arr.length % count2))
|
|
570
571
|
).map(() => []);
|
|
@@ -573,7 +574,7 @@ function windowed(arr, count2) {
|
|
|
573
574
|
}
|
|
574
575
|
function group(arr, isGroup) {
|
|
575
576
|
const groups = [];
|
|
576
|
-
arr
|
|
577
|
+
arr?.forEach?.((value) => {
|
|
577
578
|
const groupIdx = groups.findIndex(
|
|
578
579
|
(group2) => group2.every((groupVal) => isGroup(value, groupVal))
|
|
579
580
|
);
|
|
@@ -586,20 +587,20 @@ function group(arr, isGroup) {
|
|
|
586
587
|
return groups;
|
|
587
588
|
}
|
|
588
589
|
function strictArray(arr) {
|
|
589
|
-
return arr
|
|
590
|
+
return arr?.filter?.(
|
|
590
591
|
(val) => typeof val === "string" ? val.trim().length > 0 : val !== void 0 && val !== null
|
|
591
592
|
);
|
|
592
593
|
}
|
|
593
594
|
function maxOf(arr) {
|
|
594
|
-
const fmtArr = strictArray(arr);
|
|
595
|
+
const fmtArr = strictArray(arr || []);
|
|
595
596
|
return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current > prev ? current : prev);
|
|
596
597
|
}
|
|
597
598
|
function minOf(arr) {
|
|
598
|
-
const fmtArr = strictArray(arr);
|
|
599
|
+
const fmtArr = strictArray(arr || []);
|
|
599
600
|
return isEmpty(arr) ? 0 : fmtArr.reduce((prev, current) => current < prev ? current : prev);
|
|
600
601
|
}
|
|
601
602
|
function averageOf(arr) {
|
|
602
|
-
const fmtArr = strictArray(arr);
|
|
603
|
+
const fmtArr = strictArray(arr || []);
|
|
603
604
|
return isEmpty(fmtArr) ? 0 : sumOf(fmtArr) / fmtArr.length;
|
|
604
605
|
}
|
|
605
606
|
function run(value, fn) {
|
package/package.json
CHANGED
package/prepend.js
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import("fs").then((fs) => {
|
|
2
|
-
const paths = ["./dist/main.d.ts", "./dist/main.d.cts"];
|
|
3
|
-
const handlePrepend = (...args) => {
|
|
4
|
-
const text = args.join("\n");
|
|
5
|
-
|
|
6
|
-
paths.forEach((path) => {
|
|
7
|
-
const data = fs.readFileSync(path)
|
|
8
|
-
fs.writeFileSync(path, text + "\n" + data);
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
|
|
12
|
-
handlePrepend('import "@wavy/types"');
|
|
13
|
-
});
|
|
14
|
-
|
package/publish.js
DELETED
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import("child_process").then(async ({ exec }) => {
|
|
2
|
-
const fs = await import("fs");
|
|
3
|
-
const console = await import("console");
|
|
4
|
-
const jsonPackage = JSON.parse(
|
|
5
|
-
fs.readFileSync("./package.json").toString("utf-8")
|
|
6
|
-
);
|
|
7
|
-
const version = jsonPackage.version;
|
|
8
|
-
let newVersion = "";
|
|
9
|
-
const updateVersion = async () => {
|
|
10
|
-
return new Promise((res, rej) => {
|
|
11
|
-
exec("npm version patch", (err, stdout, stderr) => {
|
|
12
|
-
if (err) rej(err);
|
|
13
|
-
res({ stdout, stderr });
|
|
14
|
-
});
|
|
15
|
-
});
|
|
16
|
-
};
|
|
17
|
-
updateVersion();
|
|
18
|
-
exec("npm run build && npm publish", async (err) => {
|
|
19
|
-
const overwriteVersionError = `Cannot implicitly apply the "latest" tag because published version ${version} is higher than the new version ${version}.`;
|
|
20
|
-
const getSuccessMessage = (tries = 1) =>
|
|
21
|
-
`✨ Successfully published package (${
|
|
22
|
-
newVersion ? `v${version}-v${newVersion}` : `v${version}`
|
|
23
|
-
}) after ${tries} tries 😁! ✨`;
|
|
24
|
-
|
|
25
|
-
if (err && err.message.includes(overwriteVersionError)) {
|
|
26
|
-
updateVersion();
|
|
27
|
-
exec("npm publish", (err) => {
|
|
28
|
-
if (err) console.error(err);
|
|
29
|
-
else console.log(getSuccessMessage(2));
|
|
30
|
-
});
|
|
31
|
-
} else if (err) {
|
|
32
|
-
console.log(err);
|
|
33
|
-
} else {
|
|
34
|
-
console.log(getSuccessMessage());
|
|
35
|
-
}
|
|
36
|
-
});
|
|
37
|
-
});
|