MCPcopy Index your code
hub / github.com/vercel/hyper / constructYamlInteger

Function constructYamlInteger

bin/yarn-standalone.js:65276–65317  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

65274}
65275
65276function constructYamlInteger(data) {
65277 var value = data, sign = 1, ch, base, digits = [];
65278
65279 if (value.indexOf('_') !== -1) {
65280 value = value.replace(/_/g, '');
65281 }
65282
65283 ch = value[0];
65284
65285 if (ch === '-' || ch === '+') {
65286 if (ch === '-') sign = -1;
65287 value = value.slice(1);
65288 ch = value[0];
65289 }
65290
65291 if (value === '0') return 0;
65292
65293 if (ch === '0') {
65294 if (value[1] === 'b') return sign * parseInt(value.slice(2), 2);
65295 if (value[1] === 'x') return sign * parseInt(value, 16);
65296 return sign * parseInt(value, 8);
65297 }
65298
65299 if (value.indexOf(':') !== -1) {
65300 value.split(':').forEach(function (v) {
65301 digits.unshift(parseInt(v, 10));
65302 });
65303
65304 value = 0;
65305 base = 1;
65306
65307 digits.forEach(function (d) {
65308 value += (d * base);
65309 base *= 60;
65310 });
65311
65312 return sign * value;
65313
65314 }
65315
65316 return sign * parseInt(value, 10);
65317}
65318
65319function isInteger(object) {
65320 return (Object.prototype.toString.call(object)) === '[object Number]' &&

Callers

nothing calls this directly

Calls 3

parseIntFunction · 0.85
indexOfMethod · 0.80
forEachMethod · 0.45

Tested by

no test coverage detected