mybase 1.1.17 → 1.1.18

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mybase",
3
- "version": "1.1.17",
3
+ "version": "1.1.18",
4
4
  "description": "",
5
5
  "main": "mybase.js",
6
6
  "scripts": {
@@ -63,7 +63,11 @@ describe('isLoopbackIP', () => {
63
63
  })
64
64
 
65
65
  test('random ips should not be Loopback', () => {
66
- for(let i=0;i<100;i++)
67
- expect(isLoopbackIP(randomIP())).toBe(false)
66
+ for(let i=0;i<100;i++){
67
+ let ip = isLoopbackIP(randomIP())
68
+ console.log(ip)
69
+ expect(ip).toBe(false)
70
+ }
71
+
68
72
  })
69
73
  });
@@ -0,0 +1 @@
1
+ export declare function randomUTFString(minLength: number, maxLength: number, includeAscii?: boolean): string;
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.randomUTFString = void 0;
4
+ function randomUTFString(minLength, maxLength, includeAscii = true) {
5
+ // Extended characters set including various languages and symbols
6
+ let characters = 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ' + // Accented Latin characters
7
+ 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψω' + // Greek
8
+ 'אבגדהוזחטיךכלםמןנסעפצקרשת' + // Hebrew
9
+ //Arabic
10
+ 'ا ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي' +
11
+ // Persian
12
+ 'آ ا ب پ ت ث ج چ ح خ د ذ ر ز ژ س ش ص ض ط ظ ع غ ف ق ک گ ل م ن و ه ی' +
13
+ // Turkish
14
+ 'ğıöşü' +
15
+ 'ĞİÖŞÜ ' +
16
+ // More Emojis
17
+ '🙂🤔😍😂👍🚀❤️🎉' +
18
+ 'бвгдежзийклмнопрстуфхцчшщъыьэюя' + // Cyrillic (Russian, etc.)
19
+ '日本語中文한국어' + // Japanese, Chinese, Korean characters
20
+ '🙂🤔😍😂👍🚀❤️🎉'; // Emojis
21
+ if (includeAscii)
22
+ characters += 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
23
+ const charactersLength = Array.from(characters).length;
24
+ const length = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength;
25
+ let result = '';
26
+ for (let i = 0; i < length; i++)
27
+ result += Array.from(characters)[Math.floor(Math.random() * charactersLength)];
28
+ return result;
29
+ }
30
+ exports.randomUTFString = randomUTFString;
@@ -0,0 +1,44 @@
1
+ import { randomUTFString } from './randomUTFString';
2
+
3
+ describe('randomUTFString', () => {
4
+ const asciiCharacters = 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789';
5
+ let extendedCharset =
6
+ 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ' + // Accented Latin characters
7
+ 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψω' + // Greek
8
+ 'אבגדהוזחטיךכלםמןנסעפצקרשת' + // Hebrew
9
+ //Arabic
10
+ 'ا ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي' +
11
+ // Persian
12
+ 'آ ا ب پ ت ث ج چ ح خ د ذ ر ز ژ س ش ص ض ط ظ ع غ ف ق ک گ ل م ن و ه ی' +
13
+ // Turkish
14
+ 'a b c ç d e f g ğ h ı i j k l m n o ö p r s ş t u ü v y z' +
15
+ 'A B C Ç D E F G Ğ H I İ J K L M N O Ö P R S Ş T U Ü V Y Z' +
16
+ // More Emojis
17
+ '🙂🤔😍😂👍🚀❤️🎉' +
18
+ 'абвгдежзийклмнопрстуфхцчшщъыьэюя' + // Cyrillic (Russian, etc.)
19
+ '日本語中文한국어' + // Japanese, Chinese, Korean characters
20
+ '🙂🤔😍😂👍🚀❤️🎉' // Emojis
21
+ it('should generate a random string within the specified length range', () => {
22
+ const minLength = 5;
23
+ const maxLength = 10;
24
+ const result = randomUTFString(minLength, maxLength);
25
+ expect(result.length).toBeGreaterThanOrEqual(minLength);
26
+ expect(result.length).toBeLessThanOrEqual(maxLength+1); // utf8 characters can be 1-4 bytes long
27
+ });
28
+
29
+ it('should include ASCII characters by default', () => {
30
+ const result = randomUTFString(500, 400);
31
+
32
+ expect(result).toMatch(new RegExp(`[${asciiCharacters}]`));
33
+ });
34
+
35
+ it('should exclude ASCII characters when includeAscii is set to false', () => {
36
+ const result = randomUTFString(500, 1000, false);
37
+ expect(result).not.toMatch(new RegExp(`[${asciiCharacters}]`));
38
+ });
39
+
40
+ it('should include extended characters when includeAscii is set to true', () => {
41
+ const result = randomUTFString(500, 1000, true);
42
+ expect(result).toMatch(new RegExp(`[${extendedCharset}]`));
43
+ });
44
+ });
@@ -0,0 +1,33 @@
1
+
2
+
3
+
4
+ export function randomUTFString(minLength: number, maxLength: number, includeAscii:boolean=true): string {
5
+ // Extended characters set including various languages and symbols
6
+ let characters =
7
+ 'àáâãäåæçèéêëìíîïðñòóôõöøùúûüýÿ' + // Accented Latin characters
8
+ 'ΑΒΓΔΕΖΗΘΙΚΛΜΝΞΟΠΡΣΤΥΦΧΨΩαβγδεζηθικλμνξοπρσςτυφχψω' + // Greek
9
+ 'אבגדהוזחטיךכלםמןנסעפצקרשת' + // Hebrew
10
+ //Arabic
11
+ 'ا ب ت ث ج ح خ د ذ ر ز س ش ص ض ط ظ ع غ ف ق ك ل م ن ه و ي' +
12
+ // Persian
13
+ 'آ ا ب پ ت ث ج چ ح خ د ذ ر ز ژ س ش ص ض ط ظ ع غ ف ق ک گ ل م ن و ه ی' +
14
+ // Turkish
15
+ 'ğıöşü' +
16
+ 'ĞİÖŞÜ ' +
17
+ // More Emojis
18
+ '🙂🤔😍😂👍🚀❤️🎉' +
19
+ 'бвгдежзийклмнопрстуфхцчшщъыьэюя' + // Cyrillic (Russian, etc.)
20
+ '日本語中文한국어' + // Japanese, Chinese, Korean characters
21
+ '🙂🤔😍😂👍🚀❤️🎉' // Emojis
22
+
23
+ if (includeAscii) characters += 'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
24
+
25
+ const charactersLength = Array.from(characters).length
26
+ const length = Math.floor(Math.random() * (maxLength - minLength + 1)) + minLength
27
+ let result = ''
28
+
29
+ for (let i = 0; i < length; i++)
30
+ result += Array.from(characters)[Math.floor(Math.random() * charactersLength)]
31
+
32
+ return result
33
+ }
package/ts/index.d.ts CHANGED
@@ -21,3 +21,4 @@ export * from "./funcs/isLANIp";
21
21
  export * from "./funcs/getMysql1";
22
22
  export * from "./funcs/getMysql2";
23
23
  export * from "./funcs/initMysql2Pool";
24
+ export * from "./funcs/randomUTFString";
package/ts/index.js CHANGED
@@ -37,3 +37,4 @@ __exportStar(require("./funcs/isLANIp"), exports);
37
37
  __exportStar(require("./funcs/getMysql1"), exports);
38
38
  __exportStar(require("./funcs/getMysql2"), exports);
39
39
  __exportStar(require("./funcs/initMysql2Pool"), exports);
40
+ __exportStar(require("./funcs/randomUTFString"), exports);
package/ts/index.ts CHANGED
@@ -20,4 +20,5 @@ export * from "./funcs/isLoopbackIP"
20
20
  export * from "./funcs/isLANIp"
21
21
  export * from "./funcs/getMysql1"
22
22
  export * from "./funcs/getMysql2"
23
- export * from "./funcs/initMysql2Pool"
23
+ export * from "./funcs/initMysql2Pool"
24
+ export * from "./funcs/randomUTFString"