diff --git a/build/check.d.ts b/build/check.d.ts new file mode 100644 index 0000000..622e800 --- /dev/null +++ b/build/check.d.ts @@ -0,0 +1,12 @@ +type FalsyCheckValue = Array | Record | boolean | string | number | null | undefined; +type Checker = ((value: T) => FalsyCheckValue) | ((value: T) => Promise) | FalsyCheckValue | Promise; +interface CheckMap { + [key: string]: Checker; +} +interface SyncCheckMap { + [key: string]: ((value: any) => FalsyCheckValue) | FalsyCheckValue; +} +type CheckResult> = C extends SyncCheckMap ? boolean : Promise; +export declare function check>(checkers: C): CheckResult; +export declare function check>(value: T, checkers: C): CheckResult; +export {}; diff --git a/build/index.d.ts b/build/index.d.ts new file mode 100644 index 0000000..ab6acc1 --- /dev/null +++ b/build/index.d.ts @@ -0,0 +1,12 @@ +import { check } from './check.ts'; +import { parseDuration } from './stages.js'; +import { getCurrentStageIndex } from './stages.js'; +import { tagWithCurrentStageIndex } from './stages.js'; +import { tagWithCurrentStageProfile } from './stages.js'; +import { findBetween } from './utils.js'; +import { normalDistributionStages } from './utils.js'; +import { randomIntBetween } from './utils.js'; +import { randomItem } from './utils.js'; +import { randomString } from './utils.js'; +import { uuidv4 } from './utils.js'; +export { check, parseDuration, getCurrentStageIndex, tagWithCurrentStageIndex, tagWithCurrentStageProfile, findBetween, normalDistributionStages, randomIntBetween, randomItem, randomString, uuidv4 }; diff --git a/build/index.js b/build/index.js index 51983c1..09b1218 100644 --- a/build/index.js +++ b/build/index.js @@ -1,2 +1,2 @@ -(()=>{"use strict";var r={n:t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},d:(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},o:(r,t)=>Object.prototype.hasOwnProperty.call(r,t),r:r=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(r,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(r,"__esModule",{value:!0})}},t={};r.r(t),r.d(t,{check:()=>S,findBetween:()=>p,getCurrentStageIndex:()=>i,normalDistributionStages:()=>y,parseDuration:()=>o,randomIntBetween:()=>g,randomItem:()=>d,randomString:()=>m,tagWithCurrentStageIndex:()=>u,tagWithCurrentStageProfile:()=>s,uuidv4:()=>h});const e=require("k6/execution");var n=r.n(e);function o(r){if(null==r||r.length<1)throw new Error("str is empty");for(var t=0,e="",n={},o=0;o0&&(t+=parseFloat(e,10)),t}function a(r){return r>="0"&&r<="9"}function i(){var r=n().test.options.scenarios[n().scenario.name];if(null==r)throw new Error("the exec.test.options object doesn't contain the current scenario ".concat(n().scenario.name));if(null==r.stages)throw new Error("only ramping-vus or ramping-arravial-rate supports stages, it is not possible to get a stage index on other executors.");if(r.stages.length<1)throw new Error("the current scenario ".concat(r.name," doesn't contain any stage"));for(var t=0,e=new Date-n().scenario.startTime,a=0;ao.target?"ramp-up":o.target==e.target?"steady":"ramp-down"}()}const c=require("k6/crypto");function l(r){return function(r){if(Array.isArray(r))return f(r)}(r)||function(r){if("undefined"!=typeof Symbol&&null!=r[Symbol.iterator]||null!=r["@@iterator"])return Array.from(r)}(r)||function(r,t){if(!r)return;if("string"==typeof r)return f(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return f(r,t)}(r)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function f(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e0&&void 0!==arguments[0]&&arguments[0];return r?x():v()}function g(r,t){return Math.floor(Math.random()*(t-r+1)+r)}function d(r){return r[Math.floor(Math.random()*r.length)]}function m(r){for(var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:"abcdefghijklmnopqrstuvwxyz",e="";r--;)e+=t[Math.random()*t.length|0];return e}function p(r,t,e){for(var n,o=arguments.length>3&&void 0!==arguments[3]&&arguments[3],a=[],i=!0,u=0;i&&-1!=(n=r.indexOf(t))&&(n+=t.length,-1!=(u=r.indexOf(e,n)));){var s=r.substring(n,u);if(!o)return s;a.push(s),r=r.substring(u+e.length)}return a.length?a:null}function y(r,t){var e=arguments.length>2&&void 0!==arguments[2]?arguments[2]:10;function n(r,t,e){return Math.exp(-.5*Math.pow((e-r)/t,2))/(t*Math.sqrt(2*Math.PI))}for(var o=0,a=1,i=new Array(e+2).fill(0),u=new Array(e+2).fill(Math.ceil(t/6)),s=[],c=0;c<=e;c++)i[c]=n(o,a,-2*a+4*a*c/e);for(var f=Math.max.apply(Math,l(i)),h=i.map((function(t){return Math.round(t*r/f)})),g=1;g<=e;g++)u[g]=Math.ceil(4*t/(6*e));for(var d=0;d<=e+1;d++)s.push({duration:"".concat(u[d],"s"),target:h[d]});return s}function v(){return"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(r){var t=16*Math.random()|0;return("x"===r?t:3&t|8).toString(16)}))}function x(){for(var r=[],t=0;t<256;++t)r.push((t+256).toString(16).slice(1));var e=new Uint8Array((0,c.randomBytes)(16));return e[6]=15&e[6]|64,e[8]=63&e[8]|128,(r[e[0]]+r[e[1]]+r[e[2]]+r[e[3]]+"-"+r[e[4]]+r[e[5]]+"-"+r[e[6]]+r[e[7]]+"-"+r[e[8]]+r[e[9]]+"-"+r[e[10]]+r[e[11]]+r[e[12]]+r[e[13]]+r[e[14]]+r[e[15]]).toLowerCase()}function b(r,t){return function(r){if(Array.isArray(r))return r}(r)||function(r,t){var e=null==r?null:"undefined"!=typeof Symbol&&r[Symbol.iterator]||r["@@iterator"];if(null==e)return;var n,o,a=[],i=!0,u=!1;try{for(e=e.call(r);!(i=(n=e.next()).done)&&(a.push(n.value),!t||a.length!==t);i=!0);}catch(r){u=!0,o=r}finally{try{i||null==e.return||e.return()}finally{if(u)throw o}}return a}(r,t)||function(r,t){if(!r)return;if("string"==typeof r)return w(r,t);var e=Object.prototype.toString.call(r).slice(8,-1);"Object"===e&&r.constructor&&(e=r.constructor.name);if("Map"===e||"Set"===e)return Array.from(r);if("Arguments"===e||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(e))return w(r,t)}(r,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function w(r,t){(null==t||t>r.length)&&(t=r.length);for(var e=0,n=new Array(t);e{"use strict";var e={184:(e,t,r)=>{Object.defineProperty(t,"__esModule",{value:!0}),t.check=function(e,t){var r=t||e,a=Object.entries(r).map((function(t){var r=t[0],a=t[1];function o(e){return n.add(e?1:0,{check:r}),e}if("function"==typeof a){var i=a(e);return i instanceof Promise?i.then(o):o(i)}return a instanceof Promise?a.then(o):o(a)}));if(a.some((function(e){return e instanceof Promise})))return Promise.all(a).then((function(e){return e.every(Boolean)}));return a.every(Boolean)};var n=new(r(610).Rate)("checks")},664:function(e,t,r){var n=this&&this.__importDefault||function(e){return e&&e.__esModule?e:{default:e}};Object.defineProperty(t,"__esModule",{value:!0}),t.parseDuration=o,t.getCurrentStageIndex=u,t.tagWithCurrentStageIndex=function(){a.default.vu.tags.stage=u()},t.tagWithCurrentStageProfile=function(){a.default.vu.tags.stage_profile=function(){var e=u();if(e<1)return"ramp-up";var t=a.default.test.options.scenarios[a.default.scenario.name].stages,r=t[e],n=t[e-1];return r.target>n.target?"ramp-up":n.target==r.target?"steady":"ramp-down"}()};var a=n(r(744));function o(e){if(null==e||e.length<1)throw new Error("str is empty");for(var t=0,r="",n={},a=0;a0&&(t+=parseFloat(r,10)),t}function i(e){return e>="0"&&e<="9"}function u(){var e=a.default.test.options.scenarios[a.default.scenario.name];if(null==e)throw new Error("the exec.test.options object doesn't contain the current scenario ".concat(a.default.scenario.name));if(null==e.stages)throw new Error("only ramping-vus or ramping-arravial-rate supports stages, it is not possible to get a stage index on other executors.");if(e.stages.length<1)throw new Error("the current scenario ".concat(e.name," doesn't contain any stage"));for(var t=0,r=new Date-a.default.scenario.startTime,n=0;n{Object.defineProperty(t,"__esModule",{value:!0}),t.uuidv4=function(e){void 0===e&&(e=!1);return e?function(){for(var e=[],t=0;t<256;++t)e.push((t+256).toString(16).slice(1));var r=new Uint8Array((0,n.randomBytes)(16));return r[6]=15&r[6]|64,r[8]=63&r[8]|128,(e[r[0]]+e[r[1]]+e[r[2]]+e[r[3]]+"-"+e[r[4]]+e[r[5]]+"-"+e[r[6]]+e[r[7]]+"-"+e[r[8]]+e[r[9]]+"-"+e[r[10]]+e[r[11]]+e[r[12]]+e[r[13]]+e[r[14]]+e[r[15]]).toLowerCase()}():"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,(function(e){var t=16*Math.random()|0;return("x"===e?t:3&t|8).toString(16)}))},t.randomIntBetween=function(e,t){return Math.floor(Math.random()*(t-e+1)+e)},t.randomItem=function(e){return e[Math.floor(Math.random()*e.length)]},t.randomString=function(e,t){void 0===t&&(t="abcdefghijklmnopqrstuvwxyz");var r="";for(;e--;)r+=t[Math.random()*t.length|0];return r},t.findBetween=function(e,t,r,n){void 0===n&&(n=!1);var a,o=[],i=0;for(;-1!=(a=e.indexOf(t))&&(a+=t.length,-1!=(i=e.indexOf(r,a)));){var u=e.substring(a,i);if(!n)return u;o.push(u),e=e.substring(i+r.length)}return o.length?o:null},t.normalDistributionStages=function(e,t,r){void 0===r&&(r=10);function n(e,t,r){return Math.exp(-.5*Math.pow((r-e)/t,2))/(t*Math.sqrt(2*Math.PI))}for(var a=new Array(r+2).fill(0),o=new Array(r+2).fill(Math.ceil(t/6)),i=[],u=0;u<=r;u++)a[u]=n(0,1,4*u/r-2);for(var s=Math.max.apply(Math,a),c=a.map((function(t){return Math.round(t*e/s)})),f=1;f<=r;f++)o[f]=Math.ceil(4*t/(6*r));for(var l=0;l<=r+1;l++)i.push({duration:"".concat(o[l],"s"),target:c[l]});return i};var n=r(400)},400:e=>{e.exports=require("k6/crypto")},744:e=>{e.exports=require("k6/execution")},610:e=>{e.exports=require("k6/metrics")}},t={};function r(n){var a=t[n];if(void 0!==a)return a.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,r),o.exports}var n={};(()=>{var e=n;Object.defineProperty(e,"__esModule",{value:!0}),e.uuidv4=e.randomString=e.randomItem=e.randomIntBetween=e.normalDistributionStages=e.findBetween=e.tagWithCurrentStageProfile=e.tagWithCurrentStageIndex=e.getCurrentStageIndex=e.parseDuration=e.check=void 0;var t=r(664);Object.defineProperty(e,"parseDuration",{enumerable:!0,get:function(){return t.parseDuration}}),Object.defineProperty(e,"getCurrentStageIndex",{enumerable:!0,get:function(){return t.getCurrentStageIndex}}),Object.defineProperty(e,"tagWithCurrentStageIndex",{enumerable:!0,get:function(){return t.tagWithCurrentStageIndex}}),Object.defineProperty(e,"tagWithCurrentStageProfile",{enumerable:!0,get:function(){return t.tagWithCurrentStageProfile}});var a=r(599);Object.defineProperty(e,"findBetween",{enumerable:!0,get:function(){return a.findBetween}}),Object.defineProperty(e,"normalDistributionStages",{enumerable:!0,get:function(){return a.normalDistributionStages}}),Object.defineProperty(e,"randomIntBetween",{enumerable:!0,get:function(){return a.randomIntBetween}}),Object.defineProperty(e,"randomItem",{enumerable:!0,get:function(){return a.randomItem}}),Object.defineProperty(e,"randomString",{enumerable:!0,get:function(){return a.randomString}}),Object.defineProperty(e,"uuidv4",{enumerable:!0,get:function(){return a.uuidv4}});var o=r(184);Object.defineProperty(e,"check",{enumerable:!0,get:function(){return o.check}})})();var a=exports;for(var o in n)a[o]=n[o];n.__esModule&&Object.defineProperty(a,"__esModule",{value:!0})})(); //# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/build/index.js.map b/build/index.js.map index a79fb4f..a90fbd8 100644 --- a/build/index.js.map +++ b/build/index.js.map @@ -1 +1 @@ -{"version":3,"file":"index.js","mappings":"mBACA,IAAIA,EAAsB,CCA1BA,EAAyBC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ACf,IACAF,EAAUE,EAAK,IACfF,EAAUE,EAAK,IACf,IACAF,EAAUE,EAAK,IACfF,EAAUE,EAAK,IACf,IACAF,EAAUE,EAAK,IACfF,EAAUE,EAAK,IACf,IACAF,EAAUE,EAAK,KACfF,EAAUE,EAAK,KACfF,EAAUE,EAAK,KACfF,EAAUE,EAAK,KACfF,EAAUE,EAAK,KACfF,EAAUE,EAAK,MACjBG,c,g9BCtIN,IAAMC,EAAY,IC3BmB/F,QAAQ,cD2BvBgG,MAAK,UAIpB,SAASC,EAAgClG,EAAcmG,GAC1D,IAAMC,EAAWD,GAAanG,EAExBqG,EAAUhH,OAAOiH,QAAQF,GAAUjB,KAAI,SAAAoB,GAAoB,IAAAC,EAAAC,EAAAF,EAAA,GAAlBpH,EAAGqH,EAAA,GAAEE,EAAOF,EAAA,GACvD,SAASG,EAAa3G,GAKlB,OAJAgG,EAAUY,IAAI5G,EAAQ,EAAI,EAAG,CACzBkG,MAAO/G,IAGJa,EAGX,GAAuB,mBAAZ0G,EAAwB,CAC/B,IAAMG,EAASH,EAAQ1G,GAEvB,OAAI6G,aAAkBC,QACXD,EAAOE,KAAKJ,GAGhBA,EAAaE,GAGxB,OAAIH,aAAmBI,QACZJ,EAAQK,KAAKJ,GAGjBA,EAAaD,MAGxB,OAAIL,EAAQW,MAAK,SAACH,GAAM,OAAKA,aAAkBC,WACpCA,QAAQG,IAAIZ,GAASU,MAAK,SAACV,GAAO,OAAKA,EAAQa,MAAMC,YAGzDd,EAAQa,MAAMC,S","sources":["webpack://k6-jslib-utils/webpack/bootstrap","webpack://k6-jslib-utils/webpack/runtime/compat get default export","webpack://k6-jslib-utils/webpack/runtime/define property getters","webpack://k6-jslib-utils/webpack/runtime/hasOwnProperty shorthand","webpack://k6-jslib-utils/webpack/runtime/make namespace object","webpack://k6-jslib-utils/external commonjs \"k6/execution\"","webpack://k6-jslib-utils/./src/stages.js","webpack://k6-jslib-utils/external commonjs \"k6/crypto\"","webpack://k6-jslib-utils/./src/utils.js","webpack://k6-jslib-utils/./src/check.ts","webpack://k6-jslib-utils/external commonjs \"k6/metrics\""],"sourcesContent":["// The require scope\nvar __webpack_require__ = {};\n\n","// getDefaultExport function for compatibility with non-harmony modules\n__webpack_require__.n = (module) => {\n\tvar getter = module && module.__esModule ?\n\t\t() => (module['default']) :\n\t\t() => (module);\n\t__webpack_require__.d(getter, { a: getter });\n\treturn getter;\n};","// define getter functions for harmony exports\n__webpack_require__.d = (exports, definition) => {\n\tfor(var key in definition) {\n\t\tif(__webpack_require__.o(definition, key) && !__webpack_require__.o(exports, key)) {\n\t\t\tObject.defineProperty(exports, key, { enumerable: true, get: definition[key] });\n\t\t}\n\t}\n};","__webpack_require__.o = (obj, prop) => (Object.prototype.hasOwnProperty.call(obj, prop))","// define __esModule on exports\n__webpack_require__.r = (exports) => {\n\tif(typeof Symbol !== 'undefined' && Symbol.toStringTag) {\n\t\tObject.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });\n\t}\n\tObject.defineProperty(exports, '__esModule', { value: true });\n};","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/execution\");","import exec from 'k6/execution'\n\n// parseDuration parses the provided string as an Integer number\n// in millisecond precision\nfunction parseDuration(str) {\n if (str == null || str.length < 1) {\n throw new Error('str is empty')\n }\n\n // the sum in millisecond of the parsed duration\n let d = 0\n\n // current contains the partial seen number\n // it's reset when a time unit is found\n let current = ''\n\n // it tracks the seen time units\n // and it denies eventual duplicated\n let seen = {}\n\n for (let i = 0; i < str.length; i++) {\n // append the current char if it's a number or a decimal separator\n if (isNumber(str[i]) || str[i] == '.') {\n current += str[i]\n }\n\n // return if the next char is not a time unit\n if (str[i + 1] == null || isNumber(str[i + 1]) || str[i + 1] == '.') {\n continue\n }\n\n let v = parseFloat(current, 10)\n let next = str[i + 1]\n\n switch (next) {\n case 'd':\n d += v * 24 * 60 * 60 * 1000\n break\n case 'h':\n d += v * 60 * 60 * 1000\n break\n case 'm':\n if (i + 2 < str.length && str[i + 2] == 's') {\n // millisecond is the maximum precision\n // truncate eventual decimal\n d += Math.trunc(v)\n i++\n next = 'ms'\n } else {\n d += v * 60 * 1000\n }\n break\n case 's':\n d += v * 1000\n break\n default:\n throw new Error(`${next} is an unsupported time unit`)\n }\n if (seen[next]) {\n throw new Error(`${next} time unit is provided multiple times`)\n }\n seen[next] = true\n i++\n current = ''\n }\n // flush in case no time unit has been provided\n // for the latest group\n if (current.length > 0) {\n d += parseFloat(current, 10)\n }\n return d\n}\n\n// isNumber return true if the c character is a number\nfunction isNumber(c) {\n return c >= '0' && c <= '9'\n}\n\n// getCurrentStageIndex returns the computed index of the running stage.\nfunction getCurrentStageIndex() {\n let scenario = exec.test.options.scenarios[exec.scenario.name]\n if (scenario == null) {\n throw new Error(\n `the exec.test.options object doesn't contain the current scenario ${exec.scenario.name}`\n )\n }\n if (scenario.stages == null) {\n throw new Error(\n `only ramping-vus or ramping-arravial-rate supports stages, it is not possible to get a stage index on other executors.`\n )\n }\n\n if (scenario.stages.length < 1) {\n throw new Error(`the current scenario ${scenario.name} doesn't contain any stage`)\n }\n\n let sum = 0\n let elapsed = new Date() - exec.scenario.startTime\n for (let i = 0; i < scenario.stages.length; i++) {\n sum += parseDuration(scenario.stages[i].duration)\n if (elapsed < sum) {\n return i\n }\n }\n\n return scenario.stages.length - 1\n}\n\n// tagWithCurrentStageIndex adds a tag with a `stage` key\n// and the index of the current running stage as value.\nfunction tagWithCurrentStageIndex() {\n exec.vu.tags['stage'] = getCurrentStageIndex()\n}\n\n// tagWithCurrentStageProfile adds a tag with a `stage` key\n// and the profile (ramp-up, steady or ramp-down) computed\n// from the current running stage.\nfunction tagWithCurrentStageProfile() {\n //ramp-up when previous.target < current.target\n //ramp-down when previous.target > current.target\n //steady when prevuious.target = current.target\n\n let getStageProfile = function () {\n let currentIndex = getCurrentStageIndex()\n if (currentIndex < 1) {\n return 'ramp-up'\n }\n\n let stages = exec.test.options.scenarios[exec.scenario.name].stages\n let current = stages[currentIndex]\n let previous = stages[currentIndex - 1]\n\n if (current.target > previous.target) {\n return 'ramp-up'\n }\n\n if (previous.target == current.target) {\n return 'steady'\n }\n\n return 'ramp-down'\n }\n\n exec.vu.tags['stage_profile'] = getStageProfile()\n}\n\nexport { parseDuration, getCurrentStageIndex, tagWithCurrentStageIndex, tagWithCurrentStageProfile }\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/crypto\");","import { randomBytes } from 'k6/crypto'\n\n/**\n * Produces a Universal Unique Identifier version 4\n *\n * @param {boolean} secure - whether a cryptographically secure generation function should be used\n * @returns {String} - 16 characters hexadecimal representation of the UUID v4\n */\nexport function uuidv4(secure = false) {\n return secure ? secureUUIDv4() : insecureUUIDv4()\n}\n\nexport function randomIntBetween(min, max) {\n // min and max included\n return Math.floor(Math.random() * (max - min + 1) + min)\n}\n\nexport function randomItem(arrayOfItems) {\n return arrayOfItems[Math.floor(Math.random() * arrayOfItems.length)]\n}\n\nexport function randomString(length, charset = 'abcdefghijklmnopqrstuvwxyz') {\n let res = ''\n while (length--) res += charset[(Math.random() * charset.length) | 0]\n return res\n}\n\nexport function findBetween(content, left, right, repeat = false) {\n const extracted = []\n let doSearch = true\n let start,\n end = 0\n\n while (doSearch) {\n start = content.indexOf(left)\n if (start == -1) {\n break // no more matches\n }\n\n start += left.length\n end = content.indexOf(right, start)\n if (end == -1) {\n break // no more matches\n }\n let extractedContent = content.substring(start, end)\n\n // stop here if only extracting one match (default behavior)\n if (!repeat) {\n return extractedContent\n }\n\n // otherwise, add it to the array\n extracted.push(extractedContent)\n\n // update the \"cursor\" position to the end of the previous match\n content = content.substring(end + right.length)\n }\n\n return extracted.length ? extracted : null // return all matches as an array or null\n}\n\nexport function normalDistributionStages(maxVus, durationSeconds, numberOfStages = 10) {\n function normalDensity(mean, scale, x) {\n return (\n Math.exp((-1 / 2) * Math.pow((x - mean) / scale, 2)) / (scale * Math.sqrt(2 * Math.PI))\n )\n }\n\n const mean = 0\n const scale = 1\n let curve = new Array(numberOfStages + 2).fill(0)\n let durations = new Array(numberOfStages + 2).fill(Math.ceil(durationSeconds / 6))\n let k6stages = []\n\n for (let i = 0; i <= numberOfStages; i++) {\n curve[i] = normalDensity(mean, scale, -2 * scale + (4 * scale * i) / numberOfStages)\n }\n\n let peakDistribution = Math.max(...curve)\n\n let vus = curve.map((x) => Math.round((x * maxVus) / peakDistribution))\n\n for (let j = 1; j <= numberOfStages; j++) {\n durations[j] = Math.ceil((4 * durationSeconds) / (6 * numberOfStages))\n }\n\n for (let k = 0; k <= numberOfStages + 1; k++) {\n k6stages.push({ duration: `${durations[k]}s`, target: vus[k] })\n }\n\n return k6stages\n}\n\n/**\n * Fast UUID v4 producer\n *\n * Note that this function does not produce cryptographically\n * secure UUIDs. If you need safe UUIDs, use the secureUUIDv4\n * implementation instead.\n *\n * @returns {String} - 16 characters hexadecimal representation of the UUID v4\n */\nfunction insecureUUIDv4() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n let r = (Math.random() * 16) | 0,\n v = c === 'x' ? r : (r & 0x3) | 0x8\n return v.toString(16)\n })\n}\n\n/**\n * Cryptographically secure UUID v4 producer\n *\n * Note that this implementation involves a computation\n * overhead.\n *\n * @returns {String} - 16 characters hexadecimal representation of the UUID v4\n */\nfunction secureUUIDv4() {\n /**\n * bytes conversion table used to convert UUIDs bytes\n * to string form.\n */\n const byteToHex = []\n for (let i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1))\n }\n\n /**\n * produce 16 random bytes, and set UUID v4's specific\n * version and `clock_seq_hi_and_reserved` bits.\n */\n const rnds = new Uint8Array(randomBytes(16))\n rnds[6] = (rnds[6] & 0x0f) | 0x40\n rnds[8] = (rnds[8] & 0x3f) | 0x80\n\n /**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n return (\n byteToHex[rnds[0]] +\n byteToHex[rnds[1]] +\n byteToHex[rnds[2]] +\n byteToHex[rnds[3]] +\n '-' +\n byteToHex[rnds[4]] +\n byteToHex[rnds[5]] +\n '-' +\n byteToHex[rnds[6]] +\n byteToHex[rnds[7]] +\n '-' +\n byteToHex[rnds[8]] +\n byteToHex[rnds[9]] +\n '-' +\n byteToHex[rnds[10]] +\n byteToHex[rnds[11]] +\n byteToHex[rnds[12]] +\n byteToHex[rnds[13]] +\n byteToHex[rnds[14]] +\n byteToHex[rnds[15]]\n ).toLowerCase()\n}\n","import { Rate } from 'k6/metrics'\n\ntype FalsyCheckValue =\n | Array\n | Record\n | boolean\n | string\n | number\n | null\n | undefined\n\ntype Checker =\n | ((value: T) => FalsyCheckValue)\n | ((value: T) => Promise)\n | FalsyCheckValue\n | Promise\n\ninterface CheckMap {\n [key: string]: Checker\n}\n\ninterface SyncCheckMap {\n [key: string]: ((value: any) => FalsyCheckValue) | FalsyCheckValue\n}\n\ntype CheckResult> = C extends SyncCheckMap ? boolean : Promise\n\nconst checkRate = new Rate('checks')\n\nexport function check>(checkers: C): CheckResult\nexport function check>(value: T, checkers: C): CheckResult\nexport function check>(value: T | C, checkers?: C): CheckResult {\n const checkMap = checkers || (value as C)\n\n const results = Object.entries(checkMap).map(([key, checker]) => {\n function reportResult(value: FalsyCheckValue): FalsyCheckValue {\n checkRate.add(value ? 1 : 0, {\n check: key,\n })\n\n return value\n }\n\n if (typeof checker === 'function') {\n const result = checker(value as T)\n\n if (result instanceof Promise) {\n return result.then(reportResult)\n }\n\n return reportResult(result)\n }\n\n if (checker instanceof Promise) {\n return checker.then(reportResult)\n }\n\n return reportResult(checker)\n })\n\n if (results.some((result) => result instanceof Promise)) {\n return Promise.all(results).then((results) => results.every(Boolean)) as CheckResult\n }\n\n return results.every(Boolean) as CheckResult\n}\n","const __WEBPACK_NAMESPACE_OBJECT__ = require(\"k6/metrics\");"],"names":["__webpack_require__","module","getter","__esModule","d","a","exports","definition","key","o","Object","defineProperty","enumerable","get","obj","prop","prototype","hasOwnProperty","call","Symbol","toStringTag","value","require","parseDuration","str","length","Error","current","seen","i","isNumber","v","parseFloat","next","Math","trunc","concat","c","getCurrentStageIndex","scenario","exec","stages","name","sum","elapsed","Date","duration","tagWithCurrentStageIndex","tagWithCurrentStageProfile","currentIndex","previous","target","getStageProfile","uuidv4","secure","arguments","undefined","secureUUIDv4","insecureUUIDv4","randomIntBetween","min","max","floor","random","randomItem","arrayOfItems","randomString","charset","res","findBetween","content","left","right","start","repeat","extracted","doSearch","end","indexOf","extractedContent","substring","push","normalDistributionStages","maxVus","durationSeconds","numberOfStages","normalDensity","mean","scale","x","exp","pow","sqrt","PI","curve","Array","fill","durations","ceil","k6stages","peakDistribution","apply","_toConsumableArray","vus","map","round","j","k","replace","r","toString","byteToHex","slice","rnds","Uint8Array","randomBytes","toLowerCase","checkRate","Rate","check","checkers","checkMap","results","entries","_ref","_ref2","_slicedToArray","checker","reportResult","add","result","Promise","then","some","all","every","Boolean"],"sourceRoot":""} \ No newline at end of file +{"version":3,"file":"index.js","mappings":"wCACAA,OAAOC,eAAeC,EAAS,aAAc,CAAEC,OAAO,IACtDD,EAAQE,MAGR,SAAeD,EAAOE,GAClB,IAAIC,EAAWD,GAAYF,EACvBI,EAAUP,OAAOQ,QAAQF,GAAUG,KAAI,SAAUC,GACjD,IAAIC,EAAMD,EAAG,GAAIE,EAAUF,EAAG,GAC9B,SAASG,EAAaV,GAIlB,OAHAW,EAAUC,IAAIZ,EAAQ,EAAI,EAAG,CACzBC,MAAOO,IAEJR,EAEX,GAAuB,mBAAZS,EAAwB,CAC/B,IAAII,EAASJ,EAAQT,GACrB,OAAIa,aAAkBC,QACXD,EAAOE,KAAKL,GAEhBA,EAAaG,GAExB,OAAIJ,aAAmBK,QACZL,EAAQM,KAAKL,GAEjBA,EAAaD,MAExB,GAAIL,EAAQY,MAAK,SAAUH,GAAU,OAAOA,aAAkBC,WAC1D,OAAOA,QAAQG,IAAIb,GAASW,MAAK,SAAUX,GAAW,OAAOA,EAAQc,MAA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,WAAc,OAAOC,EAAWxD,oBAC5GjF,OAAOC,eAAeC,EAAS,aAAc,CAAEqI,YAAY,EAAMC,IAAK,WAAc,OAAOC,EAAWpD,cACtGrF,OAAOC,eAAeC,EAAS,eAAgB,CAAEqI,YAAY,EAAMC,IAAK,WAAc,OAAOC,EAAWlD,gBACxGvF,OAAOC,eAAeC,EAAS,SAAU,CAAEqI,YAAY,EAAMC,IAAK,WAAc,OAAOC,EAAWvE,UAClG,IAAIwE,EAAa,EAAQ,KACzB1I,OAAOC,eAAeC,EAAS,QAAS,CAAEqI,YAAY,EAAMC,IAAK,WAAc,OAAOE,EAAWtI,U","sources":["webpack://k6-jslib-utils/./src/check.ts","webpack://k6-jslib-utils/./src/stages.js","webpack://k6-jslib-utils/./src/utils.js","webpack://k6-jslib-utils/external commonjs \"k6/crypto\"","webpack://k6-jslib-utils/external commonjs \"k6/execution\"","webpack://k6-jslib-utils/external commonjs \"k6/metrics\"","webpack://k6-jslib-utils/webpack/bootstrap","webpack://k6-jslib-utils/./src/index.js"],"sourcesContent":["\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.check = check;\nvar metrics_1 = require(\"k6/metrics\");\nvar checkRate = new metrics_1.Rate('checks');\nfunction check(value, checkers) {\n var checkMap = checkers || value;\n var results = Object.entries(checkMap).map(function (_a) {\n var key = _a[0], checker = _a[1];\n function reportResult(value) {\n checkRate.add(value ? 1 : 0, {\n check: key,\n });\n return value;\n }\n if (typeof checker === 'function') {\n var result = checker(value);\n if (result instanceof Promise) {\n return result.then(reportResult);\n }\n return reportResult(result);\n }\n if (checker instanceof Promise) {\n return checker.then(reportResult);\n }\n return reportResult(checker);\n });\n if (results.some(function (result) { return result instanceof Promise; })) {\n return Promise.all(results).then(function (results) { return results.every(Boolean); });\n }\n return results.every(Boolean);\n}\n","\"use strict\";\nvar __importDefault = (this && this.__importDefault) || function (mod) {\n return (mod && mod.__esModule) ? mod : { \"default\": mod };\n};\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.parseDuration = parseDuration;\nexports.getCurrentStageIndex = getCurrentStageIndex;\nexports.tagWithCurrentStageIndex = tagWithCurrentStageIndex;\nexports.tagWithCurrentStageProfile = tagWithCurrentStageProfile;\nvar execution_1 = __importDefault(require(\"k6/execution\"));\n// parseDuration parses the provided string as an Integer number\n// in millisecond precision\nfunction parseDuration(str) {\n if (str == null || str.length < 1) {\n throw new Error('str is empty');\n }\n // the sum in millisecond of the parsed duration\n var d = 0;\n // current contains the partial seen number\n // it's reset when a time unit is found\n var current = '';\n // it tracks the seen time units\n // and it denies eventual duplicated\n var seen = {};\n for (var i = 0; i < str.length; i++) {\n // append the current char if it's a number or a decimal separator\n if (isNumber(str[i]) || str[i] == '.') {\n current += str[i];\n }\n // return if the next char is not a time unit\n if (str[i + 1] == null || isNumber(str[i + 1]) || str[i + 1] == '.') {\n continue;\n }\n var v = parseFloat(current, 10);\n var next = str[i + 1];\n switch (next) {\n case 'd':\n d += v * 24 * 60 * 60 * 1000;\n break;\n case 'h':\n d += v * 60 * 60 * 1000;\n break;\n case 'm':\n if (i + 2 < str.length && str[i + 2] == 's') {\n // millisecond is the maximum precision\n // truncate eventual decimal\n d += Math.trunc(v);\n i++;\n next = 'ms';\n }\n else {\n d += v * 60 * 1000;\n }\n break;\n case 's':\n d += v * 1000;\n break;\n default:\n throw new Error(\"\".concat(next, \" is an unsupported time unit\"));\n }\n if (seen[next]) {\n throw new Error(\"\".concat(next, \" time unit is provided multiple times\"));\n }\n seen[next] = true;\n i++;\n current = '';\n }\n // flush in case no time unit has been provided\n // for the latest group\n if (current.length > 0) {\n d += parseFloat(current, 10);\n }\n return d;\n}\n// isNumber return true if the c character is a number\nfunction isNumber(c) {\n return c >= '0' && c <= '9';\n}\n// getCurrentStageIndex returns the computed index of the running stage.\nfunction getCurrentStageIndex() {\n var scenario = execution_1.default.test.options.scenarios[execution_1.default.scenario.name];\n if (scenario == null) {\n throw new Error(\"the exec.test.options object doesn't contain the current scenario \".concat(execution_1.default.scenario.name));\n }\n if (scenario.stages == null) {\n throw new Error(\"only ramping-vus or ramping-arravial-rate supports stages, it is not possible to get a stage index on other executors.\");\n }\n if (scenario.stages.length < 1) {\n throw new Error(\"the current scenario \".concat(scenario.name, \" doesn't contain any stage\"));\n }\n var sum = 0;\n var elapsed = new Date() - execution_1.default.scenario.startTime;\n for (var i = 0; i < scenario.stages.length; i++) {\n sum += parseDuration(scenario.stages[i].duration);\n if (elapsed < sum) {\n return i;\n }\n }\n return scenario.stages.length - 1;\n}\n// tagWithCurrentStageIndex adds a tag with a `stage` key\n// and the index of the current running stage as value.\nfunction tagWithCurrentStageIndex() {\n execution_1.default.vu.tags['stage'] = getCurrentStageIndex();\n}\n// tagWithCurrentStageProfile adds a tag with a `stage` key\n// and the profile (ramp-up, steady or ramp-down) computed\n// from the current running stage.\nfunction tagWithCurrentStageProfile() {\n //ramp-up when previous.target < current.target\n //ramp-down when previous.target > current.target\n //steady when prevuious.target = current.target\n var getStageProfile = function () {\n var currentIndex = getCurrentStageIndex();\n if (currentIndex < 1) {\n return 'ramp-up';\n }\n var stages = execution_1.default.test.options.scenarios[execution_1.default.scenario.name].stages;\n var current = stages[currentIndex];\n var previous = stages[currentIndex - 1];\n if (current.target > previous.target) {\n return 'ramp-up';\n }\n if (previous.target == current.target) {\n return 'steady';\n }\n return 'ramp-down';\n };\n execution_1.default.vu.tags['stage_profile'] = getStageProfile();\n}\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uuidv4 = uuidv4;\nexports.randomIntBetween = randomIntBetween;\nexports.randomItem = randomItem;\nexports.randomString = randomString;\nexports.findBetween = findBetween;\nexports.normalDistributionStages = normalDistributionStages;\nvar crypto_1 = require(\"k6/crypto\");\n/**\n * Produces a Universal Unique Identifier version 4\n *\n * @param {boolean} secure - whether a cryptographically secure generation function should be used\n * @returns {String} - 16 characters hexadecimal representation of the UUID v4\n */\nfunction uuidv4(secure) {\n if (secure === void 0) { secure = false; }\n return secure ? secureUUIDv4() : insecureUUIDv4();\n}\nfunction randomIntBetween(min, max) {\n // min and max included\n return Math.floor(Math.random() * (max - min + 1) + min);\n}\nfunction randomItem(arrayOfItems) {\n return arrayOfItems[Math.floor(Math.random() * arrayOfItems.length)];\n}\nfunction randomString(length, charset) {\n if (charset === void 0) { charset = 'abcdefghijklmnopqrstuvwxyz'; }\n var res = '';\n while (length--)\n res += charset[(Math.random() * charset.length) | 0];\n return res;\n}\nfunction findBetween(content, left, right, repeat) {\n if (repeat === void 0) { repeat = false; }\n var extracted = [];\n var doSearch = true;\n var start, end = 0;\n while (doSearch) {\n start = content.indexOf(left);\n if (start == -1) {\n break; // no more matches\n }\n start += left.length;\n end = content.indexOf(right, start);\n if (end == -1) {\n break; // no more matches\n }\n var extractedContent = content.substring(start, end);\n // stop here if only extracting one match (default behavior)\n if (!repeat) {\n return extractedContent;\n }\n // otherwise, add it to the array\n extracted.push(extractedContent);\n // update the \"cursor\" position to the end of the previous match\n content = content.substring(end + right.length);\n }\n return extracted.length ? extracted : null; // return all matches as an array or null\n}\nfunction normalDistributionStages(maxVus, durationSeconds, numberOfStages) {\n if (numberOfStages === void 0) { numberOfStages = 10; }\n function normalDensity(mean, scale, x) {\n return (Math.exp((-1 / 2) * Math.pow((x - mean) / scale, 2)) / (scale * Math.sqrt(2 * Math.PI)));\n }\n var mean = 0;\n var scale = 1;\n var curve = new Array(numberOfStages + 2).fill(0);\n var durations = new Array(numberOfStages + 2).fill(Math.ceil(durationSeconds / 6));\n var k6stages = [];\n for (var i = 0; i <= numberOfStages; i++) {\n curve[i] = normalDensity(mean, scale, -2 * scale + (4 * scale * i) / numberOfStages);\n }\n var peakDistribution = Math.max.apply(Math, curve);\n var vus = curve.map(function (x) { return Math.round((x * maxVus) / peakDistribution); });\n for (var j = 1; j <= numberOfStages; j++) {\n durations[j] = Math.ceil((4 * durationSeconds) / (6 * numberOfStages));\n }\n for (var k = 0; k <= numberOfStages + 1; k++) {\n k6stages.push({ duration: \"\".concat(durations[k], \"s\"), target: vus[k] });\n }\n return k6stages;\n}\n/**\n * Fast UUID v4 producer\n *\n * Note that this function does not produce cryptographically\n * secure UUIDs. If you need safe UUIDs, use the secureUUIDv4\n * implementation instead.\n *\n * @returns {String} - 16 characters hexadecimal representation of the UUID v4\n */\nfunction insecureUUIDv4() {\n return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {\n var r = (Math.random() * 16) | 0, v = c === 'x' ? r : (r & 0x3) | 0x8;\n return v.toString(16);\n });\n}\n/**\n * Cryptographically secure UUID v4 producer\n *\n * Note that this implementation involves a computation\n * overhead.\n *\n * @returns {String} - 16 characters hexadecimal representation of the UUID v4\n */\nfunction secureUUIDv4() {\n /**\n * bytes conversion table used to convert UUIDs bytes\n * to string form.\n */\n var byteToHex = [];\n for (var i = 0; i < 256; ++i) {\n byteToHex.push((i + 0x100).toString(16).slice(1));\n }\n /**\n * produce 16 random bytes, and set UUID v4's specific\n * version and `clock_seq_hi_and_reserved` bits.\n */\n var rnds = new Uint8Array((0, crypto_1.randomBytes)(16));\n rnds[6] = (rnds[6] & 0x0f) | 0x40;\n rnds[8] = (rnds[8] & 0x3f) | 0x80;\n /**\n * Convert array of 16 byte values to UUID string format of the form:\n * XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX\n */\n return (byteToHex[rnds[0]] +\n byteToHex[rnds[1]] +\n byteToHex[rnds[2]] +\n byteToHex[rnds[3]] +\n '-' +\n byteToHex[rnds[4]] +\n byteToHex[rnds[5]] +\n '-' +\n byteToHex[rnds[6]] +\n byteToHex[rnds[7]] +\n '-' +\n byteToHex[rnds[8]] +\n byteToHex[rnds[9]] +\n '-' +\n byteToHex[rnds[10]] +\n byteToHex[rnds[11]] +\n byteToHex[rnds[12]] +\n byteToHex[rnds[13]] +\n byteToHex[rnds[14]] +\n byteToHex[rnds[15]]).toLowerCase();\n}\n","module.exports = require(\"k6/crypto\");","module.exports = require(\"k6/execution\");","module.exports = require(\"k6/metrics\");","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","\"use strict\";\nObject.defineProperty(exports, \"__esModule\", { value: true });\nexports.uuidv4 = exports.randomString = exports.randomItem = exports.randomIntBetween = exports.normalDistributionStages = exports.findBetween = exports.tagWithCurrentStageProfile = exports.tagWithCurrentStageIndex = exports.getCurrentStageIndex = exports.parseDuration = exports.check = void 0;\nvar stages_js_1 = require(\"./stages.js\");\nObject.defineProperty(exports, \"parseDuration\", { enumerable: true, get: function () { return stages_js_1.parseDuration; } });\nObject.defineProperty(exports, \"getCurrentStageIndex\", { enumerable: true, get: function () { return stages_js_1.getCurrentStageIndex; } });\nObject.defineProperty(exports, \"tagWithCurrentStageIndex\", { enumerable: true, get: function () { return stages_js_1.tagWithCurrentStageIndex; } });\nObject.defineProperty(exports, \"tagWithCurrentStageProfile\", { enumerable: true, get: function () { return stages_js_1.tagWithCurrentStageProfile; } });\nvar utils_js_1 = require(\"./utils.js\");\nObject.defineProperty(exports, \"findBetween\", { enumerable: true, get: function () { return utils_js_1.findBetween; } });\nObject.defineProperty(exports, \"normalDistributionStages\", { enumerable: true, get: function () { return utils_js_1.normalDistributionStages; } });\nObject.defineProperty(exports, \"randomIntBetween\", { enumerable: true, get: function () { return utils_js_1.randomIntBetween; } });\nObject.defineProperty(exports, \"randomItem\", { enumerable: true, get: function () { return utils_js_1.randomItem; } });\nObject.defineProperty(exports, \"randomString\", { enumerable: true, get: function () { return utils_js_1.randomString; } });\nObject.defineProperty(exports, \"uuidv4\", { enumerable: true, get: function () { return utils_js_1.uuidv4; } });\nvar check_ts_1 = require(\"./check.ts\");\nObject.defineProperty(exports, \"check\", { enumerable: true, get: function () { return check_ts_1.check; } });\n"],"names":["Object","defineProperty","exports","value","check","checkers","checkMap","results","entries","map","_a","key","checker","reportResult","checkRate","add","result","Promise","then","some","all","every","Boolean","Rate","__importDefault","this","mod","__esModule","parseDuration","getCurrentStageIndex","tagWithCurrentStageIndex","execution_1","default","vu","tags","tagWithCurrentStageProfile","currentIndex","stages","test","options","scenarios","scenario","name","current","previous","target","getStageProfile","str","length","Error","d","seen","i","isNumber","v","parseFloat","next","Math","trunc","concat","c","sum","elapsed","Date","startTime","duration","uuidv4","secure","byteToHex","push","toString","slice","rnds","Uint8Array","crypto_1","randomBytes","toLowerCase","secureUUIDv4","replace","r","random","randomIntBetween","min","max","floor","randomItem","arrayOfItems","randomString","charset","res","findBetween","content","left","right","repeat","start","extracted","end","indexOf","extractedContent","substring","normalDistributionStages","maxVus","durationSeconds","numberOfStages","normalDensity","mean","scale","x","exp","pow","sqrt","PI","curve","Array","fill","durations","ceil","k6stages","peakDistribution","apply","vus","round","j","k","module","require","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","undefined","__webpack_modules__","call","stages_js_1","enumerable","get","utils_js_1","check_ts_1"],"sourceRoot":""} \ No newline at end of file diff --git a/build/stages.d.ts b/build/stages.d.ts new file mode 100644 index 0000000..f4c1c8b --- /dev/null +++ b/build/stages.d.ts @@ -0,0 +1,4 @@ +export function parseDuration(str: any): number; +export function getCurrentStageIndex(): number; +export function tagWithCurrentStageIndex(): void; +export function tagWithCurrentStageProfile(): void; diff --git a/build/utils.d.ts b/build/utils.d.ts new file mode 100644 index 0000000..d3be2e0 --- /dev/null +++ b/build/utils.d.ts @@ -0,0 +1,15 @@ +/** + * Produces a Universal Unique Identifier version 4 + * + * @param {boolean} secure - whether a cryptographically secure generation function should be used + * @returns {String} - 16 characters hexadecimal representation of the UUID v4 + */ +export function uuidv4(secure?: boolean): string; +export function randomIntBetween(min: any, max: any): number; +export function randomItem(arrayOfItems: any): any; +export function randomString(length: any, charset?: string): string; +export function findBetween(content: any, left: any, right: any, repeat?: boolean): any; +export function normalDistributionStages(maxVus: any, durationSeconds: any, numberOfStages?: number): { + duration: string; + target: number; +}[]; diff --git a/package-lock.json b/package-lock.json index cc2eaef..3d87b60 100644 --- a/package-lock.json +++ b/package-lock.json @@ -21,6 +21,7 @@ "lint-staged": "^12.4.1", "prettier": "2.6.2", "terser-webpack-plugin": "^5.3.1", + "ts-loader": "^9.5.1", "webpack": "^5.72.0", "webpack-cli": "^4.9.2", "webpack-glob-entries": "^1.0.1" @@ -4217,6 +4218,15 @@ "url": "https://github.com/chalk/ansi-styles?sponsor=1" } }, + "node_modules/source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true, + "engines": { + "node": ">= 8" + } + }, "node_modules/source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -4446,6 +4456,108 @@ "punycode": "^2.1.0" } }, + "node_modules/ts-loader": { + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.1.tgz", + "integrity": "sha512-rNH3sK9kGZcH9dYzC7CewQm4NtxJTjSEVRJ2DyBZR7f8/wcta+iV44UPCXc5+nzDzivKtlzV6c9P4e+oFhDLYg==", + "dev": true, + "dependencies": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.0.0", + "micromatch": "^4.0.0", + "semver": "^7.3.4", + "source-map": "^0.7.4" + }, + "engines": { + "node": ">=12.0.0" + }, + "peerDependencies": { + "typescript": "*", + "webpack": "^5.0.0" + } + }, + "node_modules/ts-loader/node_modules/ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "dependencies": { + "color-convert": "^2.0.1" + }, + "engines": { + "node": ">=8" + }, + "funding": { + "url": "https://github.com/chalk/ansi-styles?sponsor=1" + } + }, + "node_modules/ts-loader/node_modules/chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "dependencies": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + }, + "engines": { + "node": ">=10" + }, + "funding": { + "url": "https://github.com/chalk/chalk?sponsor=1" + } + }, + "node_modules/ts-loader/node_modules/color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "dependencies": { + "color-name": "~1.1.4" + }, + "engines": { + "node": ">=7.0.0" + } + }, + "node_modules/ts-loader/node_modules/color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "node_modules/ts-loader/node_modules/has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, + "node_modules/ts-loader/node_modules/semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true, + "bin": { + "semver": "bin/semver.js" + }, + "engines": { + "node": ">=10" + } + }, + "node_modules/ts-loader/node_modules/supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "dependencies": { + "has-flag": "^4.0.0" + }, + "engines": { + "node": ">=8" + } + }, "node_modules/tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", @@ -4464,6 +4576,20 @@ "url": "https://github.com/sponsors/sindresorhus" } }, + "node_modules/typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dev": true, + "peer": true, + "bin": { + "tsc": "bin/tsc", + "tsserver": "bin/tsserver" + }, + "engines": { + "node": ">=14.17" + } + }, "node_modules/unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", @@ -7906,6 +8032,12 @@ } } }, + "source-map": { + "version": "0.7.4", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.7.4.tgz", + "integrity": "sha512-l3BikUxvPOcn5E74dZiq5BGsTb5yEwhaTSzccU6t4sDOH8NWJCstKO5QT2CvtFoK6F0saL7p9xHAqHOlCPJygA==", + "dev": true + }, "source-map-support": { "version": "0.5.21", "resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz", @@ -8062,6 +8194,76 @@ "punycode": "^2.1.0" } }, + "ts-loader": { + "version": "9.5.1", + "resolved": "https://registry.npmjs.org/ts-loader/-/ts-loader-9.5.1.tgz", + "integrity": "sha512-rNH3sK9kGZcH9dYzC7CewQm4NtxJTjSEVRJ2DyBZR7f8/wcta+iV44UPCXc5+nzDzivKtlzV6c9P4e+oFhDLYg==", + "dev": true, + "requires": { + "chalk": "^4.1.0", + "enhanced-resolve": "^5.0.0", + "micromatch": "^4.0.0", + "semver": "^7.3.4", + "source-map": "^0.7.4" + }, + "dependencies": { + "ansi-styles": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz", + "integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==", + "dev": true, + "requires": { + "color-convert": "^2.0.1" + } + }, + "chalk": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz", + "integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==", + "dev": true, + "requires": { + "ansi-styles": "^4.1.0", + "supports-color": "^7.1.0" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "semver": { + "version": "7.6.3", + "resolved": "https://registry.npmjs.org/semver/-/semver-7.6.3.tgz", + "integrity": "sha512-oVekP1cKtI+CTDvHWYFUcMtsK/00wmAEfyqKfNdARm8u1wNVhSgaX7A8d4UuIlUI5e84iEwOhs7ZPYRmzU9U6A==", + "dev": true + }, + "supports-color": { + "version": "7.2.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz", + "integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==", + "dev": true, + "requires": { + "has-flag": "^4.0.0" + } + } + } + }, "tslib": { "version": "2.4.0", "resolved": "https://registry.npmjs.org/tslib/-/tslib-2.4.0.tgz", @@ -8074,6 +8276,13 @@ "integrity": "sha512-t0rzBq87m3fVcduHDUFhKmyyX+9eo6WQjZvf51Ea/M0Q7+T374Jp1aUiyUl0GKxp8M/OETVHSDvmkyPgvX+X2w==", "dev": true }, + "typescript": { + "version": "5.5.4", + "resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz", + "integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==", + "dev": true, + "peer": true + }, "unicode-canonical-property-names-ecmascript": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/unicode-canonical-property-names-ecmascript/-/unicode-canonical-property-names-ecmascript-2.0.0.tgz", diff --git a/package.json b/package.json index 040ee61..a2ff20f 100644 --- a/package.json +++ b/package.json @@ -7,7 +7,6 @@ "@babel/core": "^7.4.4", "@babel/plugin-transform-block-scoping": "^7.14.1", "@babel/preset-env": "^7.4.4", - "@babel/preset-typescript": "^7.24.7", "@types/k6": "^0.52.0", "@types/webpack": "^5.28.0", "babel-loader": "^8.0.6", @@ -16,6 +15,7 @@ "lint-staged": "^12.4.1", "prettier": "2.6.2", "terser-webpack-plugin": "^5.3.1", + "ts-loader": "^9.5.1", "webpack": "^5.72.0", "webpack-cli": "^4.9.2", "webpack-glob-entries": "^1.0.1" @@ -23,7 +23,7 @@ "engines": {}, "scripts": { "webpack": "webpack", - "test": "k6 run --compatibility-mode=experimental_enhanced tests/", + "test": "k6 run tests/", "prepare": "husky install" }, "keywords": [ diff --git a/tests/check.ts b/tests/check.ts index 1e5d520..6fa1eb2 100644 --- a/tests/check.ts +++ b/tests/check.ts @@ -1,5 +1,5 @@ import { check } from 'k6' -import { check as asyncCheck } from '../src/check.ts' +import { check as asyncCheck } from '../build/index.js' export const options = { iterations: 1, diff --git a/tsconfig.json b/tsconfig.json new file mode 100644 index 0000000..d687279 --- /dev/null +++ b/tsconfig.json @@ -0,0 +1,15 @@ +{ + "compilerOptions": { + "target": "es5", + "module": "commonjs", + "outDir": "./dist", + "rootDir": "./src", + "strict": true, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "declaration": true, + "declarationDir": "./build", + "allowJs": true + }, + "include": ["src/**/*.ts", "src/**/*.js"] +} diff --git a/webpack.config.js b/webpack.config.js index 869c091..8137d7a 100644 --- a/webpack.config.js +++ b/webpack.config.js @@ -17,11 +17,16 @@ module.exports = { }, module: { rules: [ + // { + // test: /\.js$/, + // loader: 'babel-loader', + // exclude: /node_modules/, + // }, { test: /\.(j|t)s$/, - loader: 'babel-loader', + loader: 'ts-loader', exclude: /node_modules/, - }, + } ], }, stats: {