Function node red error

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;

Small suggestion - as it is going to be said at some time.

Start again and when you are about to enter the code from the function node, prefix it with 3 ` symbols.
That is the key usually just to the left of the 1 key.
Paste the code, press and put another 3 of that symbol.

That will format the code correctly so people can read it better.

thanks for the advice.
I have confirmed my code

I am sorry that question does not make sense.
If your function node is not returning the correct data then you can usenode.warn() to display values from the function in the debug window so you can work out what is not performing as you expect. See Writing Functions : Node-RED for how to do this and for other useful information about writing functions.