melperjs 9.1.0 → 10.0.0
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/README.md +3 -0
- package/lib/cjs/index.js +20 -0
- package/lib/cjs/node.js +17 -1
- package/lib/esm/index.js +18 -0
- package/lib/esm/node.js +17 -2
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -90,6 +90,7 @@ console.log(helper.objectStringify({
|
|
|
90
90
|
}));
|
|
91
91
|
console.log(helper.limitString("LONG TEXT", 7));
|
|
92
92
|
console.log(helper.safeString("<strong>SAFE TEXT</strong>"));
|
|
93
|
+
console.log(helper.shuffleString("ABC123"));
|
|
93
94
|
console.log(helper.randomString(32, true, true));
|
|
94
95
|
console.log(helper.randomHex(8));
|
|
95
96
|
console.log(helper.randomInteger(100, 1000));
|
|
@@ -105,6 +106,8 @@ console.log(nodeHelper.md5("data"));
|
|
|
105
106
|
const password = nodeHelper.hashBcrypt("plain", "encryptionKey");
|
|
106
107
|
console.log(password)
|
|
107
108
|
console.log("passwordHash verified ?", nodeHelper.verifyBcrypt("plain", password, "encryptionKey"));
|
|
109
|
+
console.log(await nodeHelper.executeCommand("python --version"));
|
|
110
|
+
console.log(helper.indexByTime(5));
|
|
108
111
|
const cookies = helper.cookieDict(await axios.get("https://google.com"));
|
|
109
112
|
console.log(cookies);
|
|
110
113
|
console.log(helper.cookieHeader(cookies));
|
package/lib/cjs/index.js
CHANGED
|
@@ -10,6 +10,7 @@ exports.cookieDict = cookieDict;
|
|
|
10
10
|
exports.cookieHeader = cookieHeader;
|
|
11
11
|
exports.findKeyNode = findKeyNode;
|
|
12
12
|
exports.forever = forever;
|
|
13
|
+
exports.indexByTime = indexByTime;
|
|
13
14
|
exports.isIntlError = isIntlError;
|
|
14
15
|
exports.isIntlHttpCode = isIntlHttpCode;
|
|
15
16
|
exports.limitString = limitString;
|
|
@@ -26,6 +27,7 @@ exports.randomString = randomString;
|
|
|
26
27
|
exports.randomUuid = randomUuid;
|
|
27
28
|
exports.randomWeighted = randomWeighted;
|
|
28
29
|
exports.safeString = safeString;
|
|
30
|
+
exports.shuffleString = shuffleString;
|
|
29
31
|
exports.sleep = sleep;
|
|
30
32
|
exports.sleepMs = sleepMs;
|
|
31
33
|
exports.splitClear = splitClear;
|
|
@@ -36,6 +38,7 @@ var _setCookieParser = _interopRequireDefault(require("set-cookie-parser"));
|
|
|
36
38
|
var _camelCase = _interopRequireDefault(require("lodash/camelCase.js"));
|
|
37
39
|
var _upperFirst = _interopRequireDefault(require("lodash/upperFirst.js"));
|
|
38
40
|
var _isEmpty = _interopRequireDefault(require("lodash/isEmpty.js"));
|
|
41
|
+
var _shuffle = _interopRequireDefault(require("lodash/shuffle.js"));
|
|
39
42
|
function _interopRequireDefault(e) { return e && e.__esModule ? e : { default: e }; }
|
|
40
43
|
const CONSTANTS = exports.CONSTANTS = {
|
|
41
44
|
LOWER_CASE: "abcdefghijklmnopqrstuvwxyz",
|
|
@@ -182,6 +185,11 @@ function safeString(str) {
|
|
|
182
185
|
stripIgnoreTagBody: ["script"]
|
|
183
186
|
});
|
|
184
187
|
}
|
|
188
|
+
function shuffleString(str) {
|
|
189
|
+
const collection = str.split('');
|
|
190
|
+
const shuffled = (0, _shuffle.default)(collection);
|
|
191
|
+
return shuffled.join('');
|
|
192
|
+
}
|
|
185
193
|
function randomString(length, useNumbers = true, useUppercase = false) {
|
|
186
194
|
let characters = CONSTANTS.LOWER_CASE;
|
|
187
195
|
if (useUppercase) characters += CONSTANTS.UPPER_CASE;
|
|
@@ -255,6 +263,18 @@ function randomElement(obj) {
|
|
|
255
263
|
return obj[randomElement(Object.keys(obj))];
|
|
256
264
|
}
|
|
257
265
|
}
|
|
266
|
+
function indexByTime(index) {
|
|
267
|
+
const date = new Date();
|
|
268
|
+
const hour = date.getHours();
|
|
269
|
+
const minute = date.getMinutes();
|
|
270
|
+
if (hour < 20) {
|
|
271
|
+
return (index + hour) % 10;
|
|
272
|
+
} else {
|
|
273
|
+
const totalMinutes = (hour - 20) * 60 + minute;
|
|
274
|
+
const minuteIndex = Math.floor(totalMinutes / 24);
|
|
275
|
+
return (index + minuteIndex) % 10;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
258
278
|
function cookieDict(res, decodeValues = false) {
|
|
259
279
|
let dict = {};
|
|
260
280
|
const cookies = _setCookieParser.default.parse(res, {
|
package/lib/cjs/node.js
CHANGED
|
@@ -4,6 +4,7 @@ Object.defineProperty(exports, "__esModule", {
|
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
6
|
exports.createNumDir = createNumDir;
|
|
7
|
+
exports.executeCommand = executeCommand;
|
|
7
8
|
exports.formatProxy = formatProxy;
|
|
8
9
|
exports.getVersion = getVersion;
|
|
9
10
|
exports.hashBcrypt = hashBcrypt;
|
|
@@ -65,6 +66,19 @@ function tokenElement(obj) {
|
|
|
65
66
|
return obj[tokenElement(Object.keys(obj))];
|
|
66
67
|
}
|
|
67
68
|
}
|
|
69
|
+
function executeCommand(command) {
|
|
70
|
+
return new Promise((resolve, reject) => {
|
|
71
|
+
(0, _child_process.exec)(command, (error, stdout, stderr) => {
|
|
72
|
+
if (error) {
|
|
73
|
+
reject(error);
|
|
74
|
+
} else if (stderr) {
|
|
75
|
+
reject(stderr);
|
|
76
|
+
} else {
|
|
77
|
+
resolve(stdout.trim());
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
});
|
|
81
|
+
}
|
|
68
82
|
function serverIp() {
|
|
69
83
|
const interfaces = (0, _os.networkInterfaces)();
|
|
70
84
|
for (const devName in interfaces) {
|
|
@@ -96,7 +110,9 @@ function createNumDir(mainDirectory) {
|
|
|
96
110
|
});
|
|
97
111
|
for (let i = 0; i <= 9; i++) {
|
|
98
112
|
try {
|
|
99
|
-
_fs.default.mkdirSync(_path.default.join(mainDirectory, i.toString())
|
|
113
|
+
_fs.default.mkdirSync(_path.default.join(mainDirectory, i.toString()), {
|
|
114
|
+
recursive: true
|
|
115
|
+
});
|
|
100
116
|
} catch (e) {
|
|
101
117
|
console.error(`createNumDir:${i}`, e.message);
|
|
102
118
|
}
|
package/lib/esm/index.js
CHANGED
|
@@ -3,6 +3,7 @@ import setCookieParser from "set-cookie-parser";
|
|
|
3
3
|
import camelCase from "lodash/camelCase.js";
|
|
4
4
|
import upperFirst from "lodash/upperFirst.js";
|
|
5
5
|
import isEmpty from "lodash/isEmpty.js";
|
|
6
|
+
import shuffle from "lodash/shuffle.js";
|
|
6
7
|
export const CONSTANTS = {
|
|
7
8
|
LOWER_CASE: "abcdefghijklmnopqrstuvwxyz",
|
|
8
9
|
UPPER_CASE: "ABCDEFGHIJKLMNOPQRSTUVWXYZ",
|
|
@@ -148,6 +149,11 @@ export function safeString(str) {
|
|
|
148
149
|
stripIgnoreTagBody: ["script"]
|
|
149
150
|
});
|
|
150
151
|
}
|
|
152
|
+
export function shuffleString(str) {
|
|
153
|
+
const collection = str.split('');
|
|
154
|
+
const shuffled = shuffle(collection);
|
|
155
|
+
return shuffled.join('');
|
|
156
|
+
}
|
|
151
157
|
export function randomString(length, useNumbers = true, useUppercase = false) {
|
|
152
158
|
let characters = CONSTANTS.LOWER_CASE;
|
|
153
159
|
if (useUppercase) characters += CONSTANTS.UPPER_CASE;
|
|
@@ -221,6 +227,18 @@ export function randomElement(obj) {
|
|
|
221
227
|
return obj[randomElement(Object.keys(obj))];
|
|
222
228
|
}
|
|
223
229
|
}
|
|
230
|
+
export function indexByTime(index) {
|
|
231
|
+
const date = new Date();
|
|
232
|
+
const hour = date.getHours();
|
|
233
|
+
const minute = date.getMinutes();
|
|
234
|
+
if (hour < 20) {
|
|
235
|
+
return (index + hour) % 10;
|
|
236
|
+
} else {
|
|
237
|
+
const totalMinutes = (hour - 20) * 60 + minute;
|
|
238
|
+
const minuteIndex = Math.floor(totalMinutes / 24);
|
|
239
|
+
return (index + minuteIndex) % 10;
|
|
240
|
+
}
|
|
241
|
+
}
|
|
224
242
|
export function cookieDict(res, decodeValues = false) {
|
|
225
243
|
let dict = {};
|
|
226
244
|
const cookies = setCookieParser.parse(res, {
|
package/lib/esm/node.js
CHANGED
|
@@ -3,7 +3,7 @@ import { promises as fsp } from "fs";
|
|
|
3
3
|
import path from "path";
|
|
4
4
|
import crypto from "crypto";
|
|
5
5
|
import { networkInterfaces } from "os";
|
|
6
|
-
import { execSync } from "child_process";
|
|
6
|
+
import { exec, execSync } from "child_process";
|
|
7
7
|
import bcrypt from "bcryptjs";
|
|
8
8
|
import { CONSTANTS, randomWeighted, splitClear } from "./index.js";
|
|
9
9
|
export function tokenString(length, useNumbers = true, useUppercase = false) {
|
|
@@ -40,6 +40,19 @@ export function tokenElement(obj) {
|
|
|
40
40
|
return obj[tokenElement(Object.keys(obj))];
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
+
export function executeCommand(command) {
|
|
44
|
+
return new Promise((resolve, reject) => {
|
|
45
|
+
exec(command, (error, stdout, stderr) => {
|
|
46
|
+
if (error) {
|
|
47
|
+
reject(error);
|
|
48
|
+
} else if (stderr) {
|
|
49
|
+
reject(stderr);
|
|
50
|
+
} else {
|
|
51
|
+
resolve(stdout.trim());
|
|
52
|
+
}
|
|
53
|
+
});
|
|
54
|
+
});
|
|
55
|
+
}
|
|
43
56
|
export function serverIp() {
|
|
44
57
|
const interfaces = networkInterfaces();
|
|
45
58
|
for (const devName in interfaces) {
|
|
@@ -71,7 +84,9 @@ export function createNumDir(mainDirectory) {
|
|
|
71
84
|
});
|
|
72
85
|
for (let i = 0; i <= 9; i++) {
|
|
73
86
|
try {
|
|
74
|
-
fs.mkdirSync(path.join(mainDirectory, i.toString())
|
|
87
|
+
fs.mkdirSync(path.join(mainDirectory, i.toString()), {
|
|
88
|
+
recursive: true
|
|
89
|
+
});
|
|
75
90
|
} catch (e) {
|
|
76
91
|
console.error(`createNumDir:${i}`, e.message);
|
|
77
92
|
}
|