I found the solution around the time you guys were posting. I put a function node in at the start of my flow with the following text in it and it works perfectly.
To call the functions I need the following in every node I want to use my fuctions in.
var Func = flow.get('Func');
To call the functions I now need to use the Func. prefix so GrantAccess becomes Func.GrantAccess
Func = {
GrantAccess : function (haystack, arr) {
return arr.some(function (v) {
return haystack.indexOf(v) >= 0;
})},
pad : function (num, size) {
var s = num+"";
while (s.length < size) s = "0" + s;
return s;
},
DaysBetween : function (date1, date2) {
var one_day=1000*60*60*24;
var date1_ms = date1.getTime();
var date2_ms = date2.getTime();
var difference_ms = date2_ms - date1_ms;
difference_ms = Math.round(difference_ms/1000,3);
var mseconds = difference_ms % 1000;
var seconds = Math.floor(difference_ms % 60);
difference_ms = difference_ms/60;
var minutes = Math.floor(difference_ms % 60);
difference_ms = difference_ms/60;
var hours = Math.floor(difference_ms % 24);
var days = Math.floor(difference_ms/24);
return Func.pad(minutes,2) + ':' + Func.pad(seconds,2) + '.' + Func.pad(mseconds,3);
},
GetPriority : function (priority) {
var PriorityTable = { 64:"Low",
16384:"Below Normal",
32:"Normal",
32768:"Above Normal",
128:"High",
256:"Realtime"
};
return (PriorityTable[priority])
}
}
flow.set('Func', Func);
node.status({fill:"green",shape:"dot",text:"Functions Loaded"});