@ancon/wildcat-utils 1.13.0 → 1.14.0
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/index.js +1 -1
- package/index.mjs +30 -28
- package/logger/index.js +1 -1
- package/logger/index.mjs +5 -4
- package/logger/sanitizeAsStringDict.js +1 -1
- package/logger/sanitizeAsStringDict.mjs +8 -7
- package/package.json +6 -1
- package/string/index.d.ts +2 -1
- package/string/index.js +1 -1
- package/string/index.mjs +3 -1
- package/string/truncate.d.ts +12 -0
- package/string/truncate.js +1 -0
- package/string/truncate.mjs +10 -0
package/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),i=require("./shared/generateId.js"),t=require("./outlet/getListOutletOpeningHoursTable.js"),n=require("./versioning/isVersionALessThanB.js"),s=require("./versioning/cleanVersionString.js"),o=require("./api/getUrlAndParams.js"),g=require("./api/getEndpointWithVersion.js"),
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./shared/enums.js"),r=require("./shared/isWithinFlag.js"),i=require("./shared/generateId.js"),t=require("./outlet/getListOutletOpeningHoursTable.js"),n=require("./versioning/isVersionALessThanB.js"),s=require("./versioning/cleanVersionString.js"),o=require("./api/getUrlAndParams.js"),g=require("./api/getEndpointWithVersion.js"),u=require("./string/slugify.js"),a=require("./string/truncate.js"),l=require("./color/lighten.js"),c=require("./color/brighten.js"),d=require("./color/darken.js"),q=require("./user/getFullName.js"),_=require("./user/getFullAddressString.js"),p=require("./logger/Logger.js"),h=require("./logger/types.js"),S=require("./logger/sanitizeAsStringDict.js"),V=require("./printing/isValidPrinter.js"),y=require("./printing/isValidNetworkPrinter.js"),P=require("./printing/isValidStarCloudPrinter.js"),L=require("./printing/getPrinterType.js");require("moment");require("@ancon/wildcat-types");require("compare-versions");require("tinycolor2");require("@ancon/wildcat-printing");exports.DayOfWeek=e.DayOfWeek;exports.IntervalState=e.IntervalState;exports.IntervalType=e.IntervalType;exports.OrderFormat=e.OrderFormat;exports.isWithinFlag=r;exports.generateId=i;exports.getListOutletOpeningHoursTable=t;exports.isVersionALessThanB=n;exports.cleanVersionString=s;exports.getUrlAndParams=o;exports.getEndpointWithVersion=g;exports.slugify=u;exports.truncate=a;exports.lighten=l;exports.brighten=c;exports.darken=d;exports.getFullName=q;exports.getFullAddressString=_;exports.Logger=p;exports.LogLevel=h.LogLevel;exports.sanitizeAsStringDict=S;exports.isValidPrinter=V;exports.isValidNetworkPrinter=y;exports.isValidStarCloudPrinter=P;exports.getPrinterType=L;
|
package/index.mjs
CHANGED
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { DayOfWeek as s, IntervalState as i, IntervalType as d, OrderFormat as p } from "./shared/enums.mjs";
|
|
2
|
-
import { default as
|
|
2
|
+
import { default as u } from "./shared/isWithinFlag.mjs";
|
|
3
3
|
import { default as x } from "./shared/generateId.mjs";
|
|
4
4
|
import { default as V } from "./outlet/getListOutletOpeningHoursTable.mjs";
|
|
5
5
|
import { default as L } from "./versioning/isVersionALessThanB.mjs";
|
|
6
6
|
import { default as S } from "./versioning/cleanVersionString.mjs";
|
|
7
7
|
import { default as A } from "./api/getUrlAndParams.mjs";
|
|
8
8
|
import { default as O } from "./api/getEndpointWithVersion.mjs";
|
|
9
|
-
import { default as
|
|
10
|
-
import { default as
|
|
11
|
-
import { default as
|
|
12
|
-
import { default as D } from "./color/
|
|
13
|
-
import { default as w } from "./
|
|
14
|
-
import { default as B } from "./user/
|
|
15
|
-
import { default as E } from "./
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
18
|
-
import { default as J } from "./
|
|
19
|
-
import { default as M } from "./printing/
|
|
20
|
-
import { default as R } from "./printing/
|
|
21
|
-
import { default as Y } from "./printing/
|
|
9
|
+
import { default as c } from "./string/slugify.mjs";
|
|
10
|
+
import { default as v } from "./string/truncate.mjs";
|
|
11
|
+
import { default as W } from "./color/lighten.mjs";
|
|
12
|
+
import { default as D } from "./color/brighten.mjs";
|
|
13
|
+
import { default as w } from "./color/darken.mjs";
|
|
14
|
+
import { default as B } from "./user/getFullName.mjs";
|
|
15
|
+
import { default as E } from "./user/getFullAddressString.mjs";
|
|
16
|
+
import { default as U } from "./logger/Logger.mjs";
|
|
17
|
+
import { LogLevel as q } from "./logger/types.mjs";
|
|
18
|
+
import { default as J } from "./logger/sanitizeAsStringDict.mjs";
|
|
19
|
+
import { default as M } from "./printing/isValidPrinter.mjs";
|
|
20
|
+
import { default as R } from "./printing/isValidNetworkPrinter.mjs";
|
|
21
|
+
import { default as Y } from "./printing/isValidStarCloudPrinter.mjs";
|
|
22
|
+
import { default as _ } from "./printing/getPrinterType.mjs";
|
|
22
23
|
import "moment";
|
|
23
24
|
import "@ancon/wildcat-types";
|
|
24
25
|
import "compare-versions";
|
|
@@ -28,25 +29,26 @@ export {
|
|
|
28
29
|
s as DayOfWeek,
|
|
29
30
|
i as IntervalState,
|
|
30
31
|
d as IntervalType,
|
|
31
|
-
|
|
32
|
-
|
|
32
|
+
q as LogLevel,
|
|
33
|
+
U as Logger,
|
|
33
34
|
p as OrderFormat,
|
|
34
|
-
|
|
35
|
+
D as brighten,
|
|
35
36
|
S as cleanVersionString,
|
|
36
|
-
|
|
37
|
+
w as darken,
|
|
37
38
|
x as generateId,
|
|
38
39
|
O as getEndpointWithVersion,
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
E as getFullAddressString,
|
|
41
|
+
B as getFullName,
|
|
41
42
|
V as getListOutletOpeningHoursTable,
|
|
42
|
-
|
|
43
|
+
_ as getPrinterType,
|
|
43
44
|
A as getUrlAndParams,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
45
|
+
R as isValidNetworkPrinter,
|
|
46
|
+
M as isValidPrinter,
|
|
47
|
+
Y as isValidStarCloudPrinter,
|
|
47
48
|
L as isVersionALessThanB,
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
u as isWithinFlag,
|
|
50
|
+
W as lighten,
|
|
51
|
+
J as sanitizeAsStringDict,
|
|
52
|
+
c as slugify,
|
|
53
|
+
v as truncate
|
|
52
54
|
};
|
package/logger/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Logger.js"),r=require("./types.js"),g=require("./sanitizeAsStringDict.js");exports.Logger=e;exports.LogLevel=r.LogLevel;exports.sanitizeAsStringDict=g;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./Logger.js"),r=require("./types.js"),g=require("./sanitizeAsStringDict.js");require("../string/truncate.js");exports.Logger=e;exports.LogLevel=r.LogLevel;exports.sanitizeAsStringDict=g;
|
package/logger/index.mjs
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { default as
|
|
2
|
-
import { LogLevel as
|
|
1
|
+
import { default as t } from "./Logger.mjs";
|
|
2
|
+
import { LogLevel as f } from "./types.mjs";
|
|
3
3
|
import { default as g } from "./sanitizeAsStringDict.mjs";
|
|
4
|
+
import "../string/truncate.mjs";
|
|
4
5
|
export {
|
|
5
|
-
|
|
6
|
-
|
|
6
|
+
f as LogLevel,
|
|
7
|
+
t as Logger,
|
|
7
8
|
g as sanitizeAsStringDict
|
|
8
9
|
};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";function
|
|
1
|
+
"use strict";const f=require("../string/truncate.js");function m(n,t){return t?`${t}.${n}`:n}function s(n,t,u){return Object.entries(n).reduce((e,[o,r])=>{const i=m(o,u);return t[i]!==void 0?e:typeof r=="string"?(t[i]=f(r,100),e):typeof r=="number"?(t[i]=f(r.toString(),100),e):typeof r=="object"&&r?s(r,e,o):(t[i]=f(String(r),100),t)},t)}function x(n){if(n)return s(n,{})}module.exports=x;
|
|
@@ -1,19 +1,20 @@
|
|
|
1
|
+
import i from "../string/truncate.mjs";
|
|
1
2
|
function s(n, t) {
|
|
2
3
|
return t ? `${t}.${n}` : n;
|
|
3
4
|
}
|
|
4
|
-
function
|
|
5
|
+
function u(n, t, m) {
|
|
5
6
|
return Object.entries(n).reduce(
|
|
6
|
-
(e, [
|
|
7
|
-
const f = s(
|
|
8
|
-
return t[f] !== void 0 ? e : typeof r == "string" ? (t[f] = r, e) : typeof r == "number" ? (t[f] = r.toString(), e) : typeof r == "object" && r ?
|
|
7
|
+
(e, [o, r]) => {
|
|
8
|
+
const f = s(o, m);
|
|
9
|
+
return t[f] !== void 0 ? e : typeof r == "string" ? (t[f] = i(r, 100), e) : typeof r == "number" ? (t[f] = i(r.toString(), 100), e) : typeof r == "object" && r ? u(r, e, o) : (t[f] = i(String(r), 100), t);
|
|
9
10
|
},
|
|
10
11
|
t
|
|
11
12
|
);
|
|
12
13
|
}
|
|
13
|
-
function
|
|
14
|
+
function L(n) {
|
|
14
15
|
if (n)
|
|
15
|
-
return
|
|
16
|
+
return u(n, {});
|
|
16
17
|
}
|
|
17
18
|
export {
|
|
18
|
-
|
|
19
|
+
L as default
|
|
19
20
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ancon/wildcat-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.14.0",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "index.cjs",
|
|
6
6
|
"module": "index.js",
|
|
@@ -136,6 +136,11 @@
|
|
|
136
136
|
"require": "./string/slugify.cjs",
|
|
137
137
|
"types": "./string/slugify.d.ts"
|
|
138
138
|
},
|
|
139
|
+
"./string/truncate": {
|
|
140
|
+
"import": "./string/truncate.js",
|
|
141
|
+
"require": "./string/truncate.cjs",
|
|
142
|
+
"types": "./string/truncate.d.ts"
|
|
143
|
+
},
|
|
139
144
|
"./user/getFullAddressString": {
|
|
140
145
|
"import": "./user/getFullAddressString.js",
|
|
141
146
|
"require": "./user/getFullAddressString.cjs",
|
package/string/index.d.ts
CHANGED
package/string/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const t=require("./slugify.js"),e=require("./truncate.js");exports.slugify=t;exports.truncate=e;
|
package/string/index.mjs
CHANGED
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Truncate a string to fit within `maxLen` number of characters.
|
|
3
|
+
* @param str String to truncate
|
|
4
|
+
* @param maxLen Max number of characters
|
|
5
|
+
* @param options Options
|
|
6
|
+
* @returns Truncated or original string
|
|
7
|
+
*/
|
|
8
|
+
declare function truncate<T = string | undefined | null>(str: T, maxLen: number, options?: {
|
|
9
|
+
trim?: boolean;
|
|
10
|
+
ellipsis?: string;
|
|
11
|
+
}): string;
|
|
12
|
+
export default truncate;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";function i(u,e,t){const f=(t==null?void 0:t.trim)??!0,l=(t==null?void 0:t.ellipsis)??"...";if(typeof u!="string")return"";let r=u;return e<0||Math.max(0,r.length)>e&&(r=r.substring(0,Math.max(0,e-l.length)),f&&(r=r.trim()),r+=l),r}module.exports=i;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
function a(l, e, t) {
|
|
2
|
+
const f = (t == null ? void 0 : t.trim) ?? !0, u = (t == null ? void 0 : t.ellipsis) ?? "...";
|
|
3
|
+
if (typeof l != "string")
|
|
4
|
+
return "";
|
|
5
|
+
let r = l;
|
|
6
|
+
return e < 0 || Math.max(0, r.length) > e && (r = r.substring(0, Math.max(0, e - u.length)), f && (r = r.trim()), r += u), r;
|
|
7
|
+
}
|
|
8
|
+
export {
|
|
9
|
+
a as default
|
|
10
|
+
};
|