MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / _decode

Method _decode

modules/crypt/etc/ber.js:348–366  ·  view source on GitHub ↗
(b)

Source from the content-addressed store, hash-verified

346 return this._decode(new BER(a));
347 }
348 static _decode(b) {
349 let tag = b.getTag();
350 if (tag == 0) {
351 // must be 00 terminator
352 if (b.getc() != 0)
353 throw new Error();
354 return null;
355 }
356 if ((tag & 0x1f) == 0x1f) {
357 // extended tag -- just ignore
358 while (b.getc() >= 0x80)
359 ;
360 }
361 let res = this.decodeTag(tag, b, b.getLength());
362 if (!(res instanceof Array))
363 res = [res];
364 res.unshift(tag);
365 return res;
366 }
367 static decodeTag(tag, b, len) {
368 let res;
369 if ((tag >> 6) == 2) { // context specific class

Callers 2

decodeMethod · 0.95
decodeTagMethod · 0.95

Calls 4

decodeTagMethod · 0.95
getTagMethod · 0.80
getcMethod · 0.80
getLengthMethod · 0.80

Tested by

no test coverage detected