UNPKG

wonder.js

Version:
63 lines (56 loc) 2.25 kB
'use strict'; var List = require("bs-platform/lib/js/list.js"); var Pervasives = require("bs-platform/lib/js/pervasives.js"); var Log$WonderLog = require("wonder-log/lib/js/src/Log.js"); function handleGetNoneNoWorkerJob(name, list) { Log$WonderLog.warn("job:" + (String(name) + " is none")); return list; } function handleGetNoneWorkerJob(name, jobHandleMap) { return Log$WonderLog.fatal(Log$WonderLog.buildFatalMessage("get no job", "can\'t find job handle function whose job name is " + (String(name) + ""), "", "make sure that the job name defined in config record be correctly", "jobHandleMap:" + (Log$WonderLog.getJsonStr(jobHandleMap) + ("\nname: " + (String(name) + ""))))); } function addJob(param, jobList) { var targetHandleFunc = param[3]; var targetJobName = param[0]; if (param[2]) { var afterJobName = param[1]; return List.fold_left((function (list, jobItem) { var match = jobItem[0] === afterJobName; if (match) { return Pervasives.$at(list, /* :: */[ jobItem, /* :: */[ /* tuple */[ targetJobName, targetHandleFunc ], /* [] */0 ] ]); } else { return Pervasives.$at(list, /* :: */[ jobItem, /* [] */0 ]); } }), /* [] */0, jobList); } else { return /* :: */[ /* tuple */[ targetJobName, targetHandleFunc ], jobList ]; } } function removeJob(targetJobName, jobList) { return List.filter((function (param) { return param[0] !== targetJobName; }))(jobList); } exports.handleGetNoneNoWorkerJob = handleGetNoneNoWorkerJob; exports.handleGetNoneWorkerJob = handleGetNoneWorkerJob; exports.addJob = addJob; exports.removeJob = removeJob; /* Log-WonderLog Not a pure module */