@appsemble/utils 0.21.0 → 0.21.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.
- package/README.md +3 -3
- package/convertToCsv.js +1 -1
- package/normalize.js +2 -2
- package/package.json +3 -3
- package/pem.js +3 -3
- package/remap.js +1 -1
- package/string.js +2 -2
package/README.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
#  Appsemble Utilities
|
|
2
2
|
|
|
3
3
|
> Internal utility functions used across multiple Appsemble projects.
|
|
4
4
|
|
|
5
5
|
[](https://www.npmjs.com/package/@appsemble/utils)
|
|
6
|
-
[](https://gitlab.com/appsemble/appsemble/-/releases/0.21.2)
|
|
7
7
|
[](https://prettier.io)
|
|
8
8
|
|
|
9
9
|
## Table of Contents
|
|
@@ -26,5 +26,5 @@ not guaranteed.
|
|
|
26
26
|
|
|
27
27
|
## License
|
|
28
28
|
|
|
29
|
-
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.21.
|
|
29
|
+
[LGPL-3.0-only](https://gitlab.com/appsemble/appsemble/-/blob/0.21.2/LICENSE.md) ©
|
|
30
30
|
[Appsemble](https://appsemble.com)
|
package/convertToCsv.js
CHANGED
|
@@ -13,7 +13,7 @@ export function convertToCsv(body) {
|
|
|
13
13
|
const quote = '"';
|
|
14
14
|
const quoteRegex = new RegExp(quote, 'g');
|
|
15
15
|
const escape = (value) => value.includes(separator) || value.includes(lineEnd) || value.includes(quote)
|
|
16
|
-
? `${quote}${value.
|
|
16
|
+
? `${quote}${value.replaceAll(quoteRegex, `${quote}${quote}`)}${quote}`
|
|
17
17
|
: value;
|
|
18
18
|
if (body == null) {
|
|
19
19
|
throw new Error('No data');
|
package/normalize.js
CHANGED
|
@@ -14,11 +14,11 @@ export function normalize(input, stripTrailingHyphen = true) {
|
|
|
14
14
|
const normalized = input
|
|
15
15
|
// Normalize accents. https://stackoverflow.com/a/37511463/1154610
|
|
16
16
|
.normalize('NFD')
|
|
17
|
-
.
|
|
17
|
+
.replaceAll(/[\u0300-\u036F]/g, '')
|
|
18
18
|
// Make it lower case.
|
|
19
19
|
.toLowerCase()
|
|
20
20
|
// Replace any non-alphanumeric with single hyphens them at the start.
|
|
21
|
-
.
|
|
21
|
+
.replaceAll(/[^\da-z]+/g, (match, index) => (index ? '-' : ''));
|
|
22
22
|
return stripTrailingHyphen ? normalized.replace(/-$/, '') : normalized;
|
|
23
23
|
}
|
|
24
24
|
//# sourceMappingURL=normalize.js.map
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@appsemble/utils",
|
|
3
|
-
"version": "0.21.
|
|
3
|
+
"version": "0.21.2",
|
|
4
4
|
"description": "Utility functions used in Appsemble internally",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -31,7 +31,7 @@
|
|
|
31
31
|
"test": "vitest"
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@appsemble/types": "0.21.
|
|
34
|
+
"@appsemble/types": "0.21.2",
|
|
35
35
|
"axios": "^1.0.0",
|
|
36
36
|
"cron-parser": "^4.0.0",
|
|
37
37
|
"date-fns": "^2.0.0",
|
|
@@ -45,7 +45,7 @@
|
|
|
45
45
|
"openapi-types": "^12.0.0",
|
|
46
46
|
"parse-duration": "^1.0.0",
|
|
47
47
|
"postcss": "^8.0.0",
|
|
48
|
-
"type-fest": "^
|
|
48
|
+
"type-fest": "^4.0.0"
|
|
49
49
|
},
|
|
50
50
|
"devDependencies": {
|
|
51
51
|
"@types/langmap": "^0.0.1",
|
package/pem.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
export function stripPem(pem, removeNewlines = false) {
|
|
2
2
|
return pem
|
|
3
|
-
.
|
|
4
|
-
.
|
|
5
|
-
.
|
|
3
|
+
.replaceAll(/^[\s-]*BEGIN [A-Z]+[\s-]*/g, '')
|
|
4
|
+
.replaceAll(/[\s-]*END [A-Z]+[\s-]*$/g, '')
|
|
5
|
+
.replaceAll(/\r?\n/g, removeNewlines ? '' : '\n')
|
|
6
6
|
.trim();
|
|
7
7
|
}
|
|
8
8
|
export function wrapPem(pem, type) {
|
package/remap.js
CHANGED
|
@@ -324,7 +324,7 @@ const mapperImplementations = {
|
|
|
324
324
|
},
|
|
325
325
|
'string.replace'(values, input) {
|
|
326
326
|
const [[regex, replacer]] = Object.entries(values);
|
|
327
|
-
return String(input).
|
|
327
|
+
return String(input).replaceAll(new RegExp(regex, 'gm'), replacer);
|
|
328
328
|
},
|
|
329
329
|
translate(messageId, input, context) {
|
|
330
330
|
const message = context.getMessage({ id: messageId });
|
package/string.js
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* @returns The input, but hyphenated.
|
|
6
6
|
*/
|
|
7
7
|
export function camelToHyphen(string) {
|
|
8
|
-
return string.
|
|
8
|
+
return string.replaceAll(/[A-Z]/g, (match) => `-${match.toLowerCase()}`);
|
|
9
9
|
}
|
|
10
10
|
/**
|
|
11
11
|
* Convert a string to upper case.
|
|
@@ -25,6 +25,6 @@ export function toUpperCase(input) {
|
|
|
25
25
|
* @returns The escaped JSON pointer segment.
|
|
26
26
|
*/
|
|
27
27
|
export function decodeJSONRef(ref) {
|
|
28
|
-
return decodeURIComponent(ref).
|
|
28
|
+
return decodeURIComponent(ref).replaceAll('~1', '/').replaceAll('~0', '~');
|
|
29
29
|
}
|
|
30
30
|
//# sourceMappingURL=string.js.map
|