@mapomodule/utils 1.0.0-alpha.23 → 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 +16 -0
- package/helpers/debounce.js +28 -4
- package/package.json +2 -5
- package/helpers/auth.js +0 -21
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,22 @@
|
|
|
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
|
+
|
|
6
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)
|
|
7
23
|
|
|
8
24
|
|
package/helpers/debounce.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
function debounce(func, wait, immediate) {
|
|
2
2
|
var timeout;
|
|
3
3
|
return function () {
|
|
4
|
-
var context = this,
|
|
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
|
+
};
|
package/package.json
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@mapomodule/utils",
|
|
3
|
-
"version": "1.0.0-alpha.
|
|
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": "
|
|
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
|
-
}
|