@jsenv/test 3.7.13 → 3.7.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/jsenv_test.js +73 -44
- package/dist/jsenv_test_node_modules.js +23 -2
- package/package.json +4 -4
package/dist/jsenv_test.js
CHANGED
|
@@ -833,19 +833,47 @@ const setDecimalsPrecision = (
|
|
|
833
833
|
// return numberTruncated
|
|
834
834
|
// }
|
|
835
835
|
|
|
836
|
-
const
|
|
837
|
-
year:
|
|
838
|
-
month:
|
|
839
|
-
week:
|
|
840
|
-
day:
|
|
841
|
-
hour:
|
|
842
|
-
minute:
|
|
843
|
-
second:
|
|
836
|
+
const UNIT_MS = {
|
|
837
|
+
year: 31_557_600_000,
|
|
838
|
+
month: 2_629_000_000,
|
|
839
|
+
week: 604_800_000,
|
|
840
|
+
day: 86_400_000,
|
|
841
|
+
hour: 3_600_000,
|
|
842
|
+
minute: 60_000,
|
|
843
|
+
second: 1000,
|
|
844
|
+
};
|
|
845
|
+
const UNIT_KEYS = Object.keys(UNIT_MS);
|
|
846
|
+
const SMALLEST_UNIT_NAME = UNIT_KEYS[UNIT_KEYS.length - 1];
|
|
847
|
+
const TIME_DICTIONARY_EN = {
|
|
848
|
+
year: { long: "year", plural: "years", short: "y" },
|
|
849
|
+
month: { long: "month", plural: "months", short: "m" },
|
|
850
|
+
week: { long: "week", plural: "weeks", short: "w" },
|
|
851
|
+
day: { long: "day", plural: "days", short: "d" },
|
|
852
|
+
hour: { long: "hour", plural: "hours", short: "h" },
|
|
853
|
+
minute: { long: "minute", plural: "minutes", short: "m" },
|
|
854
|
+
second: { long: "second", plural: "seconds", short: "s" },
|
|
855
|
+
joinDuration: (primary, remaining) => `${primary} and ${remaining}`,
|
|
856
|
+
};
|
|
857
|
+
const TIME_DICTIONARY_FR = {
|
|
858
|
+
year: { long: "an", plural: "ans", short: "a" },
|
|
859
|
+
month: { long: "mois", plural: "mois", short: "m" },
|
|
860
|
+
week: { long: "semaine", plural: "semaines", short: "s" },
|
|
861
|
+
day: { long: "jour", plural: "jours", short: "j" },
|
|
862
|
+
hour: { long: "heure", plural: "heures", short: "h" },
|
|
863
|
+
minute: { long: "minute", plural: "minutes", short: "m" },
|
|
864
|
+
second: { long: "seconde", plural: "secondes", short: "s" },
|
|
865
|
+
joinDuration: (primary, remaining) => `${primary} et ${remaining}`,
|
|
844
866
|
};
|
|
845
867
|
|
|
846
868
|
const humanizeDuration = (
|
|
847
869
|
ms,
|
|
848
|
-
{
|
|
870
|
+
{
|
|
871
|
+
short,
|
|
872
|
+
rounded = true,
|
|
873
|
+
decimals,
|
|
874
|
+
lang = "en",
|
|
875
|
+
timeDictionnary = lang === "fr" ? TIME_DICTIONARY_FR : TIME_DICTIONARY_EN,
|
|
876
|
+
} = {},
|
|
849
877
|
) => {
|
|
850
878
|
// ignore ms below meaningfulMs so that:
|
|
851
879
|
// humanizeDuration(0.5) -> "0 second"
|
|
@@ -855,7 +883,9 @@ const humanizeDuration = (
|
|
|
855
883
|
// yes we could return "0.1 millisecond" but we choosed consistency over precision
|
|
856
884
|
// so that the prefered unit is "second" (and does not become millisecond when ms is super small)
|
|
857
885
|
if (ms < 1) {
|
|
858
|
-
return short
|
|
886
|
+
return short
|
|
887
|
+
? `0${timeDictionnary.second.short}`
|
|
888
|
+
: `0 ${timeDictionnary.second.long}`;
|
|
859
889
|
}
|
|
860
890
|
const { primary, remaining } = parseMs(ms);
|
|
861
891
|
if (!remaining) {
|
|
@@ -864,52 +894,51 @@ const humanizeDuration = (
|
|
|
864
894
|
decimals === undefined ? (primary.name === "second" ? 1 : 0) : decimals,
|
|
865
895
|
short,
|
|
866
896
|
rounded,
|
|
897
|
+
timeDictionnary,
|
|
867
898
|
});
|
|
868
899
|
}
|
|
869
|
-
|
|
900
|
+
const primaryText = humanizeDurationUnit(primary, {
|
|
870
901
|
decimals: decimals === undefined ? 0 : decimals,
|
|
871
902
|
short,
|
|
872
903
|
rounded,
|
|
873
|
-
|
|
904
|
+
timeDictionnary,
|
|
905
|
+
});
|
|
906
|
+
const remainingText = humanizeDurationUnit(remaining, {
|
|
874
907
|
decimals: decimals === undefined ? 0 : decimals,
|
|
875
908
|
short,
|
|
876
909
|
rounded,
|
|
877
|
-
|
|
910
|
+
timeDictionnary,
|
|
911
|
+
});
|
|
912
|
+
return timeDictionnary.joinDuration(primaryText, remainingText);
|
|
878
913
|
};
|
|
879
|
-
const humanizeDurationUnit = (
|
|
914
|
+
const humanizeDurationUnit = (
|
|
915
|
+
unit,
|
|
916
|
+
{ decimals, short, rounded, timeDictionnary },
|
|
917
|
+
) => {
|
|
880
918
|
const count = rounded
|
|
881
919
|
? setRoundedPrecision(unit.count, { decimals })
|
|
882
920
|
: setPrecision(unit.count, { decimals });
|
|
883
|
-
|
|
921
|
+
const name = unit.name;
|
|
884
922
|
if (short) {
|
|
885
|
-
|
|
886
|
-
return `${count}${
|
|
923
|
+
const unitText = timeDictionnary[name].short;
|
|
924
|
+
return `${count}${unitText}`;
|
|
887
925
|
}
|
|
888
926
|
if (count <= 1) {
|
|
889
|
-
|
|
927
|
+
const unitText = timeDictionnary[name].long;
|
|
928
|
+
return `${count} ${unitText}`;
|
|
890
929
|
}
|
|
891
|
-
|
|
892
|
-
}
|
|
893
|
-
const MS_PER_UNITS = {
|
|
894
|
-
year: 31_557_600_000,
|
|
895
|
-
month: 2_629_000_000,
|
|
896
|
-
week: 604_800_000,
|
|
897
|
-
day: 86_400_000,
|
|
898
|
-
hour: 3_600_000,
|
|
899
|
-
minute: 60_000,
|
|
900
|
-
second: 1000,
|
|
930
|
+
const unitText = timeDictionnary[name].plural;
|
|
931
|
+
return `${count} ${unitText}`;
|
|
901
932
|
};
|
|
902
933
|
|
|
903
934
|
const parseMs = (ms) => {
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
const firstUnitIndex = unitNames.findIndex((unitName) => {
|
|
909
|
-
if (unitName === smallestUnitName) {
|
|
935
|
+
let firstUnitName = SMALLEST_UNIT_NAME;
|
|
936
|
+
let firstUnitCount = ms / UNIT_MS[SMALLEST_UNIT_NAME];
|
|
937
|
+
const firstUnitIndex = UNIT_KEYS.findIndex((unitName) => {
|
|
938
|
+
if (unitName === SMALLEST_UNIT_NAME) {
|
|
910
939
|
return false;
|
|
911
940
|
}
|
|
912
|
-
const msPerUnit =
|
|
941
|
+
const msPerUnit = UNIT_MS[unitName];
|
|
913
942
|
const unitCount = Math.floor(ms / msPerUnit);
|
|
914
943
|
if (unitCount) {
|
|
915
944
|
firstUnitName = unitName;
|
|
@@ -918,7 +947,7 @@ const parseMs = (ms) => {
|
|
|
918
947
|
}
|
|
919
948
|
return false;
|
|
920
949
|
});
|
|
921
|
-
if (firstUnitName ===
|
|
950
|
+
if (firstUnitName === SMALLEST_UNIT_NAME) {
|
|
922
951
|
return {
|
|
923
952
|
primary: {
|
|
924
953
|
name: firstUnitName,
|
|
@@ -926,9 +955,9 @@ const parseMs = (ms) => {
|
|
|
926
955
|
},
|
|
927
956
|
};
|
|
928
957
|
}
|
|
929
|
-
const remainingMs = ms - firstUnitCount *
|
|
930
|
-
const remainingUnitName =
|
|
931
|
-
const remainingUnitCount = remainingMs /
|
|
958
|
+
const remainingMs = ms - firstUnitCount * UNIT_MS[firstUnitName];
|
|
959
|
+
const remainingUnitName = UNIT_KEYS[firstUnitIndex + 1];
|
|
960
|
+
const remainingUnitCount = remainingMs / UNIT_MS[remainingUnitName];
|
|
932
961
|
// - 1 year and 1 second is too much information
|
|
933
962
|
// so we don't check the remaining units
|
|
934
963
|
// - 1 year and 0.0001 week is awful
|
|
@@ -4121,13 +4150,13 @@ const applyPackageResolve = (packageSpecifier, resolutionContext) => {
|
|
|
4121
4150
|
: resolvePackageSymlink(packageDirectoryFacadeUrl);
|
|
4122
4151
|
const packageJson = readPackageJson(packageDirectoryUrl);
|
|
4123
4152
|
if (packageJson !== null) {
|
|
4124
|
-
const { exports } = packageJson;
|
|
4125
|
-
if (exports !== null && exports !== undefined) {
|
|
4153
|
+
const { exports: exports$1 } = packageJson;
|
|
4154
|
+
if (exports$1 !== null && exports$1 !== undefined) {
|
|
4126
4155
|
return applyPackageExportsResolution(packageSubpath, {
|
|
4127
4156
|
...resolutionContext,
|
|
4128
4157
|
packageDirectoryUrl,
|
|
4129
4158
|
packageJson,
|
|
4130
|
-
exports,
|
|
4159
|
+
exports: exports$1,
|
|
4131
4160
|
});
|
|
4132
4161
|
}
|
|
4133
4162
|
}
|
|
@@ -4154,8 +4183,8 @@ const applyPackageSelfResolution = (packageSubpath, resolutionContext) => {
|
|
|
4154
4183
|
if (packageJson.name !== packageName) {
|
|
4155
4184
|
return undefined;
|
|
4156
4185
|
}
|
|
4157
|
-
const { exports } = packageJson;
|
|
4158
|
-
if (!exports) {
|
|
4186
|
+
const { exports: exports$1 } = packageJson;
|
|
4187
|
+
if (!exports$1) {
|
|
4159
4188
|
const subpathResolution = applyLegacySubpathResolution(packageSubpath, {
|
|
4160
4189
|
...resolutionContext,
|
|
4161
4190
|
packageDirectoryUrl,
|
|
@@ -684,6 +684,7 @@ const ESC = '\u001B[';
|
|
|
684
684
|
|
|
685
685
|
!isBrowser && process.env.TERM_PROGRAM === 'Apple_Terminal';
|
|
686
686
|
const isWindows = !isBrowser && process.platform === 'win32';
|
|
687
|
+
!isBrowser && (process.env.TERM?.startsWith('screen') || process.env.TERM?.startsWith('tmux') || process.env.TMUX !== undefined);
|
|
687
688
|
|
|
688
689
|
isBrowser ? () => {
|
|
689
690
|
throw new Error('`process.cwd()` only works in Node.js, not the browser.');
|
|
@@ -709,13 +710,33 @@ const eraseLines = count => {
|
|
|
709
710
|
const eraseLine = ESC + '2K';
|
|
710
711
|
const eraseScreen = ESC + '2J';
|
|
711
712
|
|
|
712
|
-
const
|
|
713
|
+
const isOldWindows = () => {
|
|
714
|
+
if (isBrowser || !isWindows) {
|
|
715
|
+
return false;
|
|
716
|
+
}
|
|
717
|
+
|
|
718
|
+
const parts = os.release().split('.');
|
|
719
|
+
const major = Number(parts[0]);
|
|
720
|
+
const build = Number(parts[2] ?? 0);
|
|
721
|
+
|
|
722
|
+
if (major < 10) {
|
|
723
|
+
return true;
|
|
724
|
+
}
|
|
725
|
+
|
|
726
|
+
if (major === 10 && build < 10_586) {
|
|
727
|
+
return true;
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
return false;
|
|
731
|
+
};
|
|
732
|
+
|
|
733
|
+
const clearTerminal = isOldWindows()
|
|
713
734
|
? `${eraseScreen}${ESC}0f`
|
|
714
735
|
// 1. Erases the screen (Only done in case `2` is not supported)
|
|
715
736
|
// 2. Erases the whole screen including scrollback buffer
|
|
716
737
|
// 3. Moves cursor to the top-left position
|
|
717
738
|
// More info: https://www.real-world-systems.com/docs/ANSIcode.html
|
|
718
|
-
:
|
|
739
|
+
: `${eraseScreen}${ESC}3J${ESC}H`;
|
|
719
740
|
|
|
720
741
|
function createRawFrame(raw) {
|
|
721
742
|
return {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jsenv/test",
|
|
3
|
-
"version": "3.7.
|
|
3
|
+
"version": "3.7.15",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "https://github.com/jsenv/core",
|
|
@@ -35,9 +35,9 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@c88/v8-coverage": "0.1.1",
|
|
38
|
-
"@jsenv/ast": "6.7.
|
|
39
|
-
"@jsenv/plugin-supervisor": "1.7.
|
|
40
|
-
"@jsenv/sourcemap": "1.3.
|
|
38
|
+
"@jsenv/ast": "6.7.17",
|
|
39
|
+
"@jsenv/plugin-supervisor": "1.7.11",
|
|
40
|
+
"@jsenv/sourcemap": "1.3.13",
|
|
41
41
|
"he": "1.2.0",
|
|
42
42
|
"istanbul-lib-coverage": "3.2.2",
|
|
43
43
|
"istanbul-lib-instrument": "6.0.3",
|