Sha256: 49e8a7d9fed9dd8bdeb4683312dc222233f464747720bfad005d87821f938db7
Contents?: true
Size: 1.77 KB
Versions: 31
Compression:
Stored size: 1.77 KB
Contents
/* */ 'use strict'; var $ = require('./$'), global = require('./$.global'), has = require('./$.has'), cof = require('./$.cof'), isObject = require('./$.is-object'), fails = require('./$.fails'), NUMBER = 'Number', $Number = global[NUMBER], Base = $Number, proto = $Number.prototype, BROKEN_COF = cof($.create(proto)) == NUMBER; var toPrimitive = function(it) { var fn, val; if (typeof(fn = it.valueOf) == 'function' && !isObject(val = fn.call(it))) return val; if (typeof(fn = it.toString) == 'function' && !isObject(val = fn.call(it))) return val; throw TypeError("Can't convert object to number"); }; var toNumber = function(it) { if (isObject(it)) it = toPrimitive(it); if (typeof it == 'string' && it.length > 2 && it.charCodeAt(0) == 48) { var binary = false; switch (it.charCodeAt(1)) { case 66: case 98: binary = true; case 79: case 111: return parseInt(it.slice(2), binary ? 2 : 8); } } return +it; }; if (!($Number('0o1') && $Number('0b1'))) { $Number = function Number(it) { var that = this; return that instanceof $Number && (BROKEN_COF ? fails(function() { proto.valueOf.call(that); }) : cof(that) != NUMBER) ? new Base(toNumber(it)) : toNumber(it); }; $.each.call(require('./$.support-desc') ? $.getNames(Base) : ('MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY,' + 'EPSILON,isFinite,isInteger,isNaN,isSafeInteger,MAX_SAFE_INTEGER,' + 'MIN_SAFE_INTEGER,parseFloat,parseInt,isInteger').split(','), function(key) { if (has(Base, key) && !has($Number, key)) { $.setDesc($Number, key, $.getDesc(Base, key)); } }); $Number.prototype = proto; proto.constructor = $Number; require('./$.redef')(global, NUMBER, $Number); }
Version data entries
31 entries across 31 versions & 1 rubygems