diginext-utils 1.0.14 → 1.1.1
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.
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = diffDate;
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
*
|
|
10
|
+
* @param {string} date1
|
|
11
|
+
* @param {string} date2
|
|
12
|
+
* @returns
|
|
13
|
+
*/
|
|
14
|
+
function diffDate(date1, date2) {
|
|
15
|
+
date1 = date1 || new Date();
|
|
16
|
+
date2 = date2 || new Date();
|
|
17
|
+
return (new Date(date2).getTime() - new Date(date1).getTime()) / (24 * 60 * 60 * 1000);
|
|
18
|
+
}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = formatNumber;
|
|
7
|
+
|
|
8
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.string.replace.js");
|
|
11
|
+
|
|
12
|
+
require("core-js/modules/es.regexp.to-string.js");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @param {Number} num
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
function formatNumber(num) {
|
|
20
|
+
const numRound = Math.round((num + Number.EPSILON) * 100) / 100;
|
|
21
|
+
return !num ? 0 : "" + numRound.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g, "$1,");
|
|
22
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.default = generatePassword;
|
|
7
|
+
|
|
8
|
+
require("core-js/modules/es.regexp.exec.js");
|
|
9
|
+
|
|
10
|
+
require("core-js/modules/es.string.replace.js");
|
|
11
|
+
|
|
12
|
+
var _random = require("./random");
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* random password
|
|
16
|
+
* - if hard = true -> random punctuation inside
|
|
17
|
+
* @param {*} length
|
|
18
|
+
* @param {Boolean} hard
|
|
19
|
+
* @returns
|
|
20
|
+
*/
|
|
21
|
+
function generatePassword() {
|
|
22
|
+
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 6;
|
|
23
|
+
let hard = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : true;
|
|
24
|
+
if (!Number.isFinite(length)) length = 6;
|
|
25
|
+
if (length <= 0) length = 6;
|
|
26
|
+
let pass = (0, _random.randomStringByLength)(length, _random.textLowCase + _random.textLowCase.toUpperCase() + _random.numeric);
|
|
27
|
+
if (hard) pass = pass.replace(pass[Math.floor(pass.length / 2)], (0, _random.randomStringByLength)(1, _random.punctuation));
|
|
28
|
+
return pass;
|
|
29
|
+
}
|
|
@@ -4,6 +4,8 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.default = generateUUID;
|
|
7
|
+
//prettier-ignore
|
|
8
|
+
const _lut = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff'];
|
|
7
9
|
|
|
8
10
|
function generateUUID() {
|
|
9
11
|
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/21963136#21963136
|
package/dist/string/index.js
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.toUpperCase = exports.toLowerCase = exports.titleize = exports.
|
|
6
|
+
exports.toUpperCase = exports.toLowerCase = exports.titleize = exports.makeString = exports.getBetween = exports.clearUnicodeCharacters = exports.capitalizeName = exports.capitalize = void 0;
|
|
7
7
|
|
|
8
8
|
require("core-js/modules/es.regexp.constructor.js");
|
|
9
9
|
|
|
@@ -21,15 +21,7 @@ var _object = require("../object");
|
|
|
21
21
|
|
|
22
22
|
// import { log } from "../../helper/log";
|
|
23
23
|
// import { startCase, toLower } from "lodash";
|
|
24
|
-
|
|
25
|
-
exports.textLowCase = textLowCase;
|
|
26
|
-
const numeric = "0123456789";
|
|
27
|
-
exports.numeric = numeric;
|
|
28
|
-
const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
29
|
-
exports.punctuation = punctuation;
|
|
30
|
-
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{|}"; //prettier-ignore
|
|
31
|
-
|
|
32
|
-
exports.allCharacter = allCharacter;
|
|
24
|
+
//prettier-ignore
|
|
33
25
|
const char_map = {
|
|
34
26
|
À: "A",
|
|
35
27
|
Á: "A",
|
|
@@ -311,37 +303,6 @@ const char_map = {
|
|
|
311
303
|
š: "s",
|
|
312
304
|
ū: "u",
|
|
313
305
|
ž: "z"
|
|
314
|
-
}; //prettier-ignore
|
|
315
|
-
|
|
316
|
-
const _lut = ['00', '01', '02', '03', '04', '05', '06', '07', '08', '09', '0a', '0b', '0c', '0d', '0e', '0f', '10', '11', '12', '13', '14', '15', '16', '17', '18', '19', '1a', '1b', '1c', '1d', '1e', '1f', '20', '21', '22', '23', '24', '25', '26', '27', '28', '29', '2a', '2b', '2c', '2d', '2e', '2f', '30', '31', '32', '33', '34', '35', '36', '37', '38', '39', '3a', '3b', '3c', '3d', '3e', '3f', '40', '41', '42', '43', '44', '45', '46', '47', '48', '49', '4a', '4b', '4c', '4d', '4e', '4f', '50', '51', '52', '53', '54', '55', '56', '57', '58', '59', '5a', '5b', '5c', '5d', '5e', '5f', '60', '61', '62', '63', '64', '65', '66', '67', '68', '69', '6a', '6b', '6c', '6d', '6e', '6f', '70', '71', '72', '73', '74', '75', '76', '77', '78', '79', '7a', '7b', '7c', '7d', '7e', '7f', '80', '81', '82', '83', '84', '85', '86', '87', '88', '89', '8a', '8b', '8c', '8d', '8e', '8f', '90', '91', '92', '93', '94', '95', '96', '97', '98', '99', '9a', '9b', '9c', '9d', '9e', '9f', 'a0', 'a1', 'a2', 'a3', 'a4', 'a5', 'a6', 'a7', 'a8', 'a9', 'aa', 'ab', 'ac', 'ad', 'ae', 'af', 'b0', 'b1', 'b2', 'b3', 'b4', 'b5', 'b6', 'b7', 'b8', 'b9', 'ba', 'bb', 'bc', 'bd', 'be', 'bf', 'c0', 'c1', 'c2', 'c3', 'c4', 'c5', 'c6', 'c7', 'c8', 'c9', 'ca', 'cb', 'cc', 'cd', 'ce', 'cf', 'd0', 'd1', 'd2', 'd3', 'd4', 'd5', 'd6', 'd7', 'd8', 'd9', 'da', 'db', 'dc', 'dd', 'de', 'df', 'e0', 'e1', 'e2', 'e3', 'e4', 'e5', 'e6', 'e7', 'e8', 'e9', 'ea', 'eb', 'ec', 'ed', 'ee', 'ef', 'f0', 'f1', 'f2', 'f3', 'f4', 'f5', 'f6', 'f7', 'f8', 'f9', 'fa', 'fb', 'fc', 'fd', 'fe', 'ff'];
|
|
317
|
-
/**
|
|
318
|
-
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
319
|
-
* @param {number} length
|
|
320
|
-
* @returns {string}
|
|
321
|
-
*/
|
|
322
|
-
|
|
323
|
-
const randAllCharacterByLength = function randAllCharacterByLength() {
|
|
324
|
-
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
325
|
-
return randomStringByLength(length, allCharacter);
|
|
326
|
-
};
|
|
327
|
-
/**
|
|
328
|
-
* @param {number} length
|
|
329
|
-
* @param {textLowCase | numeric | punctuation | allCharacter} str
|
|
330
|
-
* @returns {string}
|
|
331
|
-
*/
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
exports.randAllCharacterByLength = randAllCharacterByLength;
|
|
335
|
-
|
|
336
|
-
const randomStringByLength = function randomStringByLength(length) {
|
|
337
|
-
let str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : textLowCase;
|
|
338
|
-
let result = "";
|
|
339
|
-
|
|
340
|
-
for (let i = 0; i < length; i++) {
|
|
341
|
-
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
342
|
-
}
|
|
343
|
-
|
|
344
|
-
return result;
|
|
345
306
|
};
|
|
346
307
|
/**
|
|
347
308
|
* Get string between str1 and str2 from text
|
|
@@ -351,9 +312,6 @@ const randomStringByLength = function randomStringByLength(length) {
|
|
|
351
312
|
* @return {string}
|
|
352
313
|
*/
|
|
353
314
|
|
|
354
|
-
|
|
355
|
-
exports.randomStringByLength = randomStringByLength;
|
|
356
|
-
|
|
357
315
|
const getBetween = function getBetween(text, str1) {
|
|
358
316
|
let str2 = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : "";
|
|
359
317
|
if (!text) return "";
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.textLowCase = exports.randomStringByLength = exports.randAllCharacterByLength = exports.punctuation = exports.numeric = exports.allCharacter = void 0;
|
|
7
|
+
const textLowCase = "abcdefghijklmnopqrstuvwxyz";
|
|
8
|
+
exports.textLowCase = textLowCase;
|
|
9
|
+
const numeric = "0123456789";
|
|
10
|
+
exports.numeric = numeric;
|
|
11
|
+
const punctuation = "!@#$%^&*()_+~|}{[];?><,./-=";
|
|
12
|
+
exports.punctuation = punctuation;
|
|
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
|
+
/**
|
|
15
|
+
* allCharacter = `đĐaáàảãạăắằẳẵặâấầẩẫậeéèẻẽẹêếềểễệoóòỏõọôốồổỗộơớờởỡợiíìỉĩịuúùủũụưứừửữựyýỳỷỹỵAÁÀẢÃẠĂẮẰẲẴẶÂẤẦẨẪẬEÉÈẺẼẸÊẾỀỂỄỆOÓÒỎÕỌÔỐỒỔỖỘƠỚỜỞỠỢIÍÌỈĨỊUÚÙỦŨỤƯỨỪỬỮỰYÝỲ !"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_\`abcdefghijklmnopqrstuvwxyz{|}`;
|
|
16
|
+
* @param {number} length
|
|
17
|
+
* @returns {string}
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
exports.allCharacter = allCharacter;
|
|
21
|
+
|
|
22
|
+
const randAllCharacterByLength = function randAllCharacterByLength() {
|
|
23
|
+
let length = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
|
|
24
|
+
return randomStringByLength(length, allCharacter);
|
|
25
|
+
};
|
|
26
|
+
/**
|
|
27
|
+
* @param {number} length
|
|
28
|
+
* @param {textLowCase | numeric | punctuation | allCharacter} str
|
|
29
|
+
* @returns {string}
|
|
30
|
+
*/
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
exports.randAllCharacterByLength = randAllCharacterByLength;
|
|
34
|
+
|
|
35
|
+
const randomStringByLength = function randomStringByLength(length) {
|
|
36
|
+
let str = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : textLowCase;
|
|
37
|
+
let result = "";
|
|
38
|
+
|
|
39
|
+
for (let i = 0; i < length; i++) {
|
|
40
|
+
result += str.charAt(Math.floor(Math.random() * str.length));
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
return result;
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
exports.randomStringByLength = randomStringByLength;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "diginext-utils",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"author": {
|
|
5
5
|
"name": "TOP GROUP (a.k.a Digitop)",
|
|
6
6
|
"email": "dev@wearetopgroup.com"
|
|
@@ -11,7 +11,9 @@
|
|
|
11
11
|
"dist",
|
|
12
12
|
"README.md"
|
|
13
13
|
],
|
|
14
|
+
"sideEffects": false,
|
|
14
15
|
"scripts": {
|
|
16
|
+
"test": "mocha test/*.test.js",
|
|
15
17
|
"publish": "npm publish",
|
|
16
18
|
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist",
|
|
17
19
|
"build": "rm -rf dist && NODE_ENV=production babel src --out-dir dist --copy-files",
|
|
@@ -33,6 +35,7 @@
|
|
|
33
35
|
"@babel/preset-react": "^7.18.6",
|
|
34
36
|
"@babel/runtime": "^7.18.9",
|
|
35
37
|
"core-js": "^3.24.1",
|
|
38
|
+
"esm": "^3.2.25",
|
|
36
39
|
"gsap": "^3.10.4",
|
|
37
40
|
"lodash": "^4.17.21"
|
|
38
41
|
},
|
|
@@ -42,6 +45,10 @@
|
|
|
42
45
|
"devDependencies": {
|
|
43
46
|
"@babel/cli": "^7.18.10",
|
|
44
47
|
"@babel/core": "^7.18.10",
|
|
45
|
-
"@babel/preset-env": "^7.18.10"
|
|
48
|
+
"@babel/preset-env": "^7.18.10",
|
|
49
|
+
"eslint": "^7.16.0",
|
|
50
|
+
"eslint-plugin-import": "^2.26.0",
|
|
51
|
+
"esm": "^3.2.25",
|
|
52
|
+
"mocha": "^10.0.0"
|
|
46
53
|
}
|
|
47
54
|
}
|