@mapomodule/utils 1.0.0-alpha.15 → 1.0.0-alpha.30

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 CHANGED
@@ -3,6 +3,44 @@
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.30](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.29...v1.0.0-alpha.30) (2022-09-13)
7
+
8
+
9
+ ### Bug Fixes
10
+
11
+ * **auth:** removed js set cookie helpers since mapo login is http-only cookie based now ([6328c13](https://github.com/lotrekagency/mapo/commit/6328c13bec39d8e312f9dd4c33c53182fd64e6ed))
12
+
13
+
14
+ ### Features
15
+
16
+ * added memoized debounce ([3c9a025](https://github.com/lotrekagency/mapo/commit/3c9a02509ffd8277d362c30eb2cfafabdde995b7))
17
+
18
+
19
+
20
+
21
+
22
+ # [1.0.0-alpha.23](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.22...v1.0.0-alpha.23) (2022-05-04)
23
+
24
+
25
+ ### Bug Fixes
26
+
27
+ * **utils:** better File recognition for deepClone util ([72a1002](https://github.com/lotrekagency/mapo/commit/72a1002144ff0be1c016a39f46f8ea712a950825))
28
+
29
+
30
+
31
+
32
+
33
+ # [1.0.0-alpha.22](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.21...v1.0.0-alpha.22) (2022-05-01)
34
+
35
+
36
+ ### Features
37
+
38
+ * big code refactor and improovements to fields management ([a818d8b](https://github.com/lotrekagency/mapo/commit/a818d8b891dbb4892f50267d6355c41297e2c6c6))
39
+
40
+
41
+
42
+
43
+
6
44
  # [1.0.0-alpha.15](https://github.com/lotrekagency/mapo/compare/v1.0.0-alpha.14...v1.0.0-alpha.15) (2022-03-11)
7
45
 
8
46
 
@@ -1,7 +1,8 @@
1
1
  function debounce(func, wait, immediate) {
2
2
  var timeout;
3
3
  return function () {
4
- var context = this, args = arguments;
4
+ var context = this,
5
+ args = arguments;
5
6
  var later = function () {
6
7
  timeout = null;
7
8
  if (!immediate) func.apply(context, args);
@@ -11,8 +12,31 @@ function debounce(func, wait, immediate) {
11
12
  timeout = setTimeout(later, wait);
12
13
  if (callNow) func.apply(context, args);
13
14
  };
14
- };
15
+ }
16
+
17
+ function memoizedDebounce(
18
+ func,
19
+ wait,
20
+ immediate,
21
+ argsSerializer = (args) => JSON.stringify(args)
22
+ ) {
23
+ var timeout = {};
24
+ return function () {
25
+ var context = this,
26
+ args = arguments,
27
+ serializedArgs = argsSerializer(arguments);
28
+ var later = function () {
29
+ timeout[serializedArgs] = null;
30
+ if (!immediate) func.apply(context, args);
31
+ };
32
+ var callNow = immediate && !timeout[serializedArgs];
33
+ clearTimeout(timeout[serializedArgs]);
34
+ timeout[serializedArgs] = setTimeout(later, wait);
35
+ if (callNow) func.apply(context, args);
36
+ };
37
+ }
15
38
 
16
39
  module.exports = {
17
- debounce
18
- }
40
+ debounce,
41
+ memoizedDebounce,
42
+ };
@@ -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
  }
@@ -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] instanceof File) && !(obj[i] instanceof Date)) {
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];
@@ -0,0 +1,9 @@
1
+ function nameSpacedSlots(slots, scope) {
2
+ return Object.keys(slots)
3
+ .filter((name) => name.startsWith(scope))
4
+ .map((name) => name.replace(scope, ""));
5
+ }
6
+
7
+ module.exports = {
8
+ nameSpacedSlots
9
+ }
package/package.json CHANGED
@@ -1,16 +1,13 @@
1
1
  {
2
2
  "name": "@mapomodule/utils",
3
- "version": "1.0.0-alpha.15",
3
+ "version": "1.0.0-alpha.30",
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>",
7
7
  "repository": "https://github.com/lotrekagency/mapo",
8
8
  "main": "./index.js",
9
- "dependencies": {
10
- "js-cookie": "^2.2.1"
11
- },
12
9
  "publishConfig": {
13
10
  "access": "public"
14
11
  },
15
- "gitHead": "cd42b3dd094ef3bf743c67819e6059bf9ccac491"
12
+ "gitHead": "f648aac2fc02b28e687f4631cfbaf4cde6999a8b"
16
13
  }
package/helpers/auth.js DELETED
@@ -1,21 +0,0 @@
1
- const Cookies = require('js-cookie')
2
-
3
- const TokenKey = '__mapo_session'
4
-
5
- function getToken() {
6
- return Cookies.get(TokenKey)
7
- }
8
-
9
- function setToken(token) {
10
- return Cookies.set(TokenKey, token)
11
- }
12
-
13
- function removeToken() {
14
- return Cookies.remove(TokenKey)
15
- }
16
-
17
- module.exports = {
18
- getToken,
19
- setToken,
20
- removeToken
21
- }