@mapomodule/utils 1.0.0-alpha.13 → 1.0.0-alpha.23
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/CHANGELOG.md +33 -0
- package/helpers/formatters.js +27 -2
- package/helpers/objHelpers.js +3 -3
- package/helpers/slots.js +9 -0
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,39 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
# [1.0.0-alpha.23](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2022-05-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **utils:** better File recognition for deepClone util ([72a1002](https://github.com/lotrekagency/mapo/commit/72a1002144ff0be1c016a39f46f8ea712a950825))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
# [1.0.0-alpha.22](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2022-05-01)
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
### Features
|
|
21
|
+
|
|
22
|
+
* big code refactor and improovements to fields management ([a818d8b](https://github.com/lotrekagency/mapo/commit/a818d8b891dbb4892f50267d6355c41297e2c6c6))
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
# [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
### Features
|
|
32
|
+
|
|
33
|
+
* enhance findPropPaths to deal also with arrays indexes ([158a9aa](https://github.com/lotrekagency/mapo/commit/158a9aa9329defbecbb39e1f19df2855dd3ece01))
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
|
|
6
39
|
# [1.0.0-alpha.13](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.12...v1.0.0-alpha.13) (2022-03-01)
|
|
7
40
|
|
|
8
41
|
|
package/helpers/formatters.js
CHANGED
|
@@ -20,8 +20,33 @@ function humanFileSize(bytes, si = false, dp = 1) {
|
|
|
20
20
|
);
|
|
21
21
|
|
|
22
22
|
return bytes.toFixed(dp) + " " + units[u];
|
|
23
|
-
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
function slugify(str) {
|
|
26
|
+
str = str || "";
|
|
27
|
+
str = str.replace(/^\s+|\s+$/g, ''); // trim
|
|
28
|
+
str = str.toLowerCase();
|
|
29
|
+
|
|
30
|
+
// remove accents, swap ñ for n, etc
|
|
31
|
+
var from = "àáäâèéëêìíïîòóöôùúüûñç·/_,:;";
|
|
32
|
+
var to = "aaaaeeeeiiiioooouuuunc------";
|
|
33
|
+
for (var i = 0, l = from.length; i < l; i++) {
|
|
34
|
+
str = str.replace(new RegExp(from.charAt(i), 'g'), to.charAt(i));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
str = str.replace(/[^a-z0-9 -]/g, '') // remove invalid chars
|
|
38
|
+
.replace(/\s+/g, '-') // collapse whitespace and replace by -
|
|
39
|
+
.replace(/-+/g, '-'); // collapse dashes
|
|
40
|
+
|
|
41
|
+
return str;
|
|
42
|
+
};
|
|
43
|
+
|
|
44
|
+
function titleCase(string) {
|
|
45
|
+
return (string && string[0].toUpperCase() + string.slice(1).toLowerCase()) || "";
|
|
46
|
+
};
|
|
24
47
|
|
|
25
48
|
module.exports = {
|
|
26
|
-
humanFileSize
|
|
49
|
+
humanFileSize,
|
|
50
|
+
slugify,
|
|
51
|
+
titleCase,
|
|
27
52
|
}
|
package/helpers/objHelpers.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function deepClone(obj) {
|
|
2
2
|
const clone = obj instanceof Array ? Object.assign([]) : Object.assign({});
|
|
3
3
|
for (const i in obj) {
|
|
4
|
-
if (obj[i] != null && typeof (obj[i]) == 'object' && !(obj[i]
|
|
4
|
+
if (obj[i] != null && typeof (obj[i]) == 'object' && !(isFileOrBlob(obj[i])) && !(obj[i] instanceof Date)) {
|
|
5
5
|
clone[i] = deepClone(obj[i]);
|
|
6
6
|
} else {
|
|
7
7
|
clone[i] = obj[i];
|
|
@@ -63,14 +63,14 @@ function findPropPaths(obj, predicate) {
|
|
|
63
63
|
throw new TypeError("Predicate is not a function");
|
|
64
64
|
}
|
|
65
65
|
(function find(obj) {
|
|
66
|
-
for (const key
|
|
66
|
+
for (const key in obj) {
|
|
67
67
|
if (predicate({ val: obj[key], obj, path, key }) === true) {
|
|
68
68
|
path.push(key);
|
|
69
69
|
results.push(path.join("."));
|
|
70
70
|
path.pop();
|
|
71
71
|
}
|
|
72
72
|
const o = obj[key];
|
|
73
|
-
if (o && typeof o === "object"
|
|
73
|
+
if (o && typeof o === "object") {
|
|
74
74
|
if (!discoveredObjects.find(obj => obj === o)) {
|
|
75
75
|
path.push(key);
|
|
76
76
|
discoveredObjects.push(o);
|
package/helpers/slots.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/utils",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
3
|
+
"version": "1.0.0-alpha.23",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"description": "This is part of Mapo nuxt module. Provides a set of utils for the project.",
|
|
6
6
|
"author": "bnznamco <gabriele.baldi.01@gmail.com>",
|
|
@@ -12,5 +12,5 @@
|
|
|
12
12
|
"publishConfig": {
|
|
13
13
|
"access": "public"
|
|
14
14
|
},
|
|
15
|
-
"gitHead": "
|
|
15
|
+
"gitHead": "19399823330cb0123d2b224e857fb3094351df95"
|
|
16
16
|
}
|