Skip to content

Commit dc563be

Browse files
committed
compiled files updated
1 parent 2956b57 commit dc563be

9 files changed

+12029
-13917
lines changed

client/splunk.js

Lines changed: 831 additions & 678 deletions
Large diffs are not rendered by default.

client/splunk.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/splunk.test.js

Lines changed: 10507 additions & 13162 deletions
Large diffs are not rendered by default.

client/splunk.test.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client/splunk.ui.charting.js

Lines changed: 316 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -23172,7 +23172,7 @@ exports.Highcharts = {
2317223172
* @function splunkjs.Utils
2317323173
*/
2317423174
root.indexOf = function(arr, search) {
23175-
for(var i=0; i<arr.length; i++) {
23175+
for(let i=0; i<arr.length; i++) {
2317623176
if (arr[i] === search) {
2317723177
return i;
2317823178
}
@@ -23214,7 +23214,7 @@ exports.Highcharts = {
2321423214
* @function splunkjs.Utils
2321523215
*/
2321623216
root.startsWith = function(original, prefix) {
23217-
var matches = original.match("^" + prefix);
23217+
let matches = original.match("^" + prefix);
2321823218
return matches && matches.length > 0 && matches[0] === prefix;
2321923219
};
2322023220

@@ -23232,7 +23232,7 @@ exports.Highcharts = {
2323223232
* @function splunkjs.Utils
2323323233
*/
2323423234
root.endsWith = function(original, suffix) {
23235-
var matches = original.match(suffix + "$");
23235+
let matches = original.match(suffix + "$");
2323623236
return matches && matches.length > 0 && matches[0] === suffix;
2323723237
};
2323823238

@@ -23373,7 +23373,7 @@ exports.Highcharts = {
2337323373
return obj.length === 0;
2337423374
}
2337523375

23376-
for (var key in obj) {
23376+
for (let key in obj) {
2337723377
if (this.hasOwnProperty.call(obj, key)) {
2337823378
return false;
2337923379
}
@@ -23403,14 +23403,14 @@ exports.Highcharts = {
2340323403
obj.forEach(iterator, context);
2340423404
}
2340523405
else if (obj.length === +obj.length) {
23406-
for (var i = 0, l = obj.length; i < l; i++) {
23406+
for (let i = 0, l = obj.length; i < l; i++) {
2340723407
if (i in obj && iterator.call(context, obj[i], i, obj) === {}) {
2340823408
return;
2340923409
}
2341023410
}
2341123411
}
2341223412
else {
23413-
for (var key in obj) {
23413+
for (let key in obj) {
2341423414
if (obj.hasOwnProperty(key)) {
2341523415
if (iterator.call(context, obj[key], key, obj) === {}) {
2341623416
return;
@@ -23437,7 +23437,7 @@ exports.Highcharts = {
2343723437
*/
2343823438
root.extend = function(obj) {
2343923439
root.forEach(Array.prototype.slice.call(arguments, 1), function(source) {
23440-
for (var prop in source) {
23440+
for (let prop in source) {
2344123441
obj[prop] = source[prop];
2344223442
}
2344323443
});
@@ -23499,7 +23499,7 @@ exports.Highcharts = {
2349923499
* @function splunkjs.Utils
2350023500
*/
2350123501
root.keyOf = function(val, obj) {
23502-
for (var k in obj) {
23502+
for (let k in obj) {
2350323503
if (obj.hasOwnProperty(k) && obj[k] === val) {
2350423504
return k;
2350523505
}
@@ -23518,7 +23518,7 @@ exports.Highcharts = {
2351823518
*/
2351923519
root.getWithVersion = function(version, map) {
2352023520
map = map || {};
23521-
var currentVersion = (version + "") || "";
23521+
let currentVersion = (version + "") || "";
2352223522
while (currentVersion !== "") {
2352323523
if (map.hasOwnProperty(currentVersion)) {
2352423524
return map[currentVersion];
@@ -23561,6 +23561,313 @@ exports.Highcharts = {
2356123561
return fs.readFileSync(path.resolve(filename, relativePath)).toString();
2356223562
};
2356323563

23564+
/**
23565+
* can make a function to pause execution for a fixed amount of time
23566+
*
23567+
* @example
23568+
*
23569+
* await Utils.sleep(1000);
23570+
*
23571+
* @param {Number} ms The timeout period, in milliseconds.
23572+
*
23573+
* @function splunkjs.Utils
23574+
*/
23575+
root.sleep = function (ms) {
23576+
return new Promise(resolve => setTimeout(resolve, ms));
23577+
}
23578+
23579+
/**
23580+
* Runs an asynchronous `while` loop.
23581+
*
23582+
* @example
23583+
*
23584+
* let i = 0;
23585+
* try {
23586+
* await Utils.whilst(
23587+
* function() { return i++ < 3; },
23588+
* async function() {
23589+
* await Utils.sleep(0);
23590+
* });
23591+
* } catch(err) {
23592+
* console.log(err);
23593+
* }
23594+
*
23595+
* @param {Function} condition A function that returns a _boolean_ indicating whether the condition has been met.
23596+
* @param {Function} body A function that runs the body of the loop.
23597+
*
23598+
* @function splunkjs.Utils
23599+
*/
23600+
root.whilst = async function(condition, body){
23601+
condition = condition || function() { return false; };
23602+
body = body || function() { return; };
23603+
23604+
let iterationDone = function(err) {
23605+
if (err) {
23606+
throw err;
23607+
}
23608+
else {
23609+
return root.whilst(condition, body);
23610+
}
23611+
};
23612+
23613+
if(condition()){
23614+
return iterationDone(await body())
23615+
}else{
23616+
return null;
23617+
}
23618+
}
23619+
23620+
/**
23621+
* Runs multiple functions (tasks) in parallel.
23622+
* Each task takes the function as a parameter.
23623+
* When all tasks have been completed or if an error occurs, the
23624+
* function returns a combined results of all tasks.
23625+
*
23626+
* **Note**: Tasks might not be run in the same order as they appear in the array,
23627+
* but the results will be returned in that order.
23628+
*
23629+
* @example
23630+
*
23631+
* let [err, one, two] = await Utils.parallel([
23632+
* function() {
23633+
* return [null, 1];
23634+
* },
23635+
* function() {
23636+
* return [null, 2, 3];
23637+
* }]
23638+
* );
23639+
* console.log(err); // == null
23640+
* console.log(one); // == 1
23641+
* console.log(two); // == [1,2]
23642+
*
23643+
* @param {Function} tasks An array of functions.
23644+
* @param {Boolean} fromMap set to true when method call is made from parallerMap function. (optional)
23645+
*
23646+
* @function splunkjs.Utils
23647+
*/
23648+
root.parallel = async function (tasks, fromMap) {
23649+
let res = [];
23650+
if(!root.isArray(tasks) && root.isFunction(fromMap)){
23651+
let taskList = [];
23652+
Object.keys(arguments).forEach(key => {
23653+
taskList.push(arguments[key]);
23654+
});
23655+
tasks = taskList;
23656+
fromMap = false;
23657+
}
23658+
for(let task of tasks) {
23659+
let result = task();
23660+
res.push(result);
23661+
}
23662+
let result = await Promise.all(res);
23663+
let response = [];
23664+
for(let resp of result){
23665+
if(resp){
23666+
if(resp[0]){
23667+
return [resp[0], null];
23668+
}
23669+
if(resp.length > 2){
23670+
response.push(resp.slice(1));
23671+
}else{
23672+
response.push(resp[1]);
23673+
}
23674+
}
23675+
}
23676+
return fromMap ? [null, response] : [null, ...response];
23677+
}
23678+
23679+
/**
23680+
* Runs an asynchronous function (mapping it) over each element in an array, in parallel.
23681+
* When all tasks have been completed or if an error occurs, function
23682+
* returns the resulting array.
23683+
*
23684+
* @example
23685+
*
23686+
* let [err, vals] = await Utils.parallelMap(
23687+
* [1, 2, 3],
23688+
* async function(val, idx) {
23689+
* if (val === 2) {
23690+
* await Utils.sleep(100);
23691+
* return [null, val+1];
23692+
* }
23693+
* else {
23694+
* return [null, val + 1];
23695+
* }
23696+
* });
23697+
* console.log(vals); // == [2,3,4]
23698+
*
23699+
* @param {Array} vals An array of values.
23700+
* @param {Function} fn A function (possibly asynchronous) to apply to each element.
23701+
*
23702+
* @function splunkjs.Utils
23703+
*/
23704+
root.parallelMap = async function (vals, fn) {
23705+
vals = vals || [];
23706+
let tasks = [];
23707+
let createTask = function(val, idx) {
23708+
return function() { return fn(val, idx); };
23709+
};
23710+
23711+
for(let i = 0; i < vals.length; i++) {
23712+
tasks.push(createTask(vals[i], i));
23713+
}
23714+
return await root.parallel(tasks, true);
23715+
}
23716+
23717+
/**
23718+
* Applies an asynchronous function over each element in an array, in parallel.
23719+
* If an error occurs, the function returns an error.
23720+
*
23721+
* @example
23722+
*
23723+
* var total = 0;
23724+
* let err = await Utils.parallelEach(
23725+
* [1, 2, 3],
23726+
* async function(val, idx) {
23727+
* var go = function() {
23728+
* total += val;
23729+
* };
23730+
*
23731+
* if (idx === 1) {
23732+
* await Utils.sleep(100);
23733+
* go();
23734+
* }
23735+
* else {
23736+
* go();
23737+
* }
23738+
* });
23739+
* console.log(total); // == 6
23740+
*
23741+
* @param {Array} vals An array of values.
23742+
* @param {Function} fn A function (possibly asynchronous) to apply to each element.
23743+
*
23744+
* @function splunkjs.Utils
23745+
*/
23746+
root.parallelEach = async function (vals, fn) {
23747+
vals = vals || [];
23748+
let [err,res] = await root.parallelMap(vals, fn);
23749+
return err || null;
23750+
};
23751+
23752+
/**
23753+
* Runs multiple functions (tasks) in series.
23754+
* Each task takes the function as a parameter.
23755+
* When all tasks have been completed or if an error occurs, the
23756+
* function returns the combined results of all tasks in the order
23757+
* they were run.
23758+
*
23759+
* @example
23760+
*
23761+
* var keeper = 0;
23762+
* let [err, one, two] = awiat Utils.series([
23763+
* async function() {
23764+
* await Utils.sleep(10);
23765+
* console.log(keeper++); // == 0
23766+
* return [null, 1];
23767+
* },
23768+
* function() {
23769+
* console.log(keeper++); // == 1
23770+
* return [null, 2, 3];
23771+
* }]
23772+
* );
23773+
* console.log(err); // == null
23774+
* console.log(one); // == 1
23775+
* console.log(two); // == [2, 3]
23776+
*
23777+
* @param {Function} tasks An array of functions.
23778+
* @param {Boolean} fromMap set to true when method call is made from seriesMap function. (optional)
23779+
*
23780+
* @function splunkjs.Utils
23781+
*/
23782+
root.series = async function (tasks, fromMap) {
23783+
let res = [];
23784+
if(!root.isArray(tasks)&& root.isFunction(fromMap)){
23785+
let taskList = [];
23786+
Object.keys(arguments).forEach(key => {
23787+
taskList.push(arguments[key]);
23788+
});
23789+
tasks = taskList;
23790+
fromMap = false;
23791+
}
23792+
for(let task of tasks) {
23793+
let result = await task();
23794+
if(result){
23795+
if(result[0]){
23796+
return [result[0], null];
23797+
}
23798+
if(result.length > 2){
23799+
res.push(result.slice(1));
23800+
}else{
23801+
res.push(result[1]);
23802+
}
23803+
}
23804+
}
23805+
return fromMap ? [null, res] : [null, ...res];
23806+
}
23807+
23808+
/**
23809+
* Runs an asynchronous function (mapping it) over each element in an array, in series.
23810+
* When all tasks have been completed or if an error occurs, function
23811+
* returns the resulting array.
23812+
*
23813+
* @example
23814+
*
23815+
* var keeper = 1;
23816+
* let [err, vals] = await Utils.seriesMap(
23817+
* [1, 2, 3],
23818+
* function(val, idx) {
23819+
* console.log(keeper++); // == 1, then 2, then 3
23820+
* return [null, val + 1];
23821+
* }
23822+
* );
23823+
* console.log(vals); // == [2,3,4];
23824+
*
23825+
* @param {Array} vals An array of values.
23826+
* @param {Function} fn A function (possibly asynchronous) to apply to each element.
23827+
*
23828+
* @function splunkjs.Utils
23829+
*/
23830+
root.seriesMap = async function (vals, fn) {
23831+
vals = vals || [];
23832+
let tasks = [];
23833+
let createTask = function(val, idx) {
23834+
return function() {
23835+
return fn(val, idx);
23836+
};
23837+
};
23838+
for(let i = 0; i < vals.length; i++) {
23839+
tasks.push(createTask(vals[i], i));
23840+
}
23841+
return await root.series(tasks, true);
23842+
}
23843+
23844+
/**
23845+
* Applies an asynchronous function over each element in an array, in series.
23846+
* If an error occurs, the function returns an error.
23847+
*
23848+
* @example
23849+
*
23850+
* var results = [1, 3, 6];
23851+
* var total = 0;
23852+
* let err = await Utils.seriesEach(
23853+
* [1, 2, 3],
23854+
* function(val, idx) {
23855+
* total += val;
23856+
* console.log(total === results[idx]); //== true
23857+
* });
23858+
* console.log(total); //== 6
23859+
*
23860+
* @param {Array} vals An array of values.
23861+
* @param {Function} fn A function (possibly asynchronous)to apply to each element.
23862+
*
23863+
* @function splunkjs.Utils
23864+
*/
23865+
root.seriesEach = async function (vals, fn) {
23866+
vals = vals || [];
23867+
let [err,res] = await root.seriesMap(vals, fn);
23868+
return err || null;
23869+
};
23870+
2356423871
})();
2356523872
},{"fs":12,"path":13}],12:[function(require,module,exports){
2356623873

client/splunk.ui.charting.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)