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","value","format","FORMATS","anyCase","LOWERCASED","toLocaleLowerCase","exports","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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