@wavy/fn 0.0.9 → 0.0.11
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 +5 -4
- package/dist/main.d.cts +1 -1
- package/dist/main.d.ts +1 -1
- package/dist/main.js +5 -4
- package/package.json +1 -29
- package/publish.js +31 -0
package/dist/main.cjs
CHANGED
|
@@ -281,7 +281,7 @@ var TimeManager = class _TimeManager {
|
|
|
281
281
|
constructor(locale = "en-jm") {
|
|
282
282
|
this.locale = locale;
|
|
283
283
|
}
|
|
284
|
-
periods = {
|
|
284
|
+
static periods = {
|
|
285
285
|
overview: {
|
|
286
286
|
getPrevious: (period) => {
|
|
287
287
|
if (period === "Today") return "Yesterday";
|
|
@@ -290,7 +290,7 @@ var TimeManager = class _TimeManager {
|
|
|
290
290
|
}
|
|
291
291
|
}
|
|
292
292
|
};
|
|
293
|
-
metrics = {
|
|
293
|
+
static metrics = {
|
|
294
294
|
second: {
|
|
295
295
|
pluginVals: [1e3],
|
|
296
296
|
unit: { fmt: "second", abv: "sec" },
|
|
@@ -402,8 +402,9 @@ var TimeManager = class _TimeManager {
|
|
|
402
402
|
return fmtDate;
|
|
403
403
|
}
|
|
404
404
|
getDuration(from, to, options) {
|
|
405
|
-
const
|
|
406
|
-
const
|
|
405
|
+
const getDate = (date) => ["string", "number"].includes(typeof date) ? new Date(date === "now" ? Date.now() : date) : date;
|
|
406
|
+
const difference = getDate(to).getTime() - getDate(from).getTime();
|
|
407
|
+
const metrics = _TimeManager.metrics;
|
|
407
408
|
const getFmtDuration = (duration2, unit) => `${duration2} ${options?.abvUnits ? unit.abv : unit.fmt}${duration2 > 1 ? "s" : ""}`;
|
|
408
409
|
const getDuration = (plugins) => plugins.reduce((prev, curr) => prev / curr);
|
|
409
410
|
const metric = (timeDifference = difference) => Object.keys(metrics).reduce((prev, curr) => {
|
package/dist/main.d.cts
CHANGED
|
@@ -32,7 +32,7 @@ declare class StringFormatter {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
declare const dateFormat: (time: number | Date | "now", format?: DateFormat) => string;
|
|
35
|
-
declare const timeDuration: (from: number, to: number, options?: {
|
|
35
|
+
declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
|
|
36
36
|
disableRemainder?: boolean;
|
|
37
37
|
abvUnits?: boolean;
|
|
38
38
|
}) => string;
|
package/dist/main.d.ts
CHANGED
|
@@ -32,7 +32,7 @@ declare class StringFormatter {
|
|
|
32
32
|
}
|
|
33
33
|
|
|
34
34
|
declare const dateFormat: (time: number | Date | "now", format?: DateFormat) => string;
|
|
35
|
-
declare const timeDuration: (from: number, to: number, options?: {
|
|
35
|
+
declare const timeDuration: (from: number | "now" | Date, to: number | "now" | Date, options?: {
|
|
36
36
|
disableRemainder?: boolean;
|
|
37
37
|
abvUnits?: boolean;
|
|
38
38
|
}) => string;
|
package/dist/main.js
CHANGED
|
@@ -184,7 +184,7 @@ var TimeManager = class _TimeManager {
|
|
|
184
184
|
constructor(locale = "en-jm") {
|
|
185
185
|
this.locale = locale;
|
|
186
186
|
}
|
|
187
|
-
periods = {
|
|
187
|
+
static periods = {
|
|
188
188
|
overview: {
|
|
189
189
|
getPrevious: (period) => {
|
|
190
190
|
if (period === "Today") return "Yesterday";
|
|
@@ -193,7 +193,7 @@ var TimeManager = class _TimeManager {
|
|
|
193
193
|
}
|
|
194
194
|
}
|
|
195
195
|
};
|
|
196
|
-
metrics = {
|
|
196
|
+
static metrics = {
|
|
197
197
|
second: {
|
|
198
198
|
pluginVals: [1e3],
|
|
199
199
|
unit: { fmt: "second", abv: "sec" },
|
|
@@ -305,8 +305,9 @@ var TimeManager = class _TimeManager {
|
|
|
305
305
|
return fmtDate;
|
|
306
306
|
}
|
|
307
307
|
getDuration(from, to, options) {
|
|
308
|
-
const
|
|
309
|
-
const
|
|
308
|
+
const getDate = (date) => ["string", "number"].includes(typeof date) ? new Date(date === "now" ? Date.now() : date) : date;
|
|
309
|
+
const difference = getDate(to).getTime() - getDate(from).getTime();
|
|
310
|
+
const metrics = _TimeManager.metrics;
|
|
310
311
|
const getFmtDuration = (duration2, unit) => `${duration2} ${options?.abvUnits ? unit.abv : unit.fmt}${duration2 > 1 ? "s" : ""}`;
|
|
311
312
|
const getDuration = (plugins) => plugins.reduce((prev, curr) => prev / curr);
|
|
312
313
|
const metric = (timeDifference = difference) => Object.keys(metrics).reduce((prev, curr) => {
|
package/package.json
CHANGED
|
@@ -1,29 +1 @@
|
|
|
1
|
-
{
|
|
2
|
-
"name": "@wavy/fn",
|
|
3
|
-
"version": "0.0.9",
|
|
4
|
-
"main": "./dist/main.js",
|
|
5
|
-
"module": "./dist/main.cjs",
|
|
6
|
-
"types": "./dist/main.d.ts",
|
|
7
|
-
"scripts": {
|
|
8
|
-
"build": "tsup && node prepend"
|
|
9
|
-
},
|
|
10
|
-
"repository": {
|
|
11
|
-
"type": "git",
|
|
12
|
-
"url": "git+https://github.com/justVibes/literate-succotash.git"
|
|
13
|
-
},
|
|
14
|
-
"keywords": [],
|
|
15
|
-
"author": "",
|
|
16
|
-
"license": "MIT",
|
|
17
|
-
"type": "module",
|
|
18
|
-
"bugs": {
|
|
19
|
-
"url": "https://github.com/justVibes/literate-succotash/issues"
|
|
20
|
-
},
|
|
21
|
-
"homepage": "https://github.com/justVibes/literate-succotash#readme",
|
|
22
|
-
"description": "",
|
|
23
|
-
"devDependencies": {
|
|
24
|
-
"@types/node": "^24.5.2",
|
|
25
|
-
"@wavy/types": "^0.0.32",
|
|
26
|
-
"tsup": "^8.5.0",
|
|
27
|
-
"typescript": "^5.9.2"
|
|
28
|
-
}
|
|
29
|
-
}
|
|
1
|
+
{"name":"@wavy/fn","version":"0.0.11","main":"./dist/main.js","module":"./dist/main.cjs","types":"./dist/main.d.ts","scripts":{"build":"tsup && node prepend"},"repository":{"type":"git","url":"git+https://github.com/justVibes/literate-succotash.git"},"keywords":[],"author":"","license":"MIT","type":"module","bugs":{"url":"https://github.com/justVibes/literate-succotash/issues"},"homepage":"https://github.com/justVibes/literate-succotash#readme","description":"","devDependencies":{"@types/node":"^24.5.2","@wavy/types":"^0.0.32","tsup":"^8.5.0","typescript":"^5.9.2"}}
|
package/publish.js
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
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
|
+
const updateVersion = () => {
|
|
9
|
+
jsonPackage.version = version
|
|
10
|
+
.split(".")
|
|
11
|
+
.map((v, i, arr) => parseInt(v) + (i === arr.length - 1 ? 1 : 0))
|
|
12
|
+
.join(".");
|
|
13
|
+
fs.writeFileSync("./package.json", JSON.stringify(jsonPackage));
|
|
14
|
+
};
|
|
15
|
+
exec("npm run build && npm publish", async (err) => {
|
|
16
|
+
const overwriteVersionError = `Cannot implicitly apply the "latest" tag because published version ${version} is higher than the new version ${version}.`;
|
|
17
|
+
const successMessage = "✨ Successfully published package 😁! ✨";
|
|
18
|
+
|
|
19
|
+
if (err && err.message.includes(overwriteVersionError)) {
|
|
20
|
+
updateVersion();
|
|
21
|
+
exec("npm publish", (err) => {
|
|
22
|
+
if (err) console.error(err);
|
|
23
|
+
else console.log(successMessage);
|
|
24
|
+
});
|
|
25
|
+
} else if (err) {
|
|
26
|
+
console.log(err);
|
|
27
|
+
} else {
|
|
28
|
+
console.log(successMessage);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
});
|