MCPcopy Create free account
hub / github.com/OpenEndedGroup/Field2 / toNumber

Function toNumber

lib/web/polyfill.js:783–792  ·  view source on GitHub ↗
(it)

Source from the content-addressed store, hash-verified

781
782Number('0o1') && Number('0b1') || function(_Number, NumberProto){
783 function toNumber(it){
784 if(isObject(it))it = toPrimitive(it);
785 if(typeof it == 'string' && it.length > 2 && it.charCodeAt(0) == 48){
786 var binary = false;
787 switch(it.charCodeAt(1)){
788 case 66 : case 98 : binary = true;
789 case 79 : case 111 : return parseInt(it.slice(2), binary ? 2 : 8);
790 }
791 } return +it;
792 }
793 function toPrimitive(it){
794 var fn, val;
795 if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;

Callers 1

polyfill.jsFile · 0.85

Calls 3

toPrimitiveFunction · 0.85
parseIntFunction · 0.85
isObjectFunction · 0.70

Tested by

no test coverage detected