All Downloads are FREE. Search and download functionalities are using the official Maven repository.

package.cjs.initializers.utils.customFormatters.js.map Maven / Gradle / Ivy

Go to download

A package encapsulating common code across neeto projects including initializers, utility functions, common components and hooks and so on.

There is a newer version: 4.12.3
Show newest version
{"version":3,"file":"customFormatters.js","names":["_dompurify","_interopRequireDefault","require","_constants","sanitizer","array","DOMPurify","sanitize","USE_PROFILES","html","cacheStore","Map","fetchCachedOrInvoke","func","lng","options","_cacheStore$get","cache","get","lngCache","set","lowerCaseDynamicTextFormatter","exports","value","format","FORMATS","anyCase","LOWERCASED","toLocaleLowerCase","listFormatter","_ref","formatter","Intl","ListFormat","newValue","boldList","map","item","concat","sanitizedItems","split"],"sources":["../../../../src/initializers/utils/customFormatters.js"],"sourcesContent":["import DOMPurify from \"dompurify\";\n\nimport { LOWERCASED, FORMATS } from \"../constants\";\n\nconst sanitizer = array =>\n  DOMPurify.sanitize(array, { USE_PROFILES: { html: true } });\n\nconst cacheStore = new Map();\n\nconst fetchCachedOrInvoke = (func, lng, options) => {\n  let cache = cacheStore.get(lng)?.get(options);\n  if (cache) return cache;\n\n  cache = func(lng, options);\n  const lngCache = cacheStore.get(lng);\n  if (lngCache) lngCache.set(options, cache);\n  else cacheStore.set(lng, new Map([[options, cache]]));\n\n  return cache;\n};\n\nexport const lowerCaseDynamicTextFormatter = (value, format) => {\n  if (!value || format === FORMATS.anyCase || typeof value !== \"string\") {\n    return value;\n  }\n\n  return LOWERCASED + value.toLocaleLowerCase();\n};\n\nexport const listFormatter = ({ value, format, lng, options }) => {\n  const formatter = fetchCachedOrInvoke(\n    (lng, options) => new Intl.ListFormat(lng, options),\n    lng,\n    options\n  );\n\n  let newValue = value;\n  if (format === FORMATS.boldList) {\n    newValue = value.map(item => `${item}`);\n  }\n  const sanitizedItems = sanitizer(newValue).split(\",\");\n\n  return formatter.format(sanitizedItems);\n};\n"],"mappings":";;;;;;;AAAA,IAAAA,UAAA,GAAAC,sBAAA,CAAAC,OAAA;AAEA,IAAAC,U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