@hestia-earth/utils 0.14.6 → 0.14.8
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/string.d.ts +8 -1
- package/dist/string.js +30 -5
- package/package.json +1 -1
package/dist/string.d.ts
CHANGED
|
@@ -8,12 +8,19 @@
|
|
|
8
8
|
export declare const ellipsis: (text?: string, maxlength?: number) => string;
|
|
9
9
|
export declare const keyToLabel: (key: string) => string;
|
|
10
10
|
/**
|
|
11
|
-
* Convert a
|
|
11
|
+
* Convert a string to dash-case.
|
|
12
12
|
*
|
|
13
13
|
* @param value The original value.
|
|
14
14
|
* @returns A dash case version of the value.
|
|
15
15
|
*/
|
|
16
16
|
export declare const toDashCase: (value?: string) => string;
|
|
17
|
+
/**
|
|
18
|
+
* Convert a string to camelCase.
|
|
19
|
+
*
|
|
20
|
+
* @param value The original value.
|
|
21
|
+
* @returns A camel case version of the value.
|
|
22
|
+
*/
|
|
23
|
+
export declare const toCamelCase: (value?: string) => string;
|
|
17
24
|
/**
|
|
18
25
|
* Returns current date in YYYY-MM-DD format.
|
|
19
26
|
*
|
package/dist/string.js
CHANGED
|
@@ -16,7 +16,7 @@ var __read = (this && this.__read) || function (o, n) {
|
|
|
16
16
|
return ar;
|
|
17
17
|
};
|
|
18
18
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
19
|
-
exports.parseCitation = exports.parseMarkdownLink = exports.now = exports.toDashCase = exports.keyToLabel = exports.ellipsis = void 0;
|
|
19
|
+
exports.parseCitation = exports.parseMarkdownLink = exports.now = exports.toCamelCase = exports.toDashCase = exports.keyToLabel = exports.ellipsis = void 0;
|
|
20
20
|
/**
|
|
21
21
|
* Trims the string to a certain max length and replace with `...`.
|
|
22
22
|
*
|
|
@@ -38,7 +38,7 @@ var keyToLabel = function (key) {
|
|
|
38
38
|
};
|
|
39
39
|
exports.keyToLabel = keyToLabel;
|
|
40
40
|
/**
|
|
41
|
-
* Convert a
|
|
41
|
+
* Convert a string to dash-case.
|
|
42
42
|
*
|
|
43
43
|
* @param value The original value.
|
|
44
44
|
* @returns A dash case version of the value.
|
|
@@ -67,6 +67,26 @@ var toDashCase = function (value) {
|
|
|
67
67
|
: null;
|
|
68
68
|
};
|
|
69
69
|
exports.toDashCase = toDashCase;
|
|
70
|
+
/**
|
|
71
|
+
* Convert a string to camelCase.
|
|
72
|
+
*
|
|
73
|
+
* @param value The original value.
|
|
74
|
+
* @returns A camel case version of the value.
|
|
75
|
+
*/
|
|
76
|
+
var toCamelCase = function (value) {
|
|
77
|
+
return value
|
|
78
|
+
? value
|
|
79
|
+
.replace(/^[_.\- ]+/, '')
|
|
80
|
+
.toLowerCase()
|
|
81
|
+
.replace(/[_.\- ]+(\w|$)/g, function (_, p1) { return p1.toUpperCase(); })
|
|
82
|
+
.replace(/\d+(\w|$)/g, function (m) { return m.toUpperCase(); })
|
|
83
|
+
.replace(/[(),\s]/g, '')
|
|
84
|
+
.replace(/[>:]/g, '-')
|
|
85
|
+
.normalize('NFD')
|
|
86
|
+
.replace(/[\u0300-\u036f]/g, '')
|
|
87
|
+
: null;
|
|
88
|
+
};
|
|
89
|
+
exports.toCamelCase = toCamelCase;
|
|
70
90
|
/**
|
|
71
91
|
* Returns current date in YYYY-MM-DD format.
|
|
72
92
|
*
|
|
@@ -93,9 +113,14 @@ exports.parseMarkdownLink = parseMarkdownLink;
|
|
|
93
113
|
* @returns
|
|
94
114
|
*/
|
|
95
115
|
var parseCitation = function (value) {
|
|
96
|
-
var _a;
|
|
116
|
+
var _a, _b;
|
|
97
117
|
var parsed = exports.parseMarkdownLink(value);
|
|
98
|
-
var
|
|
99
|
-
return {
|
|
118
|
+
var _c = __read(parsed.title.match(/(.*[(]\d+[)][\.|\s])?(.*)/), 3), original = _c[0], name = _c[1], title = _c[2];
|
|
119
|
+
return {
|
|
120
|
+
original: original,
|
|
121
|
+
name: (_a = name === null || name === void 0 ? void 0 : name.trim()) === null || _a === void 0 ? void 0 : _a.replace(/\.$/, ''),
|
|
122
|
+
title: (_b = title === null || title === void 0 ? void 0 : title.trim()) === null || _b === void 0 ? void 0 : _b.replace(/\.$/, ''),
|
|
123
|
+
link: parsed.link
|
|
124
|
+
};
|
|
100
125
|
};
|
|
101
126
|
exports.parseCitation = parseCitation;
|