{"version":3,"file":"index.mjs","sources":[""],"sourcesContent":["export type TIsJSONArgs = Parameters<typeof isJSON>;\r\n\r\nexport type TIsJSONReturn = ReturnType<typeof isJSON>;\r\n\r\n/**\r\n * Checks if a string is a valid JSON string\r\n * @param {string} str source String\r\n * @returns {boolean}\r\n * @example\r\n * // How to check if string is a JSON?\r\n * const str = '{ \"hello\": \"world\" }';\r\n * const isStrJSON = isJSON(str);\n * console.log(isStrJSON); // => true\n * @example\n * // Validate JSON entered into a configuration editor before saving\n * saveButton.disabled = !isJSON(editor.value);\n */\nexport const isJSON = (str: unknown): boolean => {\r\n  if (typeof str === \"string\" && str.length) {\n    try {\n      JSON.parse(str);\n      return true;\n      // eslint-disable-next-line no-unused-vars\r\n    } catch (_err) {\r\n      return false;\r\n    }\r\n  }\r\n  return false;\r\n};\r\n"],"names":["isJSON","str","length","JSON","parse","_err"],"mappings":"AAiBO,MAAMA,OAAUC,MACrB,UAAWA,MAAQ,UAAYA,IAAIC,OACjC,IACEC,KAAKC,MAAMH,KACX,OAAO,IAET,CAAE,MAAOI,MACP,OAAO,KACT,CAEF,OAAO"}