@takeshape/util 11.133.4 → 11.134.0
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.
- package/dist/common/relay.d.ts +4 -0
- package/dist/common/strings.d.ts +1 -0
- package/dist/common/strings.js +18 -0
- package/package.json +3 -3
package/dist/common/relay.d.ts
CHANGED
package/dist/common/strings.d.ts
CHANGED
|
@@ -10,6 +10,7 @@ export declare function formatShapeName(str: string[], options: {
|
|
|
10
10
|
* Optional config triggers a namespace-preserving behavior for built-in shapes starting with `TS`.
|
|
11
11
|
*/
|
|
12
12
|
export declare function pascalCase(str: string | string[]): string;
|
|
13
|
+
export declare function pascalCaseWithAbbreviations(str: string | string[]): string;
|
|
13
14
|
export declare function isUuid(str: string): boolean;
|
|
14
15
|
export declare function isEmptyString(str: unknown): boolean;
|
|
15
16
|
export declare function isIntegerLike(value: string | number): boolean;
|
package/dist/common/strings.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
1
|
import { isBrowser } from 'browser-or-node';
|
|
2
2
|
import _camelCase from 'lodash/camelCase.js';
|
|
3
|
+
import deburr from 'lodash/deburr.js';
|
|
3
4
|
import isEmpty from 'lodash/isEmpty.js';
|
|
4
5
|
import isNil from 'lodash/isNil.js';
|
|
5
6
|
import isString from 'lodash/isString.js';
|
|
6
7
|
import upperFirst from 'lodash/upperFirst.js';
|
|
8
|
+
import words from 'lodash/words.js';
|
|
7
9
|
import { ensureArray } from "./arrays.js";
|
|
8
10
|
export const camelCase = _camelCase;
|
|
9
11
|
export function formatShapeName(str, options) {
|
|
@@ -38,6 +40,22 @@ export function formatShapeName(str, options) {
|
|
|
38
40
|
export function pascalCase(str) {
|
|
39
41
|
return upperFirst(camelCase(str));
|
|
40
42
|
}
|
|
43
|
+
/** Used to match apostrophes. */
|
|
44
|
+
const reApos = /['\u2019]/g;
|
|
45
|
+
/** Has caps */
|
|
46
|
+
const reCap = /[A-Z]/;
|
|
47
|
+
export function pascalCaseWithAbbreviations(str) {
|
|
48
|
+
const joined = Array.isArray(str) ? str.join(' ') : str;
|
|
49
|
+
return words(deburr(joined).replace(reApos, '')).reduce((result, word) => {
|
|
50
|
+
// If the word is all uppercase and contains letters,
|
|
51
|
+
// treat it as an abbreviation and keep it uppercase
|
|
52
|
+
if (word === word.toUpperCase() && reCap.test(word)) {
|
|
53
|
+
return result + word;
|
|
54
|
+
}
|
|
55
|
+
// Otherwise, capitalize the word
|
|
56
|
+
return result + (word.charAt(0).toUpperCase() + word.slice(1).toLowerCase());
|
|
57
|
+
}, '');
|
|
58
|
+
}
|
|
41
59
|
export function isUuid(str) {
|
|
42
60
|
return Boolean(/\w{8,}(-\w{4,}){3,}-\w{12,}/.exec(str));
|
|
43
61
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@takeshape/util",
|
|
3
|
-
"version": "11.
|
|
3
|
+
"version": "11.134.0",
|
|
4
4
|
"description": "Shared utilities",
|
|
5
5
|
"homepage": "https://www.takeshape.io",
|
|
6
6
|
"repository": {
|
|
@@ -45,8 +45,8 @@
|
|
|
45
45
|
"tiny-invariant": "1.3.3",
|
|
46
46
|
"uint8array-extras": "1.4.0",
|
|
47
47
|
"url-parse": "1.5.3",
|
|
48
|
-
"@takeshape/prism": "11.
|
|
49
|
-
"@takeshape/routing": "11.
|
|
48
|
+
"@takeshape/prism": "11.134.0",
|
|
49
|
+
"@takeshape/routing": "11.134.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/classnames": "2.2.11",
|