@ancon/wildcat-utils 1.41.18 → 1.42.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.
@@ -1,3 +1,15 @@
1
+ declare type Options = {
2
+ /**
3
+ * Whether or not to format the currency postfix (ie SEK -> kr)
4
+ * @default true
5
+ */
6
+ formatPostfix?: boolean;
7
+ /**
8
+ * Whether or not to trim trailing zeros
9
+ * @default true
10
+ */
11
+ trimTrailingZeros?: boolean;
12
+ };
1
13
  /**
2
14
  * Formats the given monetary value
3
15
  * @param {number} value - The numeric value
@@ -6,4 +18,12 @@
6
18
  * @return {string} - Formatted monetary value
7
19
  */
8
20
  declare function getFormattedCurrency(value?: number | null, currency?: string | null, formatPostfix?: boolean): string;
21
+ /**
22
+ * Formats the given monetary value
23
+ * @param {number} value - The numeric value
24
+ * @param {string} currency - The currency string
25
+ * @param {boolean} options - Options object
26
+ * @return {string} - Formatted monetary value
27
+ */
28
+ declare function getFormattedCurrency(value: number | null | undefined, currency: string | null | undefined, options: Options): string;
9
29
  export default getFormattedCurrency;
@@ -1 +1 @@
1
- "use strict";const o=require("./getFormattedCurrencyPostfix.js");function u(e=0,t="SEK",i=!0){let r=0;!e||Number.isNaN(Number(e))?r=0:Number.isInteger(Number(e))?r=e:r=Number(e).toFixed(2);const s=i?o.getFormattedCurrencyPostfix(t):t;return`${r} ${s}`}module.exports=u;
1
+ "use strict";const i=require("./getFormattedCurrencyPostfix.js");function N(r=0,c="SEK",e=!0){let u=0;const t=typeof e=="object"?{formatPostfix:(e==null?void 0:e.formatPostfix)??!0,trimTrailingZeros:(e==null?void 0:e.trimTrailingZeros)??!0}:{formatPostfix:e,trimTrailingZeros:!0};!r||Number.isNaN(Number(r))?u=0:t.trimTrailingZeros&&Number.isInteger(Number(r))?u=r:u=Number(r).toFixed(2);const g=t.formatPostfix?i.getFormattedCurrencyPostfix(c):c;return`${u} ${g}`}module.exports=N;
@@ -1,10 +1,17 @@
1
- import { getFormattedCurrencyPostfix as m } from "./getFormattedCurrencyPostfix.mjs";
2
- function s(e = 0, t = "SEK", i = !0) {
3
- let r = 0;
4
- !e || Number.isNaN(Number(e)) ? r = 0 : Number.isInteger(Number(e)) ? r = e : r = Number(e).toFixed(2);
5
- const o = i ? m(t) : t;
6
- return `${r} ${o}`;
1
+ import { getFormattedCurrencyPostfix as c } from "./getFormattedCurrencyPostfix.mjs";
2
+ function d(r = 0, g = "SEK", e = !0) {
3
+ let u = 0;
4
+ const N = typeof e == "object" ? {
5
+ formatPostfix: (e == null ? void 0 : e.formatPostfix) ?? !0,
6
+ trimTrailingZeros: (e == null ? void 0 : e.trimTrailingZeros) ?? !0
7
+ } : {
8
+ formatPostfix: e,
9
+ trimTrailingZeros: !0
10
+ };
11
+ !r || Number.isNaN(Number(r)) ? u = 0 : N.trimTrailingZeros && Number.isInteger(Number(r)) ? u = r : u = Number(r).toFixed(2);
12
+ const b = N.formatPostfix ? c(g) : g;
13
+ return `${u} ${b}`;
7
14
  }
8
15
  export {
9
- s as default
16
+ d as default
10
17
  };
@@ -1 +1 @@
1
- "use strict";const n=require("moment"),t=require("@ancon/wildcat-types"),e=require("./types.js");function c(r,i,s=10){switch(r){case t.LicenseStatus.Expired:return e.LicenseUIState.Expired;case t.LicenseStatus.Extended:return e.LicenseUIState.Extended;case t.LicenseStatus.Terminated:return e.LicenseUIState.Terminated;default:return i&&n(i).diff(n(),"day")<=s?e.LicenseUIState.AboutToExpire:e.LicenseUIState.Valid}}module.exports=c;
1
+ "use strict";const r=require("moment"),e=require("@ancon/wildcat-types"),t=require("./types.js");function c(i,n,s=10){return(i&e.LicenseStatus.Terminated)===e.LicenseStatus.Terminated?t.LicenseUIState.Terminated:(i&e.LicenseStatus.Expired)===e.LicenseStatus.Expired?t.LicenseUIState.Expired:(i&e.LicenseStatus.Extended)===e.LicenseStatus.Extended?t.LicenseUIState.Extended:n&&r(n).diff(r(),"day")<=s?t.LicenseUIState.AboutToExpire:t.LicenseUIState.Valid}module.exports=c;
@@ -1,18 +1,9 @@
1
- import i from "moment";
2
- import { LicenseStatus as t } from "@ancon/wildcat-types";
3
- import { LicenseUIState as e } from "./types.mjs";
4
- function s(n, r, o = 10) {
5
- switch (n) {
6
- case t.Expired:
7
- return e.Expired;
8
- case t.Extended:
9
- return e.Extended;
10
- case t.Terminated:
11
- return e.Terminated;
12
- default:
13
- return r && i(r).diff(i(), "day") <= o ? e.AboutToExpire : e.Valid;
14
- }
1
+ import n from "moment";
2
+ import { LicenseStatus as e } from "@ancon/wildcat-types";
3
+ import { LicenseUIState as r } from "./types.mjs";
4
+ function a(i, t, o = 10) {
5
+ return (i & e.Terminated) === e.Terminated ? r.Terminated : (i & e.Expired) === e.Expired ? r.Expired : (i & e.Extended) === e.Extended ? r.Extended : t && n(t).diff(n(), "day") <= o ? r.AboutToExpire : r.Valid;
15
6
  }
16
7
  export {
17
- s as default
8
+ a as default
18
9
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ancon/wildcat-utils",
3
- "version": "1.41.18",
3
+ "version": "1.42.0",
4
4
  "private": false,
5
5
  "main": "index.js",
6
6
  "module": "index.mjs",