diginext-utils 1.0.10 → 1.0.13

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.
@@ -20,7 +20,7 @@ var _math = require("../math");
20
20
  * @param {Array} array
21
21
  * @param {string} key
22
22
  * @returns {Number}
23
- */
23
+ */
24
24
  const sumArray = (array, key) => {
25
25
  if (!array) {
26
26
  console.warn("ARRAY NOT EXITED !");
@@ -45,7 +45,7 @@ const averageArray = (array, key) => {
45
45
  return 0;
46
46
  }
47
47
 
48
- return (void 0).sum(array, key) / array.length || 0;
48
+ return sumArray(array, key) / array.length || 0;
49
49
  };
50
50
  /**
51
51
  *
@@ -1,16 +1,9 @@
1
1
  "use strict";
2
2
 
3
3
  Object.defineProperty(exports, "__esModule", {
4
- value: true,
4
+ value: true
5
5
  });
6
- exports.isLink =
7
- exports.isImage =
8
- exports.getUrlParams =
9
- exports.getFileNameWithoutExtension =
10
- exports.getFileNameWithExtension =
11
- exports.getFileExtension =
12
- exports.addQueryParam =
13
- void 0;
6
+ exports.isLink = exports.isImage = exports.getUrlParams = exports.getFileNameWithoutExtension = exports.getFileNameWithExtension = exports.getFileExtension = exports.addQueryParam = void 0;
14
7
 
15
8
  require("core-js/modules/es.regexp.exec.js");
16
9
 
@@ -29,42 +22,43 @@ var _object = require("../object");
29
22
  var urlRegex = /(https?:\/\/[^\s]+)/g;
30
23
 
31
24
  const addQueryParam = (_url, key, value) => {
32
- _url += (_url.split("?")[1] ? "&" : "?") + "".concat(key, "=").concat(value);
33
- return _url;
25
+ _url += (_url.split("?")[1] ? "&" : "?") + "".concat(key, "=").concat(value);
26
+ return _url;
34
27
  };
35
28
 
36
29
  exports.addQueryParam = addQueryParam;
37
30
 
38
31
  const getUrlParams = (parameter, staticURL, decode) => {
39
- if (typeof window == "undefined") return "";
40
- staticURL = staticURL == undefined ? window.location : staticURL;
41
- var currLocation = staticURL.length ? staticURL : window.location.search;
42
- if (currLocation.split("?").length < 2) return "";
43
- var parArr = currLocation.split("?")[1].split("&"),
44
- returnBool = true;
45
-
46
- for (var i = 0; i < parArr.length; i++) {
47
- var parr = parArr[i].split("=");
48
-
49
- if (parr[0] == parameter) {
50
- return decode ? decodeURIComponent(parr[1]) : parr[1];
51
- returnBool = true;
52
- } else {
53
- returnBool = false;
54
- }
55
- }
56
-
57
- if (!returnBool) return false;
32
+ if (typeof window == "undefined") return "";
33
+ staticURL = staticURL == undefined ? window.location : staticURL;
34
+ var currLocation = staticURL.length ? staticURL : window.location.search;
35
+ if (currLocation.split("?").length < 2) return "";
36
+ var parArr = currLocation.split("?")[1].split("&"),
37
+ returnBool = true;
38
+
39
+ for (var i = 0; i < parArr.length; i++) {
40
+ var parr = parArr[i].split("=");
41
+
42
+ if (parr[0] == parameter) {
43
+ return decode ? decodeURIComponent(parr[1]) : parr[1];
44
+ returnBool = true;
45
+ } else {
46
+ returnBool = false;
47
+ }
48
+ }
49
+
50
+ if (!returnBool) return false;
58
51
  };
59
52
  /**
60
53
  *
61
54
  * @return {boolean}
62
55
  */
63
56
 
57
+
64
58
  exports.getUrlParams = getUrlParams;
65
59
 
66
- const isLink = (str) => {
67
- return urlRegex.test(str);
60
+ const isLink = str => {
61
+ return urlRegex.test(str);
68
62
  }; // /**
69
63
  // *
70
64
  // * @return {JSX.Element}
@@ -79,24 +73,25 @@ const isLink = (str) => {
79
73
  * @return {string}
80
74
  */
81
75
 
76
+
82
77
  exports.isLink = isLink;
83
78
 
84
- const getFileNameWithoutExtension = (url) => {
85
- url = decodeURIComponent(url);
79
+ const getFileNameWithoutExtension = url => {
80
+ url = decodeURIComponent(url);
86
81
 
87
- if (url) {
88
- const m = url.toString().match(/.*\/(.+?)\./);
82
+ if (url) {
83
+ const m = url.toString().match(/.*\/(.+?)\./);
89
84
 
90
- if (m && m.length > 1) {
91
- return m[1];
92
- }
85
+ if (m && m.length > 1) {
86
+ return m[1];
87
+ }
93
88
 
94
- if (!(0, _object.isNull)(url)) {
95
- return url.split(".").shift();
96
- }
97
- }
89
+ if (!(0, _object.isNull)(url)) {
90
+ return url.split(".").shift();
91
+ }
92
+ }
98
93
 
99
- return "";
94
+ return "";
100
95
  };
101
96
  /**
102
97
  *
@@ -104,24 +99,25 @@ const getFileNameWithoutExtension = (url) => {
104
99
  * @return {string}
105
100
  */
106
101
 
102
+
107
103
  exports.getFileNameWithoutExtension = getFileNameWithoutExtension;
108
104
 
109
- const getFileNameWithExtension = (url) => {
110
- url = decodeURIComponent(url);
105
+ const getFileNameWithExtension = url => {
106
+ url = decodeURIComponent(url);
111
107
 
112
- if (url) {
113
- const m = url.toString().match(/.*\/(.*)$/);
108
+ if (url) {
109
+ const m = url.toString().match(/.*\/(.*)$/);
114
110
 
115
- if (m && m.length > 1) {
116
- return m[1].split("/").pop().split("?")[0];
117
- }
111
+ if (m && m.length > 1) {
112
+ return m[1].split("/").pop().split("?")[0];
113
+ }
118
114
 
119
- if (!(0, _object.isNull)(url)) {
120
- return url;
121
- }
122
- }
115
+ if (!(0, _object.isNull)(url)) {
116
+ return url;
117
+ }
118
+ }
123
119
 
124
- return "";
120
+ return "";
125
121
  };
126
122
  /**
127
123
  *
@@ -129,10 +125,11 @@ const getFileNameWithExtension = (url) => {
129
125
  * @return {string}
130
126
  */
131
127
 
128
+
132
129
  exports.getFileNameWithExtension = getFileNameWithExtension;
133
130
 
134
- const getFileExtension = (url) => {
135
- return getFileNameWithExtension(url).split(".").pop();
131
+ const getFileExtension = url => {
132
+ return getFileNameWithExtension(url).split(".").pop();
136
133
  };
137
134
  /**
138
135
  *
@@ -140,14 +137,15 @@ const getFileExtension = (url) => {
140
137
  * @returns
141
138
  */
142
139
 
140
+
143
141
  exports.getFileExtension = getFileExtension;
144
142
 
145
- const isImage = (url) => {
146
- const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
147
- const index = arr.findIndex((item) => {
148
- return (void 0).getFileExtension(url).toLowerCase() == item;
149
- });
150
- return index >= 0;
143
+ const isImage = url => {
144
+ const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
145
+ const index = arr.findIndex(item => {
146
+ return getFileExtension(url).toLowerCase() == item;
147
+ });
148
+ return index >= 0;
151
149
  };
152
150
 
153
- exports.isImage = isImage;
151
+ exports.isImage = isImage;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "diginext-utils",
3
- "version": "1.0.10",
3
+ "version": "1.0.13",
4
4
  "author": {
5
5
  "name": "TOP GROUP (a.k.a Digitop)",
6
6
  "email": "dev@wearetopgroup.com"
@@ -14,7 +14,19 @@
14
14
  "scripts": {
15
15
  "publish": "npm publish",
16
16
  "clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
17
- "build": "rm -rf dist && NODE_ENV=production babel src --out-dir dist --copy-files"
17
+ "build": "rm -rf dist && NODE_ENV=production babel src --out-dir dist --copy-files",
18
+ "watch": "nodemon"
19
+ },
20
+ "nodemonConfig": {
21
+ "exec": "yarn build",
22
+ "watch": [
23
+ "src/*"
24
+ ],
25
+ "ignore": [
26
+ "**/__tests__/**",
27
+ "*.test.js",
28
+ "*.spec.js"
29
+ ]
18
30
  },
19
31
  "dependencies": {
20
32
  "@babel/polyfill": "^7.12.1",