@artilleryio/int-commons 2.0.2-38ff32c → 2.0.2-61d96f9
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/engine_util.js +10 -1
- package/package.json +3 -2
package/engine_util.js
CHANGED
|
@@ -10,6 +10,7 @@ const deepForEach = require('deep-for-each');
|
|
|
10
10
|
const espree = require('espree');
|
|
11
11
|
const L = require('lodash');
|
|
12
12
|
const vm = require('vm');
|
|
13
|
+
const ms = require('ms');
|
|
13
14
|
const A = require('async');
|
|
14
15
|
const { JSONPath: jsonpath } = require('jsonpath-plus');
|
|
15
16
|
const cheerio = require('cheerio');
|
|
@@ -42,7 +43,15 @@ function createThink(requestSpec, opts) {
|
|
|
42
43
|
let thinkspec = requestSpec.think;
|
|
43
44
|
|
|
44
45
|
let f = function think(context, callback) {
|
|
45
|
-
let
|
|
46
|
+
let templatedThink = template(thinkspec, context);
|
|
47
|
+
let thinktime = Number.isInteger(L.toNumber(templatedThink))
|
|
48
|
+
? ms(`${templatedThink}s`)
|
|
49
|
+
: ms(templatedThink);
|
|
50
|
+
|
|
51
|
+
if (typeof thinktime == 'undefined') {
|
|
52
|
+
throw new Error(`Invalid think time: ${templatedThink || thinkspec}`);
|
|
53
|
+
}
|
|
54
|
+
|
|
46
55
|
if (requestSpec.jitter || opts.jitter) {
|
|
47
56
|
thinktime = jitter(`${thinktime}:${requestSpec.jitter || opts.jitter}`);
|
|
48
57
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@artilleryio/int-commons",
|
|
3
|
-
"version": "2.0.2-
|
|
3
|
+
"version": "2.0.2-61d96f9",
|
|
4
4
|
"main": "./index.js",
|
|
5
5
|
"license": "MPL-2.0",
|
|
6
6
|
"dependencies": {
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"deep-for-each": "^3.0.0",
|
|
11
11
|
"espree": "^9.4.1",
|
|
12
12
|
"jsonpath-plus": "^7.2.0",
|
|
13
|
-
"lodash": "^4.17.19"
|
|
13
|
+
"lodash": "^4.17.19",
|
|
14
|
+
"ms": "^2.1.3"
|
|
14
15
|
},
|
|
15
16
|
"scripts": {
|
|
16
17
|
"lint": "eslint --ext \".js,.ts,.tsx\" .",
|