mybase 1.1.5 → 1.1.6
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 +1 -1
- package/ts/funcs/randomIP.d.ts +1 -0
- package/ts/funcs/randomIP.js +10 -0
- package/ts/funcs/randomIP.test.ts +16 -0
- package/ts/funcs/randomIP.ts +7 -0
- package/ts/index.d.ts +1 -0
- package/ts/index.js +1 -0
- package/ts/index.ts +1 -0
package/package.json
CHANGED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function randomIP(): string;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.randomIP = void 0;
|
|
4
|
+
function randomIP() {
|
|
5
|
+
function int2ip(ipInt) {
|
|
6
|
+
return ((ipInt >>> 24) + '.' + (ipInt >> 16 & 255) + '.' + (ipInt >> 8 & 255) + '.' + (ipInt & 255));
|
|
7
|
+
}
|
|
8
|
+
return int2ip(Math.random() * Math.pow(2, 32));
|
|
9
|
+
}
|
|
10
|
+
exports.randomIP = randomIP;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { randomIP } from './randomIP';
|
|
2
|
+
|
|
3
|
+
describe('randomIP', () => {
|
|
4
|
+
it('should return a valid IP address', () => {
|
|
5
|
+
for(let i=0; i<1000; i++) {
|
|
6
|
+
const ipAddress = randomIP();
|
|
7
|
+
const ipParts = ipAddress.split('.');
|
|
8
|
+
expect(ipParts.length).toBe(4);
|
|
9
|
+
ipParts.forEach((part) => {
|
|
10
|
+
const partInt = parseInt(part);
|
|
11
|
+
expect(partInt).toBeGreaterThanOrEqual(0);
|
|
12
|
+
expect(partInt).toBeLessThanOrEqual(255);
|
|
13
|
+
});
|
|
14
|
+
}
|
|
15
|
+
});
|
|
16
|
+
});
|
package/ts/index.d.ts
CHANGED
package/ts/index.js
CHANGED
|
@@ -26,3 +26,4 @@ __exportStar(require("./funcs/vaultRead"), exports);
|
|
|
26
26
|
__exportStar(require("./funcs/vaultFill"), exports);
|
|
27
27
|
__exportStar(require("./funcs/asJSON"), exports);
|
|
28
28
|
__exportStar(require("./funcs/promiseTimeout"), exports);
|
|
29
|
+
__exportStar(require("./funcs/randomIP"), exports);
|
package/ts/index.ts
CHANGED