Skip to content

Commit

Permalink
0.5.3
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Feb 14, 2015
1 parent 2d26808 commit 721d890
Show file tree
Hide file tree
Showing 17 changed files with 203 additions and 64 deletions.
12 changes: 11 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ String
#trim() -> str
Date
.now() -> int
#toISOString() -> string
```
### ECMAScript 6
Expand Down Expand Up @@ -202,6 +203,11 @@ RegExp(/./g, 'm'); // => /./m
/foo/gim.flags; // => 'gim'
```
#### ECMAScript 6: Number & Math
Module `es6.number.constructor`. `Number` constructor support binary and octal literals, [example](http://goo.gl/jRd6b3):
```javascript
Number('0b1010101'); // => 85
Number('0o7654321'); // => 2054353
```
Modules `es6.number` and `es6.math`.
```javascript
Number
Expand Down Expand Up @@ -1321,7 +1327,7 @@ Where `core.date` and `web.console` are module names, `library` is flag for buil
* `shim.old` is equal `es5,web.timers,web.console`
* `shim.modern` is equal `es6,es7,js.array.statics,web.immediate,web.dom.itarable`
* `web` is equal `web.timers,web.console,web.immediate,web.dom.itarable`
* `es6` is equal `es6.object,es6.object.statics-accept-primitives,es6.function,es6.number,es6.math,es6.string,es6.array,es6.iterators,es6.regexp,es6.collections,es6.promise,es6.symbol,es6.reflect`
* `es6` is equal `es6.object,es6.object.statics-accept-primitives,es6.function,es6.number.constructor,es6.number,es6.math,es6.string,es6.array,es6.iterators,es6.regexp,es6.collections,es6.promise,es6.symbol,es6.reflect`
* `es7` is equal `es7.proposals,es7.abstract-refs`
* `core` is equal `core.global,core.$for,core.delay,core.dict,core.binding,core.array,core.object,core.number,core.string,core.date,core.log`
Expand All @@ -1334,6 +1340,10 @@ Where `core.date` and `web.console` are module names, `library` is flag for buil
* `core-js/client/library` builds as `shim,core,library`
## Changelog
**0.5.3** - *2015.02.14*
* added [support binary and octal literals](#ecmascript-6-number--math) to `Number` constructor
* added [`Date#toISOString`](#ecmascript-5)
**0.5.2** - *2015.02.10* - Some fixes
**0.5.1** - *2015.02.09* - Some fixes
Expand Down
2 changes: 1 addition & 1 deletion bower.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "core.js",
"main": "client/core.js",
"version": "0.5.2",
"version": "0.5.3",
"description": "Standard Library",
"keywords": [
"ES6",
Expand Down
35 changes: 34 additions & 1 deletion client/core.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Core.js 0.5.2
* Core.js 0.5.3
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2015 Denis Pushkarev
Expand Down Expand Up @@ -977,6 +977,39 @@ if(exportGlobal || framework){
});
}('name');

/******************************************************************************
* Module : es6.number.constructor *
******************************************************************************/

Number('0o1') && Number('0b1') || function(_Number, NumberProto){
function toNumber(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;
}
function toPrimitive(it){
var fn, val;
if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
if(isFunction(fn = it[TO_STRING]) && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to number");
}
Number = function Number(it){
return this instanceof Number ? new _Number(toNumber(it)) : toNumber(it);
}
forEach.call(DESC ? getNames(_Number)
: array('MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY'), function(key){
key in Number || defineProperty(Number, key, getOwnDescriptor(_Number, key));
});
Number[PROTOTYPE] = NumberProto;
NumberProto[CONSTRUCTOR] = Number;
hidden(global, NUMBER, Number);
}(Number, Number[PROTOTYPE]);

/******************************************************************************
* Module : es6.number *
******************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions client/core.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/core.min.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/library.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Core.js 0.5.2
* Core.js 0.5.3
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2015 Denis Pushkarev
Expand Down
2 changes: 1 addition & 1 deletion client/library.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

35 changes: 34 additions & 1 deletion client/shim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Core.js 0.5.2
* Core.js 0.5.3
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2015 Denis Pushkarev
Expand Down Expand Up @@ -977,6 +977,39 @@ if(exportGlobal || framework){
});
}('name');

/******************************************************************************
* Module : es6.number.constructor *
******************************************************************************/

Number('0o1') && Number('0b1') || function(_Number, NumberProto){
function toNumber(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;
}
function toPrimitive(it){
var fn, val;
if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
if(isFunction(fn = it[TO_STRING]) && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to number");
}
Number = function Number(it){
return this instanceof Number ? new _Number(toNumber(it)) : toNumber(it);
}
forEach.call(DESC ? getNames(_Number)
: array('MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY'), function(key){
key in Number || defineProperty(Number, key, getOwnDescriptor(_Number, key));
});
Number[PROTOTYPE] = NumberProto;
NumberProto[CONSTRUCTOR] = Number;
hidden(global, NUMBER, Number);
}(Number, Number[PROTOTYPE]);

/******************************************************************************
* Module : es6.number *
******************************************************************************/
Expand Down
4 changes: 2 additions & 2 deletions client/shim.min.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion client/shim.min.js.map

Large diffs are not rendered by default.

35 changes: 34 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Core.js 0.5.2
* Core.js 0.5.3
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2015 Denis Pushkarev
Expand Down Expand Up @@ -747,6 +747,39 @@ if(exportGlobal || framework){
});
}('name');

/******************************************************************************
* Module : es6.number.constructor *
******************************************************************************/

Number('0o1') && Number('0b1') || function(_Number, NumberProto){
function toNumber(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;
}
function toPrimitive(it){
var fn, val;
if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
if(isFunction(fn = it[TO_STRING]) && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to number");
}
Number = function Number(it){
return this instanceof Number ? new _Number(toNumber(it)) : toNumber(it);
}
forEach.call(DESC ? getNames(_Number)
: array('MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY'), function(key){
key in Number || defineProperty(Number, key, getOwnDescriptor(_Number, key));
});
Number[PROTOTYPE] = NumberProto;
NumberProto[CONSTRUCTOR] = Number;
hidden(global, NUMBER, Number);
}(Number, Number[PROTOTYPE]);

/******************************************************************************
* Module : es6.number *
******************************************************************************/
Expand Down
2 changes: 1 addition & 1 deletion library.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Core.js 0.5.2
* Core.js 0.5.3
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2015 Denis Pushkarev
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "core-js",
"description": "Standard library",
"version": "0.5.2",
"version": "0.5.3",
"repository": {
"type": "git",
"url": "https://github.com/zloirock/core-js.git"
Expand Down
35 changes: 34 additions & 1 deletion shim.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/**
* Core.js 0.5.2
* Core.js 0.5.3
* https://github.com/zloirock/core-js
* License: http://rock.mit-license.org
* © 2015 Denis Pushkarev
Expand Down Expand Up @@ -747,6 +747,39 @@ if(exportGlobal || framework){
});
}('name');

/******************************************************************************
* Module : es6.number.constructor *
******************************************************************************/

Number('0o1') && Number('0b1') || function(_Number, NumberProto){
function toNumber(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;
}
function toPrimitive(it){
var fn, val;
if(isFunction(fn = it.valueOf) && !isObject(val = fn.call(it)))return val;
if(isFunction(fn = it[TO_STRING]) && !isObject(val = fn.call(it)))return val;
throw TypeError("Can't convert object to number");
}
Number = function Number(it){
return this instanceof Number ? new _Number(toNumber(it)) : toNumber(it);
}
forEach.call(DESC ? getNames(_Number)
: array('MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY'), function(key){
key in Number || defineProperty(Number, key, getOwnDescriptor(_Number, key));
});
Number[PROTOTYPE] = NumberProto;
NumberProto[CONSTRUCTOR] = Number;
hidden(global, NUMBER, Number);
}(Number, Number[PROTOTYPE]);

/******************************************************************************
* Module : es6.number *
******************************************************************************/
Expand Down
5 changes: 3 additions & 2 deletions src/es6.number.constructor.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if(DESC && !(Number('0o1') && Number('0b1')))!function(_Number, NumberProto){
Number('0o1') && Number('0b1') || function(_Number, NumberProto){
function toNumber(it){
if(isObject(it))it = toPrimitive(it);
if(typeof it == 'string' && it.length > 2 && it.charCodeAt(0) == 48){
Expand All @@ -18,7 +18,8 @@ if(DESC && !(Number('0o1') && Number('0b1')))!function(_Number, NumberProto){
Number = function Number(it){
return this instanceof Number ? new _Number(toNumber(it)) : toNumber(it);
}
forEach.call(getNames(_Number), function(key){
forEach.call(DESC ? getNames(_Number)
: array('MAX_VALUE,MIN_VALUE,NaN,NEGATIVE_INFINITY,POSITIVE_INFINITY'), function(key){
key in Number || defineProperty(Number, key, getOwnDescriptor(_Number, key));
});
Number[PROTOTYPE] = NumberProto;
Expand Down
62 changes: 30 additions & 32 deletions tests/tests.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

26 changes: 12 additions & 14 deletions tests/tests/es6.number.constructor.ls
Original file line number Diff line number Diff line change
Expand Up @@ -60,18 +60,16 @@ test 'regression' !->
for <[MAX_VALUE MIN_VALUE NaN NEGATIVE_INFINITY POSITIVE_INFINITY]>
ok .. of Number, "#{..} in Number"

# vvv check it for test Number constructor with octal and binary
if /\[native code\]\s*\}\s*$/.test Object.defineProperty
test \binary !->
check \0b1, 1
check \0B1, 1
check \0b234, NaN
check {valueOf: -> \0b11}, 3
check {toString: -> \0b111}, 7
test \binary !->
check \0b1, 1
check \0B1, 1
check \0b234, NaN
check {valueOf: -> \0b11}, 3
check {toString: -> \0b111}, 7

test \octal !->
check \0o7, 7
check \0O7, 7
check \0o89a, NaN
check {valueOf: -> \0o77}, 63
check {toString: -> \0o777}, 511
test \octal !->
check \0o7, 7
check \0O7, 7
check \0o89a, NaN
check {valueOf: -> \0o77}, 63
check {toString: -> \0o777}, 511

0 comments on commit 721d890

Please sign in to comment.