@stryke/string-format 0.6.0 → 0.6.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.
@@ -5,10 +5,11 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.camelCase = camelCase;
7
7
  exports.isCamelCase = isCamelCase;
8
+ var _acronyms = require("./acronyms.cjs");
8
9
  var _lowerCaseFirst = require("./lower-case-first.cjs");
9
10
  var _pascalCase = require("./pascal-case.cjs");
10
11
  function isCamelCase(e) {
11
- return e ? /^[a-z][a-zA-Z0-9]*$/.test(e) : !1;
12
+ return e ? /^[a-z][a-z0-9]*$/.test(e) && _acronyms.ACRONYMS.includes(e) || /^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(e) : !1;
12
13
  }
13
14
  function camelCase(e) {
14
15
  return isCamelCase(e) || e === void 0 ? e : (0, _lowerCaseFirst.lowerCaseFirst)((0, _pascalCase.pascalCase)(e));
@@ -1 +1 @@
1
- import{lowerCaseFirst as r}from"./lower-case-first";import{pascalCase as a}from"./pascal-case";export function isCamelCase(e){return e?/^[a-z][a-zA-Z0-9]*$/.test(e):!1}export function camelCase(e){return isCamelCase(e)||e===void 0?e:r(a(e))}
1
+ import{ACRONYMS as r}from"./acronyms";import{lowerCaseFirst as a}from"./lower-case-first";import{pascalCase as s}from"./pascal-case";export function isCamelCase(e){return e?/^[a-z][a-z0-9]*$/.test(e)&&r.includes(e)||/^(?:[a-z][a-z0-9]*[A-Z]+)*$/.test(e):!1}export function camelCase(e){return isCamelCase(e)||e===void 0?e:a(s(e))}
@@ -7,6 +7,6 @@ exports.CASE_SPLIT_PATTERN = void 0;
7
7
  exports.getWords = getWords;
8
8
  const CASE_SPLIT_PATTERN = exports.CASE_SPLIT_PATTERN = /[A-Z]?[a-z]+|\d+|[A-Z]+(?![a-z])/g;
9
9
  function getWords(r) {
10
- if (r.length > 2e3) throw new Error("The regular expression parameter of `get-words` can't handle strings longer than 2000 characters");
10
+ if (r.length > 5e3) throw new Error("The regular expression parameter of `get-words` can't handle strings longer than 2000 characters");
11
11
  return [...(r.match(CASE_SPLIT_PATTERN) ?? [])];
12
12
  }
@@ -1 +1 @@
1
- export const CASE_SPLIT_PATTERN=/[A-Z]?[a-z]+|\d+|[A-Z]+(?![a-z])/g;export function getWords(r){if(r.length>2e3)throw new Error("The regular expression parameter of `get-words` can't handle strings longer than 2000 characters");return[...r.match(CASE_SPLIT_PATTERN)??[]]}
1
+ export const CASE_SPLIT_PATTERN=/[A-Z]?[a-z]+|\d+|[A-Z]+(?![a-z])/g;export function getWords(r){if(r.length>5e3)throw new Error("The regular expression parameter of `get-words` can't handle strings longer than 2000 characters");return[...r.match(CASE_SPLIT_PATTERN)??[]]}
@@ -5,9 +5,10 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  exports.isPascalCase = isPascalCase;
7
7
  exports.pascalCase = pascalCase;
8
+ var _acronyms = require("./acronyms.cjs");
8
9
  var _getWords = require("./get-words.cjs");
9
10
  function isPascalCase(e) {
10
- return e ? /^[A-Z][a-zA-Z0-9]*$/.test(e) : !1;
11
+ return e ? /^[A-Z][A-Z0-9]*$/.test(e) && _acronyms.ACRONYMS.includes(e) || /^(?:[A-Z][A-Z0-9]*[a-z]+)*$/.test(e) : !1;
11
12
  }
12
13
  function pascalCase(e) {
13
14
  return isPascalCase(e) || e === void 0 ? e : (0, _getWords.getWords)(e).map(r => r.length > 0 ? r.trim().charAt(0).toUpperCase() + r.trim().slice(1) : "").join("");
@@ -1 +1 @@
1
- import{getWords as n}from"./get-words";export function isPascalCase(e){return e?/^[A-Z][a-zA-Z0-9]*$/.test(e):!1}export function pascalCase(e){return isPascalCase(e)||e===void 0?e:n(e).map(r=>r.length>0?r.trim().charAt(0).toUpperCase()+r.trim().slice(1):"").join("")}
1
+ import{ACRONYMS as s}from"./acronyms";import{getWords as t}from"./get-words";export function isPascalCase(e){return e?/^[A-Z][A-Z0-9]*$/.test(e)&&s.includes(e)||/^(?:[A-Z][A-Z0-9]*[a-z]+)*$/.test(e):!1}export function pascalCase(e){return isPascalCase(e)||e===void 0?e:t(e).map(r=>r.length>0?r.trim().charAt(0).toUpperCase()+r.trim().slice(1):"").join("")}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stryke/string-format",
3
- "version": "0.6.0",
3
+ "version": "0.6.2",
4
4
  "type": "module",
5
5
  "description": "A package containing utility functions to transform strings into various formats.",
6
6
  "repository": {
@@ -10,7 +10,7 @@
10
10
  },
11
11
  "private": false,
12
12
  "publishConfig": { "access": "public" },
13
- "dependencies": { "@stryke/helpers": "^0.7.1", "@stryke/types": "^0.8.6" },
13
+ "dependencies": { "@stryke/helpers": "^0.7.1", "@stryke/types": "^0.8.8" },
14
14
  "devDependencies": {},
15
15
  "sideEffects": false,
16
16
  "files": ["dist/**/*"],
@@ -333,5 +333,5 @@
333
333
  "main": "./dist/index.cjs",
334
334
  "module": "./dist/index.mjs",
335
335
  "types": "./dist/index.d.ts",
336
- "gitHead": "57da58e3434302b35f798674d9f18f92ca7f7ac9"
336
+ "gitHead": "7aac00edc2ff843fb756d37cdcaf482e2da4472b"
337
337
  }