UNPKG

@web3r/flowerkit

Version:

Tree-shakable JavaScript and TypeScript utility library for frontend/browser apps: DOM, events, arrays, objects, strings, date, JSON, and network helpers (ESM/CJS, SSR-friendly).

1 lines 1.16 kB
{"version":3,"file":"index.cjs","sources":[""],"sourcesContent":["export type TIsStrInSnakeCaseArgs = Parameters<typeof isStrInSnakeCase>;\r\n\r\nexport type TIsStrInSnakeCaseReturn = ReturnType<typeof isStrInSnakeCase>;\r\n\r\n/**\r\n * Checks if a string is in snake_case.\r\n * Rules:\r\n * Lowercase letters separated by single underscores\r\n * No leading or trailing underscore\r\n *\r\n * @param {string} str Source string\r\n * @returns {boolean} True if string is snake_case\r\n * @throws {TypeError} If str is not a string\r\n * @example\r\n * isStrInSnakeCase(\"good_snake\"); // true\r\n */\r\nexport const isStrInSnakeCase = (str: string): boolean => {\r\n if (typeof str !== \"string\") {\r\n throw new TypeError(\"isStrInSnakeCase: str must be a string\");\r\n }\r\n // eslint-disable-next-line security/detect-unsafe-regex\r\n const pattern = /^[a-z]+(?:_[a-z]+)*$/;\r\n return !!str.length && pattern.test(str);\r\n};\r\n"],"names":["isStrInSnakeCase","str","TypeError","pattern","length","test"],"mappings":";;;;;;;;;;;;GAgBO,MAAMA,iBAAoBC,MAC/B,UAAWA,MAAQ,SACjB,MAAM,IAAIC,UAAU;wDAGtB;MAAMC,QAAU,uBAChB,QAASF,IAAIG,QAAUD,QAAQE,KAAKJ"}