@carto/ps-utils 1.1.1 → 1.1.2

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.
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});function f(t,r=1){if(!t){console.warn(`hexToRgbaDeckGL: ${t} invalid hexadecimal format`);return}if(r<0||r>1){console.warn(`hexToRgbaDeckGL: ${r} invalid alpha format`);return}if(t?.includes("#")&&(t=t.slice(1)),!/[0-9A-Fa-f]{6}/g.test(t)&&!/[0-9A-Fa-f]{3}/g.test(t)&&!/[0-9A-Fa-f]{2}/g.test(t)){console.warn(`hexToRgbaDeckGL: ${t} invalid hexadecimal format`);return}const n=t.length;n<6&&(t=t.slice(0,6-n).repeat(6/n));const o=parseInt(t.length===3?t.slice(0,1).repeat(2):t.slice(0,2),16),e=parseInt(t.length===3?t.slice(1,2).repeat(2):t.slice(2,4),16),i=parseInt(t.length===3?t.slice(2,3).repeat(2):t.slice(4,6),16);return[o,e,i,r*255]}function g(t,{withPrefix:r=!0}={}){if(!t||!t.length){console.warn("rgbaDeckGLToHex: invalid array or empty values");return}if(t.some(e=>e<0||e>255)){console.warn(`rgbaDeckGLToHex: [${t.toString()}] invalid array value format`);return}const o=t.map(e=>e.toString(16).padStart(2,"0")).join("");return`${r?"#":""}${o}`}function c(t,{format:r="NFD",replaceUnicode:n="[̀-ͯ]"}={}){const o=new RegExp(n,"g");return t.normalize(r).replace(o,"")}function m(t,r,{matchFn:n,normalizeOptions:o}={}){const e=new RegExp(c(t.toLowerCase(),o),"gi");return Array.isArray(r)?r.filter(i=>{const a=n?n(i):i;return c(a).match(e)}):c(r).match(e)?r:null}function l(t,r,n){return Intl.DateTimeFormat(r,n).format(t)}const s={NUMBER:{style:"decimal",maximumFractionDigits:1,minimumFractionDigits:0,notation:"compact",compactDisplay:"short"},CURRENCY:{style:"currency",currency:"USD",maximumFractionDigits:2,minimumFractionDigits:2,notation:"compact",compactDisplay:"short"},DATE:{year:"numeric",month:"2-digit",day:"2-digit"}};function u(t,r,n){return Intl.NumberFormat(r,n).format(t)}function D(t,r,n={}){return u(t,r,{...s.NUMBER,...n})}function p(t,r,n={}){return u(t,r,{...s.CURRENCY,...n})}exports.CONFIG=s;exports.formatCurrency=p;exports.formatDate=l;exports.formatNumber=D;exports.hexToRgbaDeckGL=f;exports.matchText=m;exports.normalize=c;exports.rgbaDeckGLToHex=g;
package/dist/ps-utils.js CHANGED
@@ -39,7 +39,7 @@ function g(t, { withPrefix: n = !0 } = {}) {
39
39
  const e = t.map((o) => o.toString(16).padStart(2, "0")).join("");
40
40
  return `${n ? "#" : ""}${e}`;
41
41
  }
42
- function s(t, { format: n = "NFD", replaceUnicode: r = "[\u0300-\u036F]" } = {}) {
42
+ function s(t, { format: n = "NFD", replaceUnicode: r = "[̀-ͯ]" } = {}) {
43
43
  const e = new RegExp(r, "g");
44
44
  return t.normalize(n).replace(e, "");
45
45
  }
@@ -4,6 +4,6 @@
4
4
  * @property {boolean} withPrefix - boolean - Whether to include the '#' prefix in the hex
5
5
  * string.
6
6
  */
7
- export declare type RgbaDeckGLToHexOptions = {
7
+ export type RgbaDeckGLToHexOptions = {
8
8
  withPrefix?: boolean;
9
9
  };
@@ -8,7 +8,7 @@ import { NormalizeOptions } from '../normalize/types';
8
8
  * @property {NormalizeOptions} normalizeOptions - This is an object that contains the
9
9
  * options for the normalize function.
10
10
  */
11
- export declare type MatchTextOptions<T> = {
11
+ export type MatchTextOptions<T> = {
12
12
  matchFn?: (data: T) => string;
13
13
  normalizeOptions?: NormalizeOptions;
14
14
  };
@@ -9,7 +9,7 @@
9
9
  * @property {string} replaceUnicode - The unicode character to replace the unicode
10
10
  * characters with. By default is `[\u0300-\u036f]`.
11
11
  */
12
- export declare type NormalizeOptions = {
12
+ export type NormalizeOptions = {
13
13
  format?: 'NFD' | 'NFKD' | 'NFC' | 'NFKC';
14
14
  replaceUnicode?: string;
15
15
  };
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@carto/ps-utils",
3
- "version": "1.1.1",
3
+ "version": "1.1.2",
4
4
  "description": "CARTO's Professional Service Utils library",
5
5
  "files": [
6
6
  "dist"
7
7
  ],
8
8
  "type": "module",
9
9
  "types": "./dist/types/index.d.ts",
10
- "main": "./dist/ps-utils.js",
10
+ "main": "./dist/ps-utils.cjs",
11
11
  "module": "./dist/ps-utils.js",
12
12
  "exports": {
13
13
  ".": {
14
14
  "import": "./dist/ps-utils.js",
15
- "require": "./dist/ps-utils.js"
15
+ "require": "./dist/ps-utils.cjs"
16
16
  }
17
17
  },
18
18
  "scripts": {