@wavy/fn 0.0.8 → 0.0.10
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 +11 -3
- package/dist/main.d.cts +5 -1
- package/dist/main.d.ts +5 -1
- package/dist/main.js +10 -3
- package/package.json +1 -1
package/dist/main.cjs
CHANGED
|
@@ -43,6 +43,7 @@ __export(main_exports, {
|
|
|
43
43
|
formatInvoiceNo: () => formatInvoiceNo,
|
|
44
44
|
getCaps: () => getCaps,
|
|
45
45
|
getFileExt: () => getFileExt,
|
|
46
|
+
getFilename: () => getFilename,
|
|
46
47
|
getMimeTypes: () => getMimeTypes,
|
|
47
48
|
group: () => group,
|
|
48
49
|
hasIndex: () => hasIndex,
|
|
@@ -280,7 +281,7 @@ var TimeManager = class _TimeManager {
|
|
|
280
281
|
constructor(locale = "en-jm") {
|
|
281
282
|
this.locale = locale;
|
|
282
283
|
}
|
|
283
|
-
periods = {
|
|
284
|
+
static periods = {
|
|
284
285
|
overview: {
|
|
285
286
|
getPrevious: (period) => {
|
|
286
287
|
if (period === "Today") return "Yesterday";
|
|
@@ -289,7 +290,7 @@ var TimeManager = class _TimeManager {
|
|
|
289
290
|
}
|
|
290
291
|
}
|
|
291
292
|
};
|
|
292
|
-
metrics = {
|
|
293
|
+
static metrics = {
|
|
293
294
|
second: {
|
|
294
295
|
pluginVals: [1e3],
|
|
295
296
|
unit: { fmt: "second", abv: "sec" },
|
|
@@ -402,7 +403,7 @@ var TimeManager = class _TimeManager {
|
|
|
402
403
|
}
|
|
403
404
|
getDuration(from, to, options) {
|
|
404
405
|
const difference = new Date(to).getTime() - new Date(from).getTime();
|
|
405
|
-
const metrics =
|
|
406
|
+
const metrics = _TimeManager.metrics;
|
|
406
407
|
const getFmtDuration = (duration2, unit) => `${duration2} ${options?.abvUnits ? unit.abv : unit.fmt}${duration2 > 1 ? "s" : ""}`;
|
|
407
408
|
const getDuration = (plugins) => plugins.reduce((prev, curr) => prev / curr);
|
|
408
409
|
const metric = (timeDifference = difference) => Object.keys(metrics).reduce((prev, curr) => {
|
|
@@ -835,6 +836,12 @@ function inferFilename(filePath) {
|
|
|
835
836
|
function getFileExt(filePath) {
|
|
836
837
|
return "." + takeLastWhile(filePath.split(""), (v) => v !== ".").join("");
|
|
837
838
|
}
|
|
839
|
+
function getFilename(params) {
|
|
840
|
+
if (!params.filename) return inferFilename(params.filePath);
|
|
841
|
+
const fileExt = getFileExt(params.filePath);
|
|
842
|
+
if (params.filename.includes(fileExt)) return params.filename.trim();
|
|
843
|
+
return params.filename.trim() + fileExt;
|
|
844
|
+
}
|
|
838
845
|
async function copyToClipboard(text) {
|
|
839
846
|
try {
|
|
840
847
|
await navigator.clipboard.writeText(text);
|
|
@@ -1092,6 +1099,7 @@ var serverDataAdapter = new ServerDataAdapter().invoke;
|
|
|
1092
1099
|
formatInvoiceNo,
|
|
1093
1100
|
getCaps,
|
|
1094
1101
|
getFileExt,
|
|
1102
|
+
getFilename,
|
|
1095
1103
|
getMimeTypes,
|
|
1096
1104
|
group,
|
|
1097
1105
|
hasIndex,
|
package/dist/main.d.cts
CHANGED
|
@@ -149,6 +149,10 @@ declare function someValuesEmpty<O extends {
|
|
|
149
149
|
declare function poll<T>(getValue: () => T, interval?: number): Promise<Awaited<T> & ({} | null)>;
|
|
150
150
|
declare function inferFilename(filePath: string): string;
|
|
151
151
|
declare function getFileExt(filePath: string): string;
|
|
152
|
+
declare function getFilename(params: {
|
|
153
|
+
filePath: string;
|
|
154
|
+
filename?: string;
|
|
155
|
+
}): string;
|
|
152
156
|
declare function copyToClipboard(text: string): Promise<TaskResult>;
|
|
153
157
|
declare function readClipboardText(): Promise<TaskResult<{
|
|
154
158
|
text: string;
|
|
@@ -167,4 +171,4 @@ declare const serverDataAdapter: {
|
|
|
167
171
|
}>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
|
|
168
172
|
};
|
|
169
173
|
|
|
170
|
-
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, formatGCTRegNo, formatInvoiceNo, getCaps, getFileExt, getMimeTypes, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, ordinalIndicator, overwrite, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, trimString, undefinedIfEmpty, upperFirst, windowed };
|
|
174
|
+
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, formatGCTRegNo, formatInvoiceNo, getCaps, getFileExt, getFilename, getMimeTypes, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, ordinalIndicator, overwrite, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, trimString, undefinedIfEmpty, upperFirst, windowed };
|
package/dist/main.d.ts
CHANGED
|
@@ -149,6 +149,10 @@ declare function someValuesEmpty<O extends {
|
|
|
149
149
|
declare function poll<T>(getValue: () => T, interval?: number): Promise<Awaited<T> & ({} | null)>;
|
|
150
150
|
declare function inferFilename(filePath: string): string;
|
|
151
151
|
declare function getFileExt(filePath: string): string;
|
|
152
|
+
declare function getFilename(params: {
|
|
153
|
+
filePath: string;
|
|
154
|
+
filename?: string;
|
|
155
|
+
}): string;
|
|
152
156
|
declare function copyToClipboard(text: string): Promise<TaskResult>;
|
|
153
157
|
declare function readClipboardText(): Promise<TaskResult<{
|
|
154
158
|
text: string;
|
|
@@ -167,4 +171,4 @@ declare const serverDataAdapter: {
|
|
|
167
171
|
}>(event: "unzip", data: DataType): NormalizeFromServer<DataType>;
|
|
168
172
|
};
|
|
169
173
|
|
|
170
|
-
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, formatGCTRegNo, formatInvoiceNo, getCaps, getFileExt, getMimeTypes, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, ordinalIndicator, overwrite, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, trimString, undefinedIfEmpty, upperFirst, windowed };
|
|
174
|
+
export { addArticle, arrayWithConst, asyncRun, averageOf, blankSpaces, buildArray, camelCaseToLetter, classNameExt, classNameResolver, coerceIn, copyToClipboard, count, dataSearcher, distinct, drop, dropLast, dropLastWhile, dropWhile, format, formatGCTRegNo, formatInvoiceNo, getCaps, getFileExt, getFilename, getMimeTypes, group, hasIndex, ifDefined, ifEmpty, inRange, indexOf, indices, inferFilename, insertAt, isEmpty, isFile, isLetter, isLocalFile, isNumber, lastIndex, map, mapToArray, maxOf, minOf, negate, ordinalIndicator, overwrite, pluralize, poll, random, range, readClipboardText, removeAll, repeat, run, serverDataAdapter, someValuesEmpty, sort, strictArray, stringToSearch, subObjectList, sumOf, take, takeLast, takeLastWhile, takeWhile, timeDuration, toNumber, trimString, undefinedIfEmpty, upperFirst, windowed };
|
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" },
|
|
@@ -306,7 +306,7 @@ var TimeManager = class _TimeManager {
|
|
|
306
306
|
}
|
|
307
307
|
getDuration(from, to, options) {
|
|
308
308
|
const difference = new Date(to).getTime() - new Date(from).getTime();
|
|
309
|
-
const metrics =
|
|
309
|
+
const metrics = _TimeManager.metrics;
|
|
310
310
|
const getFmtDuration = (duration2, unit) => `${duration2} ${options?.abvUnits ? unit.abv : unit.fmt}${duration2 > 1 ? "s" : ""}`;
|
|
311
311
|
const getDuration = (plugins) => plugins.reduce((prev, curr) => prev / curr);
|
|
312
312
|
const metric = (timeDifference = difference) => Object.keys(metrics).reduce((prev, curr) => {
|
|
@@ -739,6 +739,12 @@ function inferFilename(filePath) {
|
|
|
739
739
|
function getFileExt(filePath) {
|
|
740
740
|
return "." + takeLastWhile(filePath.split(""), (v) => v !== ".").join("");
|
|
741
741
|
}
|
|
742
|
+
function getFilename(params) {
|
|
743
|
+
if (!params.filename) return inferFilename(params.filePath);
|
|
744
|
+
const fileExt = getFileExt(params.filePath);
|
|
745
|
+
if (params.filename.includes(fileExt)) return params.filename.trim();
|
|
746
|
+
return params.filename.trim() + fileExt;
|
|
747
|
+
}
|
|
742
748
|
async function copyToClipboard(text) {
|
|
743
749
|
try {
|
|
744
750
|
await navigator.clipboard.writeText(text);
|
|
@@ -995,6 +1001,7 @@ export {
|
|
|
995
1001
|
formatInvoiceNo,
|
|
996
1002
|
getCaps,
|
|
997
1003
|
getFileExt,
|
|
1004
|
+
getFilename,
|
|
998
1005
|
getMimeTypes,
|
|
999
1006
|
group,
|
|
1000
1007
|
hasIndex,
|