why does the local function turn on when node red can't be injected ??
(function(window) {
var methods = {},
init;
methods.ambil = function(simpenstr, opsi) {
var ambil = {
Type: undefined,
Length: undefined,
Value: undefined,
Parsing: undefined
};
ambil.Type = simpenstr.substring(0, opsi.panjangambil);
ambil.Type = String(parseInt(ambil.Type, 16).toString(2));
kurang = String(parseInt(ambil.Type, 16).toString(2));
aku = parseInt(ambil.Type, 16).toString(2);
ambil.Type = ambil.Type.slice(0, -(opsi.panjangambil));
simpenstr = simpenstr.substring(opsi.panjangambil);
if (ambil.Length = kurang.toString().slice(-2) == "00"){
ambil.Length = "01"
}else if (ambil.Length = kurang.toString().slice(-2) == "0"){
ambil.Length = "01"
}else if (ambil.Length = kurang.toString().slice(-2) == "11"){
ambil.Length = "110"
}else if (ambil.Length = kurang.toString().slice(-2) == "01"){
ambil.Length = "10"
}else if (ambil.Length = kurang.toString().slice(-2) == "1"){
ambil.Length = "10"
}else {
ambil.Length = "100"
};
desimal = (parseInt(ambil.Length, 2).toString(16).toUpperCase
());
ambil.Value = String(simpenstr).substr(0, desimal * 2).toString();
ambil.Parsing = parseInt(ambil.Value, 16);
simpenstr = simpenstr.substring(desimal * 2);
return {
tag: ambil,
retStr: simpenstr
};
};
methods.parserdata = function(tlv, keluaranArray, opsi) {
while (tlv) {
var res = methods.ambil(tlv, opsi);
keluaranArray.push(res.tag);
tlv = res.retStr;
}
return keluaranArray;
};
init = methods;
var parser = init;
})("undefined" !== typeof window ? window : {});
var tlv = '08000ce440242a00012116450e1012000186a0' ;
var opsi = {
panjangambil: 2
};
var keluaran = [ ];
// console.log(parser.parserdata(tlv, keluaran, opsi));
var oke = global.set('parser');
tee = (parser.parserdata(tlv, keluaran, opsi)).slice(-1);
msg.payload = tee;
return msg;