diginext-utils 1.2.3 → 1.2.4
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/dist/Checker.js +0 -6
- package/dist/EventDispatcher.js +2 -14
- package/dist/FileUpload.js +0 -8
- package/dist/Slug.js +17 -18
- package/dist/Timer.js +0 -2
- package/dist/Validation.js +5 -10
- package/dist/array.js +22 -86
- package/dist/backend/file/createDir.js +1 -4
- package/dist/backend/file/fileMove.js +1 -6
- package/dist/backend/file/findFilesByExt.js +1 -8
- package/dist/backend/zip/extractZip.js +4 -0
- package/dist/color.js +14 -36
- package/dist/console/enableConsole.js +0 -4
- package/dist/console/index.js +0 -4
- package/dist/device/browser.js +0 -14
- package/dist/device/camera.js +29 -43
- package/dist/device.js +33 -59
- package/dist/index.js +0 -23
- package/dist/math/diffDate.js +0 -1
- package/dist/math/positiveNumber.js +0 -2
- package/dist/math.js +40 -29
- package/dist/object.js +1 -22
- package/dist/permission/requestCamera.js +8 -11
- package/dist/permission/requestDeviceOrientationControl.js +8 -9
- package/dist/string/formatNumber.js +0 -5
- package/dist/string/generatePassword.js +0 -4
- package/dist/string/generateUUID.js +3 -2
- package/dist/string/name/en.js +3 -4
- package/dist/string/name/vi.js +4 -11
- package/dist/string/random.js +2 -8
- package/dist/string/trimNull.js +0 -7
- package/dist/string/url.js +8 -41
- package/dist/string.js +25 -43
- package/package.json +1 -2
package/dist/string/random.js
CHANGED
|
@@ -11,36 +11,30 @@ exports.numeric = numeric;
|
|
|
11
11
|
const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
12
12
|
exports.punctuation = punctuation;
|
|
13
13
|
const allCharacter = "\u0111\u0110a\xE1\xE0\u1EA3\xE3\u1EA1\u0103\u1EAF\u1EB1\u1EB3\u1EB5\u1EB7\xE2\u1EA5\u1EA7\u1EA9\u1EAB\u1EADe\xE9\xE8\u1EBB\u1EBD\u1EB9\xEA\u1EBF\u1EC1\u1EC3\u1EC5\u1EC7o\xF3\xF2\u1ECF\xF5\u1ECD\xF4\u1ED1\u1ED3\u1ED5\u1ED7\u1ED9\u01A1\u1EDB\u1EDD\u1EDF\u1EE1\u1EE3i\xED\xEC\u1EC9\u0129\u1ECBu\xFA\xF9\u1EE7\u0169\u1EE5\u01B0\u1EE9\u1EEB\u1EED\u1EEF\u1EF1y\xFD\u1EF3\u1EF7\u1EF9\u1EF5A\xC1\xC0\u1EA2\xC3\u1EA0\u0102\u1EAE\u1EB0\u1EB2\u1EB4\u1EB6\xC2\u1EA4\u1EA6\u1EA8\u1EAA\u1EACE\xC9\xC8\u1EBA\u1EBC\u1EB8\xCA\u1EBE\u1EC0\u1EC2\u1EC4\u1EC6O\xD3\xD2\u1ECE\xD5\u1ECC\xD4\u1ED0\u1ED2\u1ED4\u1ED6\u1ED8\u01A0\u1EDA\u1EDC\u1EDE\u1EE0\u1EE2I\xCD\xCC\u1EC8\u0128\u1ECAU\xDA\xD9\u1EE6\u0168\u1EE4\u01AF\u1EE8\u1EEA\u1EEC\u1EEE\u1EF0Y\xDD\u1EF2 !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[]^_`abcdefghijklmnopqrstuvwxyz{|}";
|
|
14
|
+
|
|
14
15
|
/**
|
|
15
16
|
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
16
17
|
* @param {number} length
|
|
17
18
|
* @returns {string}
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
20
|
exports.allCharacter = allCharacter;
|
|
21
|
-
|
|
22
21
|
const randAllCharacterByLength = function randAllCharacterByLength() {
|
|
23
22
|
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
24
23
|
return randomStringByLength(length, allCharacter);
|
|
25
24
|
};
|
|
25
|
+
|
|
26
26
|
/**
|
|
27
27
|
* @param {number} length
|
|
28
28
|
* @param {textLowCase | numeric | punctuation | allCharacter} str
|
|
29
29
|
* @returns {string}
|
|
30
30
|
*/
|
|
31
|
-
|
|
32
|
-
|
|
33
31
|
exports.randAllCharacterByLength = randAllCharacterByLength;
|
|
34
|
-
|
|
35
32
|
const randomStringByLength = function randomStringByLength(length) {
|
|
36
33
|
let str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : textLowCase;
|
|
37
34
|
let result = "";
|
|
38
|
-
|
|
39
35
|
for (let i = 0; i < length; i++) {
|
|
40
36
|
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
41
37
|
}
|
|
42
|
-
|
|
43
38
|
return result;
|
|
44
39
|
};
|
|
45
|
-
|
|
46
40
|
exports.randomStringByLength = randomStringByLength;
|
package/dist/string/trimNull.js
CHANGED
|
@@ -4,19 +4,12 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = trimNull;
|
|
7
|
-
|
|
8
7
|
require("core-js/modules/es.regexp.to-string.js");
|
|
9
|
-
|
|
10
8
|
require("core-js/modules/es.regexp.exec.js");
|
|
11
|
-
|
|
12
9
|
require("core-js/modules/es.string.replace.js");
|
|
13
|
-
|
|
14
10
|
require("core-js/modules/esnext.string.replace-all.js");
|
|
15
|
-
|
|
16
11
|
var _trim = _interopRequireDefault(require("lodash/trim"));
|
|
17
|
-
|
|
18
12
|
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
19
|
-
|
|
20
13
|
function trimNull(str) {
|
|
21
14
|
if (!str) return "";
|
|
22
15
|
str = str.toString();
|
package/dist/string/url.js
CHANGED
|
@@ -4,41 +4,27 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.isLink = exports.isImage = exports.getUrlParams = exports.getFileNameWithoutExtension = exports.getFileNameWithExtension = exports.getFileExtension = exports.addQueryParam = void 0;
|
|
7
|
-
|
|
8
7
|
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
-
|
|
10
|
-
require("core-js/modules/es.string.split.js");
|
|
11
|
-
|
|
12
8
|
require("core-js/modules/es.string.search.js");
|
|
13
|
-
|
|
14
9
|
require("core-js/modules/es.regexp.test.js");
|
|
15
|
-
|
|
16
10
|
require("core-js/modules/es.string.match.js");
|
|
17
|
-
|
|
18
11
|
require("core-js/modules/es.regexp.to-string.js");
|
|
19
|
-
|
|
20
12
|
var _object = require("../object");
|
|
21
|
-
|
|
22
13
|
var urlRegex = /(https?:\/\/[^\s]+)/g;
|
|
23
|
-
|
|
24
14
|
const addQueryParam = (_url, key, value) => {
|
|
25
15
|
_url += (_url.split("?")[1] ? "&" : "?") + "".concat(key, "=").concat(value);
|
|
26
16
|
return _url;
|
|
27
17
|
};
|
|
28
|
-
|
|
29
18
|
exports.addQueryParam = addQueryParam;
|
|
30
|
-
|
|
31
19
|
const getUrlParams = (parameter, staticURL, decode) => {
|
|
32
20
|
if (typeof window == "undefined") return "";
|
|
33
21
|
staticURL = staticURL == undefined ? window.location : staticURL;
|
|
34
22
|
var currLocation = staticURL.length ? staticURL : window.location.search;
|
|
35
23
|
if (currLocation.split("?").length < 2) return "";
|
|
36
24
|
var parArr = currLocation.split("?")[1].split("&"),
|
|
37
|
-
|
|
38
|
-
|
|
25
|
+
returnBool = true;
|
|
39
26
|
for (var i = 0; i < parArr.length; i++) {
|
|
40
27
|
var parr = parArr[i].split("=");
|
|
41
|
-
|
|
42
28
|
if (parr[0] == parameter) {
|
|
43
29
|
return decode ? decodeURIComponent(parr[1]) : parr[1];
|
|
44
30
|
returnBool = true;
|
|
@@ -46,20 +32,19 @@ const getUrlParams = (parameter, staticURL, decode) => {
|
|
|
46
32
|
returnBool = false;
|
|
47
33
|
}
|
|
48
34
|
}
|
|
49
|
-
|
|
50
35
|
if (!returnBool) return false;
|
|
51
36
|
};
|
|
37
|
+
|
|
52
38
|
/**
|
|
53
39
|
*
|
|
54
40
|
* @return {boolean}
|
|
55
41
|
*/
|
|
56
|
-
|
|
57
|
-
|
|
58
42
|
exports.getUrlParams = getUrlParams;
|
|
59
|
-
|
|
60
43
|
const isLink = str => {
|
|
61
44
|
return urlRegex.test(str);
|
|
62
|
-
};
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
// /**
|
|
63
48
|
// *
|
|
64
49
|
// * @return {JSX.Element}
|
|
65
50
|
// */
|
|
@@ -72,74 +57,57 @@ const isLink = str => {
|
|
|
72
57
|
* @param {string} url
|
|
73
58
|
* @return {string}
|
|
74
59
|
*/
|
|
75
|
-
|
|
76
|
-
|
|
77
60
|
exports.isLink = isLink;
|
|
78
|
-
|
|
79
61
|
const getFileNameWithoutExtension = url => {
|
|
80
62
|
url = decodeURIComponent(url);
|
|
81
|
-
|
|
82
63
|
if (url) {
|
|
83
64
|
const m = url.toString().match(/.*\/(.+?)\./);
|
|
84
|
-
|
|
85
65
|
if (m && m.length > 1) {
|
|
86
66
|
return m[1];
|
|
87
67
|
}
|
|
88
|
-
|
|
89
68
|
if (!(0, _object.isNull)(url)) {
|
|
90
69
|
return url.split(".").shift();
|
|
91
70
|
}
|
|
92
71
|
}
|
|
93
|
-
|
|
94
72
|
return "";
|
|
95
73
|
};
|
|
74
|
+
|
|
96
75
|
/**
|
|
97
76
|
*
|
|
98
77
|
* @param {string} url
|
|
99
78
|
* @return {string}
|
|
100
79
|
*/
|
|
101
|
-
|
|
102
|
-
|
|
103
80
|
exports.getFileNameWithoutExtension = getFileNameWithoutExtension;
|
|
104
|
-
|
|
105
81
|
const getFileNameWithExtension = url => {
|
|
106
82
|
url = decodeURIComponent(url);
|
|
107
|
-
|
|
108
83
|
if (url) {
|
|
109
84
|
const m = url.toString().match(/.*\/(.*)$/);
|
|
110
|
-
|
|
111
85
|
if (m && m.length > 1) {
|
|
112
86
|
return m[1].split("/").pop().split("?")[0];
|
|
113
87
|
}
|
|
114
|
-
|
|
115
88
|
if (!(0, _object.isNull)(url)) {
|
|
116
89
|
return url;
|
|
117
90
|
}
|
|
118
91
|
}
|
|
119
|
-
|
|
120
92
|
return "";
|
|
121
93
|
};
|
|
94
|
+
|
|
122
95
|
/**
|
|
123
96
|
*
|
|
124
97
|
* @param {string} url
|
|
125
98
|
* @return {string}
|
|
126
99
|
*/
|
|
127
|
-
|
|
128
|
-
|
|
129
100
|
exports.getFileNameWithExtension = getFileNameWithExtension;
|
|
130
|
-
|
|
131
101
|
const getFileExtension = url => {
|
|
132
102
|
return getFileNameWithExtension(url).split(".").pop();
|
|
133
103
|
};
|
|
104
|
+
|
|
134
105
|
/**
|
|
135
106
|
*
|
|
136
107
|
* @param {string} url
|
|
137
108
|
* @returns
|
|
138
109
|
*/
|
|
139
|
-
|
|
140
|
-
|
|
141
110
|
exports.getFileExtension = getFileExtension;
|
|
142
|
-
|
|
143
111
|
const isImage = url => {
|
|
144
112
|
const arr = ["png", "jpg", "jpeg", "jpe", "jif", "jfif", "gif", "svg"];
|
|
145
113
|
const index = arr.findIndex(item => {
|
|
@@ -147,5 +115,4 @@ const isImage = url => {
|
|
|
147
115
|
});
|
|
148
116
|
return index >= 0;
|
|
149
117
|
};
|
|
150
|
-
|
|
151
118
|
exports.isImage = isImage;
|
package/dist/string.js
CHANGED
|
@@ -4,23 +4,15 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.toUpperCase = exports.toLowerCase = exports.titleize = exports.makeString = exports.getBetween = exports.clearUnicodeCharacters = exports.capitalizeName = exports.capitalize = void 0;
|
|
7
|
-
|
|
8
7
|
require("core-js/modules/es.regexp.constructor.js");
|
|
9
|
-
|
|
10
8
|
require("core-js/modules/es.regexp.exec.js");
|
|
11
|
-
|
|
12
9
|
require("core-js/modules/es.regexp.to-string.js");
|
|
13
|
-
|
|
14
10
|
require("core-js/modules/es.string.replace.js");
|
|
15
|
-
|
|
16
11
|
require("core-js/modules/es.string.trim.js");
|
|
17
|
-
|
|
18
|
-
require("core-js/modules/es.string.split.js");
|
|
19
|
-
|
|
20
12
|
var _object = require("./object");
|
|
21
|
-
|
|
22
13
|
// import { log } from "../../helper/log";
|
|
23
14
|
// import { startCase, toLower } from "lodash";
|
|
15
|
+
|
|
24
16
|
//prettier-ignore
|
|
25
17
|
const char_map = {
|
|
26
18
|
À: "A",
|
|
@@ -304,6 +296,7 @@ const char_map = {
|
|
|
304
296
|
ū: "u",
|
|
305
297
|
ž: "z"
|
|
306
298
|
};
|
|
299
|
+
|
|
307
300
|
/**
|
|
308
301
|
* Get string between str1 and str2 from text
|
|
309
302
|
* @param {string} text
|
|
@@ -311,7 +304,6 @@ const char_map = {
|
|
|
311
304
|
* @param {string} str2
|
|
312
305
|
* @return {string}
|
|
313
306
|
*/
|
|
314
|
-
|
|
315
307
|
const getBetween = function getBetween(text, str1) {
|
|
316
308
|
let str2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
317
309
|
if (!text) return "";
|
|
@@ -320,56 +312,48 @@ const getBetween = function getBetween(text, str1) {
|
|
|
320
312
|
const secondIndex = str2 ? text.indexOf(str2, firstIndex) : text.length;
|
|
321
313
|
return text.substring(firstIndex, secondIndex);
|
|
322
314
|
};
|
|
315
|
+
|
|
323
316
|
/**
|
|
324
317
|
* Convert object to string
|
|
325
318
|
* @param {*} object
|
|
326
319
|
* @return {string}
|
|
327
320
|
*/
|
|
328
|
-
|
|
329
|
-
|
|
330
321
|
exports.getBetween = getBetween;
|
|
331
|
-
|
|
332
322
|
const makeString = function makeString() {
|
|
333
323
|
let object = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
334
324
|
/// Ensure some object is a coerced to a string
|
|
335
325
|
if ((0, _object.isNull)(object)) return "";
|
|
336
326
|
return "" + object;
|
|
337
327
|
};
|
|
328
|
+
|
|
338
329
|
/**
|
|
339
330
|
* toUpperCase
|
|
340
331
|
* @param {*} str
|
|
341
332
|
* @return {string}
|
|
342
333
|
*/
|
|
343
|
-
|
|
344
|
-
|
|
345
334
|
exports.makeString = makeString;
|
|
346
|
-
|
|
347
335
|
const toUpperCase = function toUpperCase() {
|
|
348
336
|
let str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
349
337
|
return makeString(str).toUpperCase();
|
|
350
338
|
};
|
|
339
|
+
|
|
351
340
|
/**
|
|
352
341
|
* toLowerCase
|
|
353
342
|
* @param {*} str
|
|
354
343
|
* @return {string}
|
|
355
344
|
*/
|
|
356
|
-
|
|
357
|
-
|
|
358
345
|
exports.toUpperCase = toUpperCase;
|
|
359
|
-
|
|
360
346
|
const toLowerCase = function toLowerCase() {
|
|
361
347
|
let str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
362
348
|
return makeString(str).toLowerCase();
|
|
363
349
|
};
|
|
350
|
+
|
|
364
351
|
/**
|
|
365
352
|
* toLowerCase
|
|
366
353
|
* @param {*} str
|
|
367
354
|
* @return {string}
|
|
368
355
|
*/
|
|
369
|
-
|
|
370
|
-
|
|
371
356
|
exports.toLowerCase = toLowerCase;
|
|
372
|
-
|
|
373
357
|
const titleize = function titleize() {
|
|
374
358
|
let str = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : "";
|
|
375
359
|
const regString = new RegExp(/(?:^|\s|-)\S/g);
|
|
@@ -377,30 +361,26 @@ const titleize = function titleize() {
|
|
|
377
361
|
return c.toUpperCase();
|
|
378
362
|
});
|
|
379
363
|
};
|
|
364
|
+
|
|
380
365
|
/**
|
|
381
366
|
* Convert only first charater to UpperCase
|
|
382
367
|
* @param {*} str
|
|
383
368
|
* @return {string}
|
|
384
369
|
*/
|
|
385
|
-
|
|
386
|
-
|
|
387
370
|
exports.titleize = titleize;
|
|
388
|
-
|
|
389
371
|
const capitalize = function capitalize(str) {
|
|
390
372
|
let lowercaseRest = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 1;
|
|
391
373
|
str = makeString(str);
|
|
392
374
|
const remainingChars = !lowercaseRest ? str.slice(1) : str.slice(1).toLowerCase();
|
|
393
375
|
return str.charAt(0).toUpperCase() + remainingChars;
|
|
394
376
|
};
|
|
377
|
+
|
|
395
378
|
/**
|
|
396
379
|
* Convert first character from every single words to UpperCase
|
|
397
380
|
* @param {*} str
|
|
398
381
|
* @return {string}
|
|
399
382
|
*/
|
|
400
|
-
|
|
401
|
-
|
|
402
383
|
exports.capitalize = capitalize;
|
|
403
|
-
|
|
404
384
|
const capitalizeName = str => {
|
|
405
385
|
str = makeString(str);
|
|
406
386
|
str = str.trim();
|
|
@@ -412,16 +392,14 @@ const capitalizeName = str => {
|
|
|
412
392
|
}).filter(x => x).join(" ");
|
|
413
393
|
return str;
|
|
414
394
|
};
|
|
395
|
+
|
|
415
396
|
/**
|
|
416
397
|
*
|
|
417
398
|
* @param {string} s - Input string
|
|
418
399
|
* @param {{delimiter,limit,lowercase,replacements,transliterate}} opt - Option
|
|
419
400
|
* @return {string}
|
|
420
401
|
*/
|
|
421
|
-
|
|
422
|
-
|
|
423
402
|
exports.capitalizeName = capitalizeName;
|
|
424
|
-
|
|
425
403
|
const clearUnicodeCharacters = function clearUnicodeCharacters(s) {
|
|
426
404
|
let opt = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
427
405
|
s = makeString(s);
|
|
@@ -431,15 +409,16 @@ const clearUnicodeCharacters = function clearUnicodeCharacters(s) {
|
|
|
431
409
|
lowercase: true,
|
|
432
410
|
replacements: {},
|
|
433
411
|
transliterate: typeof XRegExp === "undefined" ? true : false
|
|
434
|
-
};
|
|
412
|
+
};
|
|
435
413
|
|
|
414
|
+
// Merge options
|
|
436
415
|
for (var k in defaults) {
|
|
437
416
|
if (!opt.hasOwnProperty(k)) {
|
|
438
417
|
opt[k] = defaults[k];
|
|
439
418
|
}
|
|
440
|
-
}
|
|
441
|
-
|
|
419
|
+
}
|
|
442
420
|
|
|
421
|
+
// Vietnamese
|
|
443
422
|
s = s.replace(/á|à|ả|ạ|ã|ă|ắ|ằ|ẳ|ẵ|ặ|â|ấ|ầ|ẩ|ẫ|ậ/gi, "a");
|
|
444
423
|
s = s.replace(/é|è|ẻ|ẽ|ẹ|ê|ế|ề|ể|ễ|ệ/gi, "e");
|
|
445
424
|
s = s.replace(/i|í|ì|ỉ|ĩ|ị/gi, "i");
|
|
@@ -448,29 +427,32 @@ const clearUnicodeCharacters = function clearUnicodeCharacters(s) {
|
|
|
448
427
|
s = s.replace(/ý|ỳ|ỷ|ỹ|ỵ/gi, "y");
|
|
449
428
|
s = s.replace(/đ/gi, "d");
|
|
450
429
|
s = "@" + s + "@";
|
|
451
|
-
s = s.replace(/\@\-|\-\@|\@/gi, "");
|
|
430
|
+
s = s.replace(/\@\-|\-\@|\@/gi, "");
|
|
452
431
|
|
|
432
|
+
// Make custom replacements
|
|
453
433
|
for (var k in opt.replacements) {
|
|
454
434
|
s = s.replace(RegExp(k, "g"), opt.replacements[k]);
|
|
455
|
-
}
|
|
456
|
-
|
|
435
|
+
}
|
|
457
436
|
|
|
437
|
+
// Transliterate characters to ASCII
|
|
458
438
|
if (opt.transliterate) {
|
|
459
439
|
for (var k in char_map) {
|
|
460
440
|
s = s.replace(RegExp(k, "g"), char_map[k]);
|
|
461
441
|
}
|
|
462
|
-
}
|
|
463
|
-
|
|
442
|
+
}
|
|
464
443
|
|
|
444
|
+
// Replace non-alphanumeric characters with our delimiter
|
|
465
445
|
var alnum = typeof XRegExp === "undefined" ? RegExp("[^a-z0-9]+", "ig") : XRegExp("[^\\p{L}\\p{N}]+", "ig");
|
|
466
|
-
s = s.replace(alnum, opt.delimiter);
|
|
446
|
+
s = s.replace(alnum, opt.delimiter);
|
|
467
447
|
|
|
468
|
-
|
|
448
|
+
// Remove duplicate delimiters
|
|
449
|
+
s = s.replace(RegExp("[" + opt.delimiter + "]{2,}", "g"), opt.delimiter);
|
|
469
450
|
|
|
470
|
-
|
|
451
|
+
// Truncate slug to max. characters
|
|
452
|
+
s = s.substring(0, opt.limit);
|
|
471
453
|
|
|
454
|
+
// Remove delimiter from ends
|
|
472
455
|
s = s.replace(RegExp("(^" + opt.delimiter + "|" + opt.delimiter + "$)", "g"), "");
|
|
473
456
|
return opt.lowercase ? s.toLowerCase() : s;
|
|
474
457
|
};
|
|
475
|
-
|
|
476
458
|
exports.clearUnicodeCharacters = clearUnicodeCharacters;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginext-utils",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.4",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "TOP GROUP (a.k.a Digitop)",
|
|
6
6
|
"email": "dev@wearetopgroup.com"
|
|
@@ -31,7 +31,6 @@
|
|
|
31
31
|
]
|
|
32
32
|
},
|
|
33
33
|
"dependencies": {
|
|
34
|
-
"@babel/polyfill": "^7.12.1",
|
|
35
34
|
"@babel/preset-react": "^7.18.6",
|
|
36
35
|
"@babel/runtime": "^7.18.9",
|
|
37
36
|
"babel-plugin-module-resolver": "^4.1.0",
|