add v0.1.0~0.16.0 of es6-shim, except 0.11.0

This commit is contained in:
Peter Dave Hello
2014-08-22 02:19:27 +08:00
parent e076cef9c5
commit 93e5fdfe61
62 changed files with 26042 additions and 1 deletions
+236
View File
@@ -0,0 +1,236 @@
(function(definition) {
// RequireJS.
if (typeof define === 'function') {
define(definition);
// CommonJS and <script>.
} else {
definition();
}
})(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isNaN = globall.isNaN;
var global_isFinite = globall.isFinite;
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
var sign = function(n) {
return (n < 0) ? -1 : 1;
};
var unique = function(iterable) {
return Array.from(Set.from(iterable));
};
// http://wiki.ecmascript.org/doku.php?id=harmony:string.prototype.repeat
// http://wiki.ecmascript.org/doku.php?id=harmony:string_extras
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.indexOf(substring) === 0;
},
endsWith: function(s) {
var t = String(s);
return this.lastIndexOf(t) === this.length - t.length;
},
contains: function(s) {
return this.indexOf(s) !== -1;
},
toArray: function() {
return this.split('');
}
});
// https://gist.github.com/1074126
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isInteger: function(value) {
return typeof value === 'number' && global_isFinite(value) &&
value > -9007199254740992 && value < 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return typeof value === 'number' && global_isNaN(value);
},
toInteger: function(value) {
var n = +value;
if (isNaN(n)) return +0;
if (n === 0 || !global_isFinite(n)) return n;
return sign(n) * Math.floor(Math.abs(n));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var set = Set.from(Object.getOwnPropertyNames(subject));
var proto = Object.getPrototypeOf(subject);
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(set.add);
proto = Object.getPrototypeOf(proto);
}
return Array.from(set);
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
return x !== 0 || 1 / x === 1 / y;
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
// TODO: iteration.
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map.delete(key);
}
});
return Set;
// TODO: iteration.
})()
});
defineProperties(globall.Set, {
from: function(iterable) {
var object = Object(iterable);
var set = Set();
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object && !(set.has(key))) {
set.add(object[key]);
}
}
return set;
},
of: function() {
return Set.from(arguments);
}
});
});
+1
View File
@@ -0,0 +1 @@
!function(t){"function"==typeof define?define(t):t()}(function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isNaN,n=t.isFinite,r=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},o=function(t,e){Object.keys(e).forEach(function(n){r(t,n,e[n])})},i=function(t){return 0>t?-1:1};o(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.indexOf(t)},endsWith:function(t){var e=String(t);return this.lastIndexOf(e)===this.length-e.length},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),o(Array,{from:function(t){for(var e=Object(t),n=[],r=0,o=e.length>>>0;o>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),o(Number,{isInteger:function(t){return"number"==typeof t&&n(t)&&t>-9007199254740992&&9007199254740992>t&&Math.floor(t)===t},isNaN:function(t){return"number"==typeof t&&e(t)},toInteger:function(t){var e=+t;return isNaN(e)?0:0!==e&&n(e)?i(e)*Math.floor(Math.abs(e)):e}}),o(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Set.from(Object.getOwnPropertyNames(t)),n=Object.getPrototypeOf(t);null!==n;)Object.getOwnPropertyNames(n).forEach(e.add),n=Object.getPrototypeOf(n);return Array.from(e)},is:function(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e}}),o(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return o(t.prototype,{get:function(t){var n=e(this.keys,t);return 0>n?void 0:this.values[n]},has:function(t){return e(this.keys,t)>=0},set:function(t,n){var r=this.keys,o=this.values,i=e(r,t);0>i&&(i=r.length),r[i]=t,o[i]=n},"delete":function(t){var n=this.keys,r=this.values,o=e(n,t);return 0>o?!1:(n.splice(o,1),r.splice(o,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return o(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map.delete(t)}}),t}()}),o(t.Set,{from:function(t){for(var e=Object(t),n=Set(),r=0,o=e.length>>>0;o>r;r++)r in e&&!n.has(r)&&n.add(e[r]);return n},of:function(){return Set.from(arguments)}})});
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+244
View File
@@ -0,0 +1,244 @@
(function(definition) {
// RequireJS.
if (typeof define === 'function') {
define(definition);
// CommonJS and <script>.
} else {
definition();
}
})(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isNaN = globall.isNaN;
var global_isFinite = globall.isFinite;
var unique = function(array) {
var result = [];
var item;
for (var i = 0, length = array.length; i < length; i++) {
item = array[i];
if (result.indexOf(item) === -1) {
result.push(item);
}
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.indexOf(substring) === 0;
},
endsWith: function(s) {
var t = String(s);
return this.lastIndexOf(t) === this.length - t.length;
},
contains: function(s) {
return this.indexOf(s) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isInteger: function(value) {
return typeof value === 'number' && global_isFinite(value) &&
value > -9007199254740992 && value < 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return typeof value === 'number' && global_isNaN(value);
},
toInteger: function(value) {
var n = +value;
if (isNaN(n)) return +0;
if (n === 0 || !global_isFinite(n)) return n;
return Math.sign(n) * Math.floor(Math.abs(n));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
while (proto !== null) {
result = result.concat(Object.getOwnPropertyNames(proto));
proto = Object.getPrototypeOf(proto);
}
return unique(result);
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
return x !== 0 || 1 / x === 1 / y;
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
}
});
defineProperties(Math, {
sign: function(value) {
var number = +value;
if (global_isNaN(number) || number === 0) return number;
return (number < 0) ? -1 : 1;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map.delete(key);
}
});
return Set;
})()
});
/*defineProperties(globall.Set, {
of: function(iterable) {
var object = Object(iterable);
var set = Set();
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object && !(set.has(key))) {
set.add(object[key]);
}
}
return set;
}
});*/
});
+1
View File
@@ -0,0 +1 @@
!function(t){"function"==typeof define?define(t):t()}(function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isNaN,n=t.isFinite,r=function(t){for(var e,n=[],r=0,i=t.length;i>r;r++)e=t[r],-1===n.indexOf(e)&&n.push(e);return n},i=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},o=function(t,e){Object.keys(e).forEach(function(n){i(t,n,e[n])})};o(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.indexOf(t)},endsWith:function(t){var e=String(t);return this.lastIndexOf(e)===this.length-e.length},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),o(Array,{from:function(t){for(var e=Object(t),n=[],r=0,i=e.length>>>0;i>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),o(Number,{isInteger:function(t){return"number"==typeof t&&n(t)&&t>-9007199254740992&&9007199254740992>t&&Math.floor(t)===t},isNaN:function(t){return"number"==typeof t&&e(t)},toInteger:function(t){var e=+t;return isNaN(e)?0:0!==e&&n(e)?Math.sign(e)*Math.floor(Math.abs(e)):e}}),o(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Object.getOwnPropertyNames(t),n=Object.getPrototypeOf(t);null!==n;)e=e.concat(Object.getOwnPropertyNames(n)),n=Object.getPrototypeOf(n);return r(e)},is:function(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e}}),o(Math,{sign:function(t){var n=+t;return e(n)||0===n?n:0>n?-1:1}}),o(t,{Map:function(){function t(){return this instanceof t?(i(this,"keys",[]),void i(this,"values",[])):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return o(t.prototype,{get:function(t){var n=e(this.keys,t);return 0>n?void 0:this.values[n]},has:function(t){return e(this.keys,t)>=0},set:function(t,n){var r=this.keys,i=this.values,o=e(r,t);0>o&&(o=r.length),r[o]=t,i[o]=n},"delete":function(t){var n=this.keys,r=this.values,i=e(n,t);return 0>i?!1:(n.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void i(this,"map",Map()):new t}return o(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map.delete(t)}}),t}()})});
+232
View File
@@ -0,0 +1,232 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isNaN = globall.isNaN;
var global_isFinite = globall.isFinite;
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.indexOf(substring) === 0;
},
endsWith: function(s) {
var t = String(s);
var index = this.lastIndexOf(t)
return index >= 0 && index === this.length - t.length;
},
contains: function(s) {
return this.indexOf(s) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isInteger: function(value) {
return typeof value === 'number' && global_isFinite(value) &&
value > -9007199254740992 && value < 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return typeof value === 'number' && global_isNaN(value);
},
toInteger: function(value) {
var n = +value;
if (isNaN(n)) return +0;
if (n === 0 || !global_isFinite(n)) return n;
return Math.sign(n) * Math.floor(Math.abs(n));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
return x !== 0 || 1 / x === 1 / y;
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
}
});
defineProperties(Math, {
sign: function(value) {
var number = +value;
if (global_isNaN(number) || number === 0) return number;
return (number < 0) ? -1 : 1;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map.delete(key);
}
});
return Set;
})()
});
/*defineProperties(globall.Set, {
of: function(iterable) {
var object = Object(iterable);
var set = Set();
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object && !(set.has(key))) {
set.add(object[key]);
}
}
return set;
}
});*/
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isNaN,n=t.isFinite,r=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},i=function(t,e){Object.keys(e).forEach(function(n){r(t,n,e[n])})};i(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.indexOf(t)},endsWith:function(t){var e=String(t),n=this.lastIndexOf(e);return n>=0&&n===this.length-e.length},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),i(Array,{from:function(t){for(var e=Object(t),n=[],r=0,i=e.length>>>0;i>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{isInteger:function(t){return"number"==typeof t&&n(t)&&t>-9007199254740992&&9007199254740992>t&&Math.floor(t)===t},isNaN:function(t){return"number"==typeof t&&e(t)},toInteger:function(t){var e=+t;return isNaN(e)?0:0!==e&&n(e)?Math.sign(e)*Math.floor(Math.abs(e)):e}}),i(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Object.getOwnPropertyNames(t),n=Object.getPrototypeOf(t);null!==n;)Object.getOwnPropertyNames(n).forEach(function(t){-1===e.indexOf(t)&&e.push(t)}),n=Object.getPrototypeOf(n);return e},is:function(t,e){return t===e?0!==t||1/t===1/e:t!==t&&e!==e}}),i(Math,{sign:function(t){var n=+t;return e(n)||0===n?n:0>n?-1:1}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return i(t.prototype,{get:function(t){var n=e(this.keys,t);return 0>n?void 0:this.values[n]},has:function(t){return e(this.keys,t)>=0},set:function(t,n){var r=this.keys,i=this.values,o=e(r,t);0>o&&(o=r.length),r[o]=t,i[o]=n},"delete":function(t){var n=this.keys,r=this.values,i=e(n,t);return 0>i?!1:(n.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map.delete(t)}}),t}()})});
+234
View File
@@ -0,0 +1,234 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isFinite = globall.isFinite;
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.indexOf(substring) === 0;
},
endsWith: function(substring) {
var substr = String(substring);
var index = this.lastIndexOf(substr)
return index >= 0 && index === this.length - substr.length;
},
contains: function(s) {
return this.indexOf(s) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value > -9007199254740992 && value < 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
sign: function(value) {
var number = +value;
if (Object.is(number, NaN) || number === 0) return number;
return (number < 0) ? -1 : 1;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
if (value === void 0) {
keys.splice(index, 1);
values.splice(index, 1);
return;
}
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isFinite,n=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},r=function(t,e){Object.keys(e).forEach(function(r){n(t,r,e[r])})};r(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.indexOf(t)},endsWith:function(t){var e=String(t),n=this.lastIndexOf(e);return n>=0&&n===this.length-e.length},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),r(Array,{from:function(t){for(var e=Object(t),n=[],r=0,i=e.length>>>0;i>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),r(Number,{isFinite:function(t){return"number"==typeof t&&e(t)},isInteger:function(t){return Number.isFinite(t)&&t>-9007199254740992&&9007199254740992>t&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var e=+t;return Object.is(e,0/0)?0:0!==e&&Number.isFinite(e)?Math.sign(e)*Math.floor(Math.abs(e)):e}}),r(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Object.getOwnPropertyNames(t),n=Object.getPrototypeOf(t);null!==n;)Object.getOwnPropertyNames(n).forEach(function(t){-1===e.indexOf(t)&&e.push(t)}),n=Object.getPrototypeOf(n);return e},is:function(t,e){return t===e?0===t?1/t===1/e:!0:t!==t&&e!==e},isnt:function(t,e){return!Object.is(t,e)}}),r(Math,{sign:function(t){var e=+t;return Object.is(e,0/0)||0===e?e:0>e?-1:1}}),r(t,{Map:function(){function t(){return this instanceof t?(n(this,"keys",[]),void n(this,"values",[])):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return r(t.prototype,{get:function(t){var n=e(this.keys,t);return 0>n?void 0:this.values[n]},has:function(t){return e(this.keys,t)>=0},set:function(t,n){var r=this.keys,i=this.values,o=e(r,t);return 0>o&&(o=r.length),void 0===n?(r.splice(o,1),void i.splice(o,1)):(r[o]=t,void(i[o]=n))},"delete":function(t){var n=this.keys,r=this.values,i=e(n,t);return 0>i?!1:(n.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void n(this,"map",Map()):new t}return r(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+234
View File
@@ -0,0 +1,234 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isFinite = globall.isFinite;
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.indexOf(substring) === 0;
},
endsWith: function(substring) {
var substr = String(substring);
var index = this.lastIndexOf(substr)
return index >= 0 && index === this.length - substr.length;
},
contains: function(s) {
return this.indexOf(s) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value > -9007199254740992 && value < 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
sign: function(value) {
var number = +value;
if (Object.is(number, NaN) || number === 0) return number;
return (number < 0) ? -1 : 1;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
if (value === void 0) {
keys.splice(index, 1);
values.splice(index, 1);
return;
}
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isFinite,n=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},r=function(t,e){Object.keys(e).forEach(function(r){n(t,r,e[r])})};r(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.indexOf(t)},endsWith:function(t){var e=String(t),n=this.lastIndexOf(e);return n>=0&&n===this.length-e.length},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),r(Array,{from:function(t){for(var e=Object(t),n=[],r=0,i=e.length>>>0;i>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),r(Number,{isFinite:function(t){return"number"==typeof t&&e(t)},isInteger:function(t){return Number.isFinite(t)&&t>-9007199254740992&&9007199254740992>t&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var e=+t;return Object.is(e,0/0)?0:0!==e&&Number.isFinite(e)?Math.sign(e)*Math.floor(Math.abs(e)):e}}),r(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Object.getOwnPropertyNames(t),n=Object.getPrototypeOf(t);null!==n;)Object.getOwnPropertyNames(n).forEach(function(t){-1===e.indexOf(t)&&e.push(t)}),n=Object.getPrototypeOf(n);return e},is:function(t,e){return t===e?0===t?1/t===1/e:!0:t!==t&&e!==e},isnt:function(t,e){return!Object.is(t,e)}}),r(Math,{sign:function(t){var e=+t;return Object.is(e,0/0)||0===e?e:0>e?-1:1}}),r(t,{Map:function(){function t(){return this instanceof t?(n(this,"keys",[]),void n(this,"values",[])):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return r(t.prototype,{get:function(t){var n=e(this.keys,t);return 0>n?void 0:this.values[n]},has:function(t){return e(this.keys,t)>=0},set:function(t,n){var r=this.keys,i=this.values,o=e(r,t);return 0>o&&(o=r.length),void 0===n?(r.splice(o,1),void i.splice(o,1)):(r[o]=t,void(i[o]=n))},"delete":function(t){var n=this.keys,r=this.values,i=e(n,t);return 0>i?!1:(n.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void n(this,"map",Map()):new t}return r(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+309
View File
@@ -0,0 +1,309 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isFinite = globall.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.indexOf(substring) === 0;
},
endsWith: function(substring) {
var substr = String(substring);
var index = this.lastIndexOf(substr)
return index >= 0 && index === this.length - substr.length;
},
contains: function(s) {
return this.indexOf(s) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value > -9007199254740992 && value < 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (Object.is(number, NaN) || number === 0) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
if (value === void 0) {
keys.splice(index, 1);
values.splice(index, 1);
return;
}
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,n=t.isFinite,e=function(t){for(var n=1,e=2;t>=e;e++)n*=e;return n},r=function(t,n,e){t[n]||Object.defineProperty(t,n,{configurable:!0,enumerable:!1,writable:!0,value:e})},i=function(t,n){Object.keys(n).forEach(function(e){r(t,e,n[e])})};i(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.indexOf(t)},endsWith:function(t){var n=String(t),e=this.lastIndexOf(n);return e>=0&&e===this.length-n.length},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),i(Array,{from:function(t){for(var n=Object(t),e=[],r=0,i=n.length>>>0;i>r;r++)r in n&&(e[r]=n[r]);return e},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{isFinite:function(t){return"number"==typeof t&&n(t)},isInteger:function(t){return Number.isFinite(t)&&t>-9007199254740992&&9007199254740992>t&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var n=+t;return Object.is(n,0/0)?0:0!==n&&Number.isFinite(n)?Math.sign(n)*Math.floor(Math.abs(n)):n}}),i(Object,{getOwnPropertyDescriptors:function(t){var n={};return Object.getOwnPropertyNames(t).forEach(function(e){n[e]=Object.getOwnPropertyDescriptor(t,e)}),n},getPropertyDescriptor:function(t,n){for(var e=Object.getOwnPropertyDescriptor(t,n),r=Object.getPrototypeOf(t);void 0===e&&null!==r;)e=Object.getOwnPropertyDescriptor(r,n),r=Object.getPrototypeOf(r);return e},getPropertyNames:function(t){for(var n=Object.getOwnPropertyNames(t),e=Object.getPrototypeOf(t);null!==e;)Object.getOwnPropertyNames(e).forEach(function(t){-1===n.indexOf(t)&&n.push(t)}),e=Object.getPrototypeOf(e);return n},is:function(t,n){return t===n?0===t?1/t===1/n:!0:t!==t&&n!==n},isnt:function(t,n){return!Object.is(t,n)}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var n=0,r=50,i=1;r>i;i++)n+=Math.pow(t,i)/e(i);return n},hypot:function(t,n){return Math.sqrt(t*t+n*n)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var n=0,e=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;e>r;r++)r%2===0?n-=Math.pow(t,r)/r:n+=Math.pow(t,r)/r;return n},sign:function(t){var n=+t;return Object.is(n,0/0)||0===n?n:0>n?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var n=function(t,n){for(var e=0,r=t.length;r>e;e++)if(Object.is(t[e],n))return e;return-1};return i(t.prototype,{get:function(t){var e=n(this.keys,t);return 0>e?void 0:this.values[e]},has:function(t){return n(this.keys,t)>=0},set:function(t,e){var r=this.keys,i=this.values,o=n(r,t);return 0>o&&(o=r.length),void 0===e?(r.splice(o,1),void i.splice(o,1)):(r[o]=t,void(i[o]=e))},"delete":function(t){var e=this.keys,r=this.values,i=n(e,t);return 0>i?!1:(e.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+308
View File
@@ -0,0 +1,308 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globall = (typeof global === 'undefined') ? window : global;
var global_isFinite = globall.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.lastIndexOf(substring, 0) === 0;
},
endsWith: function(substring) {
var startFrom = this.length - String(substring).length;
return startFrom >= 0 && this.indexOf(substring, startFrom) === startFrom;
},
contains: function(substring) {
return this.indexOf(substring) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= 9007199254740992 &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (Object.is(number, NaN) || number === 0) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globall, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
if (value === void 0) {
keys.splice(index, 1);
values.splice(index, 1);
return;
}
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,n=t.isFinite,e=function(t){for(var n=1,e=2;t>=e;e++)n*=e;return n},r=function(t,n,e){t[n]||Object.defineProperty(t,n,{configurable:!0,enumerable:!1,writable:!0,value:e})},i=function(t,n){Object.keys(n).forEach(function(e){r(t,e,n[e])})};i(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.lastIndexOf(t,0)},endsWith:function(t){var n=this.length-String(t).length;return n>=0&&this.indexOf(t,n)===n},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),i(Array,{from:function(t){for(var n=Object(t),e=[],r=0,i=n.length>>>0;i>r;r++)r in n&&(e[r]=n[r]);return e},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{isFinite:function(t){return"number"==typeof t&&n(t)},isInteger:function(t){return Number.isFinite(t)&&t>=-9007199254740992&&9007199254740992>=t&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var n=+t;return Object.is(n,0/0)?0:0!==n&&Number.isFinite(n)?Math.sign(n)*Math.floor(Math.abs(n)):n}}),i(Object,{getOwnPropertyDescriptors:function(t){var n={};return Object.getOwnPropertyNames(t).forEach(function(e){n[e]=Object.getOwnPropertyDescriptor(t,e)}),n},getPropertyDescriptor:function(t,n){for(var e=Object.getOwnPropertyDescriptor(t,n),r=Object.getPrototypeOf(t);void 0===e&&null!==r;)e=Object.getOwnPropertyDescriptor(r,n),r=Object.getPrototypeOf(r);return e},getPropertyNames:function(t){for(var n=Object.getOwnPropertyNames(t),e=Object.getPrototypeOf(t);null!==e;)Object.getOwnPropertyNames(e).forEach(function(t){-1===n.indexOf(t)&&n.push(t)}),e=Object.getPrototypeOf(e);return n},is:function(t,n){return t===n?0===t?1/t===1/n:!0:t!==t&&n!==n},isnt:function(t,n){return!Object.is(t,n)}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var n=0,r=50,i=1;r>i;i++)n+=Math.pow(t,i)/e(i);return n},hypot:function(t,n){return Math.sqrt(t*t+n*n)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var n=0,e=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;e>r;r++)r%2===0?n-=Math.pow(t,r)/r:n+=Math.pow(t,r)/r;return n},sign:function(t){var n=+t;return Object.is(n,0/0)||0===n?n:0>n?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var n=function(t,n){for(var e=0,r=t.length;r>e;e++)if(Object.is(t[e],n))return e;return-1};return i(t.prototype,{get:function(t){var e=n(this.keys,t);return 0>e?void 0:this.values[e]},has:function(t){return n(this.keys,t)>=0},set:function(t,e){var r=this.keys,i=this.values,o=n(r,t);return 0>o&&(o=r.length),void 0===e?(r.splice(o,1),void i.splice(o,1)):(r[o]=t,void(i[o]=e))},"delete":function(t){var e=this.keys,r=this.values,i=n(e,t);return 0>i?!1:(e.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+329
View File
@@ -0,0 +1,329 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.lastIndexOf(substring, 0) === 0;
},
endsWith: function(substring) {
var startFrom = this.length - String(substring).length;
return startFrom >= 0 && this.indexOf(substring, startFrom) === startFrom;
},
contains: function(substring) {
return this.indexOf(substring) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740992,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
},
isObject: function(value) {
return typeof value === 'object' && value !== null;
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globals, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
if (value === void 0) {
keys.splice(index, 1);
values.splice(index, 1);
return;
}
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,n=t.isFinite,e=function(t){for(var n=1,e=2;t>=e;e++)n*=e;return n},r=function(t,n,e){t[n]||Object.defineProperty(t,n,{configurable:!0,enumerable:!1,writable:!0,value:e})},i=function(t,n){Object.keys(n).forEach(function(e){r(t,e,n[e])})};i(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.lastIndexOf(t,0)},endsWith:function(t){var n=this.length-String(t).length;return n>=0&&this.indexOf(t,n)===n},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),i(Array,{from:function(t){for(var n=Object(t),e=[],r=0,i=n.length>>>0;i>r;r++)r in n&&(e[r]=n[r]);return e},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{MAX_INTEGER:9007199254740992,EPSILON:2.220446049250313e-16,parseInt:t.parseInt,parseFloat:t.parseFloat,isFinite:function(t){return"number"==typeof t&&n(t)},isInteger:function(t){return Number.isFinite(t)&&t>=-9007199254740992&&t<=Number.MAX_INTEGER&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var n=+t;return Object.is(n,0/0)?0:0!==n&&Number.isFinite(n)?Math.sign(n)*Math.floor(Math.abs(n)):n}}),i(Number.prototype,{clz:function(){var t=+this;return t&&Number.isFinite(t)?(t=0>t?Math.ceil(t):Math.floor(t),t-=4294967296*Math.floor(t/4294967296),32-t.toString(2).length):32}}),i(Object,{getOwnPropertyDescriptors:function(t){var n={};return Object.getOwnPropertyNames(t).forEach(function(e){n[e]=Object.getOwnPropertyDescriptor(t,e)}),n},getPropertyDescriptor:function(t,n){for(var e=Object.getOwnPropertyDescriptor(t,n),r=Object.getPrototypeOf(t);void 0===e&&null!==r;)e=Object.getOwnPropertyDescriptor(r,n),r=Object.getPrototypeOf(r);return e},getPropertyNames:function(t){for(var n=Object.getOwnPropertyNames(t),e=Object.getPrototypeOf(t);null!==e;)Object.getOwnPropertyNames(e).forEach(function(t){-1===n.indexOf(t)&&n.push(t)}),e=Object.getPrototypeOf(e);return n},is:function(t,n){return t===n?0===t?1/t===1/n:!0:t!==t&&n!==n},isnt:function(t,n){return!Object.is(t,n)},isObject:function(t){return"object"==typeof t&&null!==t}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var n=0,r=50,i=1;r>i;i++)n+=Math.pow(t,i)/e(i);return n},hypot:function(t,n){return Math.sqrt(t*t+n*n)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var n=0,e=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;e>r;r++)r%2===0?n-=Math.pow(t,r)/r:n+=Math.pow(t,r)/r;return n},sign:function(t){var n=+t;return 0===n?n:Object.is(n,0/0)?n:0>n?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var n=function(t,n){for(var e=0,r=t.length;r>e;e++)if(Object.is(t[e],n))return e;return-1};return i(t.prototype,{get:function(t){var e=n(this.keys,t);return 0>e?void 0:this.values[e]},has:function(t){return n(this.keys,t)>=0},set:function(t,e){var r=this.keys,i=this.values,o=n(r,t);return 0>o&&(o=r.length),void 0===e?(r.splice(o,1),void i.splice(o,1)):(r[o]=t,void(i[o]=e))},"delete":function(t){var e=this.keys,r=this.values,i=n(e,t);return 0>i?!1:(e.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+324
View File
@@ -0,0 +1,324 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.lastIndexOf(substring, 0) === 0;
},
endsWith: function(substring) {
var startFrom = this.length - String(substring).length;
return startFrom >= 0 && this.indexOf(substring, startFrom) === startFrom;
},
contains: function(substring) {
return this.indexOf(substring) !== -1;
},
toArray: function() {
return this.split('');
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740992,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
},
isObject: function(value) {
return typeof value === 'object' && value !== null;
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globals, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,n=t.isFinite,e=function(t){for(var n=1,e=2;t>=e;e++)n*=e;return n},r=function(t,n,e){t[n]||Object.defineProperty(t,n,{configurable:!0,enumerable:!1,writable:!0,value:e})},i=function(t,n){Object.keys(n).forEach(function(e){r(t,e,n[e])})};i(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.lastIndexOf(t,0)},endsWith:function(t){var n=this.length-String(t).length;return n>=0&&this.indexOf(t,n)===n},contains:function(t){return-1!==this.indexOf(t)},toArray:function(){return this.split("")}}),i(Array,{from:function(t){for(var n=Object(t),e=[],r=0,i=n.length>>>0;i>r;r++)r in n&&(e[r]=n[r]);return e},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{MAX_INTEGER:9007199254740992,EPSILON:2.220446049250313e-16,parseInt:t.parseInt,parseFloat:t.parseFloat,isFinite:function(t){return"number"==typeof t&&n(t)},isInteger:function(t){return Number.isFinite(t)&&t>=-9007199254740992&&t<=Number.MAX_INTEGER&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var n=+t;return Object.is(n,0/0)?0:0!==n&&Number.isFinite(n)?Math.sign(n)*Math.floor(Math.abs(n)):n}}),i(Number.prototype,{clz:function(){var t=+this;return t&&Number.isFinite(t)?(t=0>t?Math.ceil(t):Math.floor(t),t-=4294967296*Math.floor(t/4294967296),32-t.toString(2).length):32}}),i(Object,{getOwnPropertyDescriptors:function(t){var n={};return Object.getOwnPropertyNames(t).forEach(function(e){n[e]=Object.getOwnPropertyDescriptor(t,e)}),n},getPropertyDescriptor:function(t,n){for(var e=Object.getOwnPropertyDescriptor(t,n),r=Object.getPrototypeOf(t);void 0===e&&null!==r;)e=Object.getOwnPropertyDescriptor(r,n),r=Object.getPrototypeOf(r);return e},getPropertyNames:function(t){for(var n=Object.getOwnPropertyNames(t),e=Object.getPrototypeOf(t);null!==e;)Object.getOwnPropertyNames(e).forEach(function(t){-1===n.indexOf(t)&&n.push(t)}),e=Object.getPrototypeOf(e);return n},is:function(t,n){return t===n?0===t?1/t===1/n:!0:t!==t&&n!==n},isnt:function(t,n){return!Object.is(t,n)},isObject:function(t){return"object"==typeof t&&null!==t}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var n=0,r=50,i=1;r>i;i++)n+=Math.pow(t,i)/e(i);return n},hypot:function(t,n){return Math.sqrt(t*t+n*n)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var n=0,e=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;e>r;r++)r%2===0?n-=Math.pow(t,r)/r:n+=Math.pow(t,r)/r;return n},sign:function(t){var n=+t;return 0===n?n:Object.is(n,0/0)?n:0>n?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var n=function(t,n){for(var e=0,r=t.length;r>e;e++)if(Object.is(t[e],n))return e;return-1};return i(t.prototype,{get:function(t){var e=n(this.keys,t);return 0>e?void 0:this.values[e]},has:function(t){return n(this.keys,t)>=0},set:function(t,e){var r=this.keys,i=this.values,o=n(r,t);0>o&&(o=r.length),r[o]=t,i[o]=e},"delete":function(t){var e=this.keys,r=this.values,i=n(e,t);return 0>i?!1:(e.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+316
View File
@@ -0,0 +1,316 @@
({define: (typeof define === 'function')
? define // RequireJS
: function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
repeat: function(times) {
return new Array(times + 1).join(this);
},
startsWith: function(substring) {
return this.lastIndexOf(substring, 0) === 0;
},
endsWith: function(substring) {
var startFrom = this.length - String(substring).length;
return startFrom >= 0 && this.indexOf(substring, startFrom) === startFrom;
},
contains: function(substring) {
return this.indexOf(substring) !== -1;
}
});
defineProperties(Array, {
from: function(iterable) {
var object = Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740992,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject, name) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var property;
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
});
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN("foo") => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globals, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map;
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set;
defineProperty(this, 'map', Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,n=t.isFinite,e=function(t){for(var n=1,e=2;t>=e;e++)n*=e;return n},r=function(t,n,e){t[n]||Object.defineProperty(t,n,{configurable:!0,enumerable:!1,writable:!0,value:e})},i=function(t,n){Object.keys(n).forEach(function(e){r(t,e,n[e])})};i(String.prototype,{repeat:function(t){return new Array(t+1).join(this)},startsWith:function(t){return 0===this.lastIndexOf(t,0)},endsWith:function(t){var n=this.length-String(t).length;return n>=0&&this.indexOf(t,n)===n},contains:function(t){return-1!==this.indexOf(t)}}),i(Array,{from:function(t){for(var n=Object(t),e=[],r=0,i=n.length>>>0;i>r;r++)r in n&&(e[r]=n[r]);return e},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{MAX_INTEGER:9007199254740992,EPSILON:2.220446049250313e-16,parseInt:t.parseInt,parseFloat:t.parseFloat,isFinite:function(t){return"number"==typeof t&&n(t)},isInteger:function(t){return Number.isFinite(t)&&t>=-9007199254740992&&t<=Number.MAX_INTEGER&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var n=+t;return Object.is(n,0/0)?0:0!==n&&Number.isFinite(n)?Math.sign(n)*Math.floor(Math.abs(n)):n}}),i(Number.prototype,{clz:function(){var t=+this;return t&&Number.isFinite(t)?(t=0>t?Math.ceil(t):Math.floor(t),t-=4294967296*Math.floor(t/4294967296),32-t.toString(2).length):32}}),i(Object,{getOwnPropertyDescriptors:function(t){var n={};return Object.getOwnPropertyNames(t).forEach(function(e){n[e]=Object.getOwnPropertyDescriptor(t,e)}),n},getPropertyDescriptor:function(t,n){for(var e=Object.getOwnPropertyDescriptor(t,n),r=Object.getPrototypeOf(t);void 0===e&&null!==r;)e=Object.getOwnPropertyDescriptor(r,n),r=Object.getPrototypeOf(r);return e},getPropertyNames:function(t){for(var n=Object.getOwnPropertyNames(t),e=Object.getPrototypeOf(t);null!==e;)Object.getOwnPropertyNames(e).forEach(function(t){-1===n.indexOf(t)&&n.push(t)}),e=Object.getPrototypeOf(e);return n},is:function(t,n){return t===n?0===t?1/t===1/n:!0:t!==t&&n!==n},isnt:function(t,n){return!Object.is(t,n)}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var n=0,r=50,i=1;r>i;i++)n+=Math.pow(t,i)/e(i);return n},hypot:function(t,n){return Math.sqrt(t*t+n*n)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var n=0,e=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;e>r;r++)r%2===0?n-=Math.pow(t,r)/r:n+=Math.pow(t,r)/r;return n},sign:function(t){var n=+t;return 0===n?n:Object.is(n,0/0)?n:0>n?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var n=function(t,n){for(var e=0,r=t.length;r>e;e++)if(Object.is(t[e],n))return e;return-1};return i(t.prototype,{get:function(t){var e=n(this.keys,t);return 0>e?void 0:this.values[e]},has:function(t){return n(this.keys,t)>=0},set:function(t,e){var r=this.keys,i=this.values,o=n(r,t);0>o&&(o=r.length),r[o]=t,i[o]=e},"delete":function(t){var e=this.keys,r=this.values,i=n(e,t);return 0>i?!1:(e.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",Map()):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+397
View File
@@ -0,0 +1,397 @@
// ES6-shim 0.5.3 (c) 2012 Paul Miller (paulmillr.com)
// ES6-shim may be freely distributed under the MIT license.
// For more details and documentation:
// https://github.com/paulmillr/es6-shim/
({define: (typeof define === 'function') ?
define : // RequireJS
function(definition) {definition();} // CommonJS and <script>
}).define(function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
repeat: function(times) {
if (times < 1) return '';
if (times % 2) return this.repeat(times - 1) + this;
var half = this.repeat(times / 2);
return half + half;
},
startsWith: function(searchString) {
var position = arguments[1];
// Let searchStr be ToString(searchString).
var searchStr = searchString.toString();
// ReturnIfAbrupt(searchStr).
// Let S be the result of calling ToString,
// giving it the this value as its argument.
var s = this.toString();
// ReturnIfAbrupt(S).
// Let pos be ToInteger(position).
// (If position is undefined, this step produces the value 0).
var pos = (position === undefined) ? 0 : Number.toInteger(position);
// ReturnIfAbrupt(pos).
// Let len be the number of elements in S.
var len = s.length;
// Let start be min(max(pos, 0), len).
var start = Math.min(Math.max(pos, 0), len);
// Let searchLength be the number of elements in searchString.
var searchLength = searchString.length;
// If searchLength+start is greater than len, return false.
if ((searchLength + start) > len) return false;
// If the searchLength sequence of elements of S starting at
// start is the same as the full element sequence of searchString,
// return true.
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
endsWith: function(searchString) {
var endPosition = arguments[1];
// ReturnIfAbrupt(CheckObjectCoercible(this value)).
// Let S be the result of calling ToString, giving it the this value as its argument.
// ReturnIfAbrupt(S).
var s = this.toString();
// Let searchStr be ToString(searchString).
// ReturnIfAbrupt(searchStr).
var searchStr = searchString.toString();
// Let len be the number of elements in S.
var len = s.length;
// If endPosition is undefined, let pos be len, else let pos be ToInteger(endPosition).
// ReturnIfAbrupt(pos).
var pos = (endPosition === undefined) ?
len :
Number.toInteger(endPosition);
// Let end be min(max(pos, 0), len).
var end = Math.min(Math.max(pos, 0), len);
// Let searchLength be the number of elements in searchString.
var searchLength = searchString.length;
// Let start be end - searchLength.
var start = end - searchLength;
// If start is less than 0, return false.
if (start < 0) return false;
// If the searchLength sequence of elements of S starting at start is the same as the full element sequence of searchString, return true.
// Otherwise, return false.
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
contains: function(searchString) {
var position = arguments[1];
// Somehow this trick makes method 100% compat with the spec.
return ''.indexOf.call(this, searchString, position) !== -1;
}
});
defineProperties(Array, {
from: function(iterable) {
var object = new Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740992,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var addProperty = function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
};
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical.
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globals, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map();
defineProperty(this, 'keys', []);
defineProperty(this, 'values', []);
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this.keys, key);
return index < 0 ? undefined : this.values[index];
},
has: function(key) {
return indexOfIdentical(this.keys, key) >= 0;
},
set: function(key, value) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
},
'delete': function(key) {
var keys = this.keys;
var values = this.values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
return true;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set();
defineProperty(this, 'map', new Map());
}
defineProperties(Set.prototype, {
has: function(key) {
return this.map.has(key);
},
add: function(key) {
this.map.set(key, true);
},
'delete': function(key) {
return this.map['delete'](key);
}
});
return Set;
})()
});
});
+1
View File
@@ -0,0 +1 @@
({define:"function"==typeof define?define:function(t){t()}}).define(function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isFinite,n=function(t){for(var e=1,n=2;t>=n;n++)e*=n;return e},r=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},i=function(t,e){Object.keys(e).forEach(function(n){r(t,n,e[n])})};i(String.prototype,{repeat:function(t){if(1>t)return"";if(t%2)return this.repeat(t-1)+this;var e=this.repeat(t/2);return e+e},startsWith:function(t){var e=arguments[1],n=(t.toString(),this.toString()),r=void 0===e?0:Number.toInteger(e),i=n.length,o=Math.min(Math.max(r,0),i),u=t.length;if(u+o>i)return!1;var a="".indexOf.call(n,t,o);return a===o},endsWith:function(t){var e=arguments[1],n=this.toString(),r=(t.toString(),n.length),i=void 0===e?r:Number.toInteger(e),o=Math.min(Math.max(i,0),r),u=t.length,a=o-u;if(0>a)return!1;var c="".indexOf.call(n,t,a);return c===a},contains:function(t){var e=arguments[1];return-1!=="".indexOf.call(this,t,e)}}),i(Array,{from:function(t){for(var e=new Object(t),n=[],r=0,i=e.length>>>0;i>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{MAX_INTEGER:9007199254740992,EPSILON:2.220446049250313e-16,parseInt:t.parseInt,parseFloat:t.parseFloat,isFinite:function(t){return"number"==typeof t&&e(t)},isInteger:function(t){return Number.isFinite(t)&&t>=-9007199254740992&&t<=Number.MAX_INTEGER&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var e=+t;return Object.is(e,0/0)?0:0!==e&&Number.isFinite(e)?Math.sign(e)*Math.floor(Math.abs(e)):e}}),i(Number.prototype,{clz:function(){var t=+this;return t&&Number.isFinite(t)?(t=0>t?Math.ceil(t):Math.floor(t),t-=4294967296*Math.floor(t/4294967296),32-t.toString(2).length):32}}),i(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Object.getOwnPropertyNames(t),n=Object.getPrototypeOf(t),r=function(t){-1===e.indexOf(t)&&e.push(t)};null!==n;)Object.getOwnPropertyNames(n).forEach(r),n=Object.getPrototypeOf(n);return e},is:function(t,e){return t===e?0===t?1/t===1/e:!0:t!==t&&e!==e},isnt:function(t,e){return!Object.is(t,e)}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var e=0,r=50,i=1;r>i;i++)e+=Math.pow(t,i)/n(i);return e},hypot:function(t,e){return Math.sqrt(t*t+e*e)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var e=0,n=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;n>r;r++)r%2===0?e-=Math.pow(t,r)/r:e+=Math.pow(t,r)/r;return e},sign:function(t){var e=+t;return 0===e?e:Object.is(e,0/0)?e:0>e?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"keys",[]),void r(this,"values",[])):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return i(t.prototype,{get:function(t){var n=e(this.keys,t);return 0>n?void 0:this.values[n]},has:function(t){return e(this.keys,t)>=0},set:function(t,n){var r=this.keys,i=this.values,o=e(r,t);0>o&&(o=r.length),r[o]=t,i[o]=n},"delete":function(t){var n=this.keys,r=this.values,i=e(n,t);return 0>i?!1:(n.splice(i,1),r.splice(i,1),!0)}}),t}(),Set:function(){function t(){return this instanceof t?void r(this,"map",new Map):new t}return i(t.prototype,{has:function(t){return this.map.has(t)},add:function(t){this.map.set(t,!0)},"delete":function(t){return this.map["delete"](t)}}),t}()})});
+434
View File
@@ -0,0 +1,434 @@
// ES6-shim 0.6.0 (c) 2013 Paul Miller (paulmillr.com)
// ES6-shim may be freely distributed under the MIT license.
// For more details and documentation:
// https://github.com/paulmillr/es6-shim/
var main = function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var factorial = function(value) {
var result = 1;
for (var i = 2; i <= value; i++) {
result *= i;
}
return result;
};
var defineProperty = function(object, name, method) {
if (!object[name]) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
}
};
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
defineProperty(object, name, map[name]);
});
};
defineProperties(String.prototype, {
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
repeat: function(times) {
if (times < 1) return '';
if (times % 2) return this.repeat(times - 1) + this;
var half = this.repeat(times / 2);
return half + half;
},
startsWith: function(searchString) {
var position = arguments[1];
// Let searchStr be ToString(searchString).
var searchStr = searchString.toString();
// ReturnIfAbrupt(searchStr).
// Let S be the result of calling ToString,
// giving it the this value as its argument.
var s = this.toString();
// ReturnIfAbrupt(S).
// Let pos be ToInteger(position).
// (If position is undefined, this step produces the value 0).
var pos = (position === undefined) ? 0 : Number.toInteger(position);
// ReturnIfAbrupt(pos).
// Let len be the number of elements in S.
var len = s.length;
// Let start be min(max(pos, 0), len).
var start = Math.min(Math.max(pos, 0), len);
// Let searchLength be the number of elements in searchString.
var searchLength = searchString.length;
// If searchLength+start is greater than len, return false.
if ((searchLength + start) > len) return false;
// If the searchLength sequence of elements of S starting at
// start is the same as the full element sequence of searchString,
// return true.
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
endsWith: function(searchString) {
var endPosition = arguments[1];
// ReturnIfAbrupt(CheckObjectCoercible(this value)).
// Let S be the result of calling ToString, giving it the this value as its argument.
// ReturnIfAbrupt(S).
var s = this.toString();
// Let searchStr be ToString(searchString).
// ReturnIfAbrupt(searchStr).
var searchStr = searchString.toString();
// Let len be the number of elements in S.
var len = s.length;
// If endPosition is undefined, let pos be len, else let pos be ToInteger(endPosition).
// ReturnIfAbrupt(pos).
var pos = (endPosition === undefined) ?
len :
Number.toInteger(endPosition);
// Let end be min(max(pos, 0), len).
var end = Math.min(Math.max(pos, 0), len);
// Let searchLength be the number of elements in searchString.
var searchLength = searchString.length;
// Let start be end - searchLength.
var start = end - searchLength;
// If start is less than 0, return false.
if (start < 0) return false;
// If the searchLength sequence of elements of S starting at start is the same as the full element sequence of searchString, return true.
// Otherwise, return false.
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
contains: function(searchString) {
var position = arguments[1];
// Somehow this trick makes method 100% compat with the spec.
return ''.indexOf.call(this, searchString, position) !== -1;
}
});
defineProperties(Array, {
from: function(iterable) {
var object = new Object(iterable);
var array = [];
for (var key = 0, length = object.length >>> 0; key < length; key++) {
if (key in object) {
array[key] = object[key];
}
}
return array;
},
of: function() {
return Array.prototype.slice.call(arguments);
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740992,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var addProperty = function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
};
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}
return result;
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical.
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return x !== x && y !== y;
},
isnt: function(x, y) {
return !Object.is(x, y);
}
});
defineProperties(Math, {
acosh: function(value) {
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
return 0.5 * Math.log((1 + value) / (1 - value));
},
cosh: function(value) {
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
result += Math.pow(value, i) / factorial(i);
}
return result;
},
hypot: function(x, y) {
return Math.sqrt(x * x + y * y) || 0;
},
log2: function(value) {
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
var result = 0;
var n = 50;
if (value <= -1) return -Infinity;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
return ~~value;
}
});
defineProperties(globals, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map();
defineProperty(this, '_keys', []);
defineProperty(this, '_values', []);
defineProperty(this, '_size', 0);
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this._size;
}).bind(this)
});
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this._keys, key);
return index < 0 ? undefined : this._values[index];
},
has: function(key) {
return indexOfIdentical(this._keys, key) >= 0;
},
set: function(key, value) {
var keys = this._keys;
var values = this._values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
this._size += 1;
},
'delete': function(key) {
var keys = this._keys;
var values = this._values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
this._size -= 1;
return true;
},
keys: function() {
return this._keys;
},
values: function() {
return this._values;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set();
defineProperty(this, '[[SetData]]', new Map());
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this['[[SetData]]'].size;
}).bind(this)
});
}
defineProperties(Set.prototype, {
has: function(key) {
return this['[[SetData]]'].has(key);
},
add: function(key) {
this['[[SetData]]'].set(key, true);
},
'delete': function(key) {
return this['[[SetData]]']['delete'](key);
},
clear: function() {
Object.defineProperty(this, '[[SetData]]', {
configurable: true,
enumerable: false,
writable: true,
value: new Map()
});
}
});
return Set;
})()
});
};
if (typeof define === 'function' && typeof define.amd == 'object' && define.amd) {
define(main); // RequireJS
} else {
main(); // CommonJS and <script>
}
+1
View File
@@ -0,0 +1 @@
var main=function(){"use strict";var t="undefined"==typeof global?window:global,e=t.isFinite,n=function(t){for(var e=1,n=2;t>=n;n++)e*=n;return e},r=function(t,e,n){t[e]||Object.defineProperty(t,e,{configurable:!0,enumerable:!1,writable:!0,value:n})},i=function(t,e){Object.keys(e).forEach(function(n){r(t,n,e[n])})};i(String.prototype,{repeat:function(t){if(1>t)return"";if(t%2)return this.repeat(t-1)+this;var e=this.repeat(t/2);return e+e},startsWith:function(t){var e=arguments[1],n=(t.toString(),this.toString()),r=void 0===e?0:Number.toInteger(e),i=n.length,o=Math.min(Math.max(r,0),i),a=t.length;if(a+o>i)return!1;var u="".indexOf.call(n,t,o);return u===o},endsWith:function(t){var e=arguments[1],n=this.toString(),r=(t.toString(),n.length),i=void 0===e?r:Number.toInteger(e),o=Math.min(Math.max(i,0),r),a=t.length,u=o-a;if(0>u)return!1;var s="".indexOf.call(n,t,u);return s===u},contains:function(t){var e=arguments[1];return-1!=="".indexOf.call(this,t,e)}}),i(Array,{from:function(t){for(var e=new Object(t),n=[],r=0,i=e.length>>>0;i>r;r++)r in e&&(n[r]=e[r]);return n},of:function(){return Array.prototype.slice.call(arguments)}}),i(Number,{MAX_INTEGER:9007199254740992,EPSILON:2.220446049250313e-16,parseInt:t.parseInt,parseFloat:t.parseFloat,isFinite:function(t){return"number"==typeof t&&e(t)},isInteger:function(t){return Number.isFinite(t)&&t>=-9007199254740992&&t<=Number.MAX_INTEGER&&Math.floor(t)===t},isNaN:function(t){return Object.is(t,0/0)},toInteger:function(t){var e=+t;return Object.is(e,0/0)?0:0!==e&&Number.isFinite(e)?Math.sign(e)*Math.floor(Math.abs(e)):e}}),i(Number.prototype,{clz:function(){var t=+this;return t&&Number.isFinite(t)?(t=0>t?Math.ceil(t):Math.floor(t),t-=4294967296*Math.floor(t/4294967296),32-t.toString(2).length):32}}),i(Object,{getOwnPropertyDescriptors:function(t){var e={};return Object.getOwnPropertyNames(t).forEach(function(n){e[n]=Object.getOwnPropertyDescriptor(t,n)}),e},getPropertyDescriptor:function(t,e){for(var n=Object.getOwnPropertyDescriptor(t,e),r=Object.getPrototypeOf(t);void 0===n&&null!==r;)n=Object.getOwnPropertyDescriptor(r,e),r=Object.getPrototypeOf(r);return n},getPropertyNames:function(t){for(var e=Object.getOwnPropertyNames(t),n=Object.getPrototypeOf(t),r=function(t){-1===e.indexOf(t)&&e.push(t)};null!==n;)Object.getOwnPropertyNames(n).forEach(r),n=Object.getPrototypeOf(n);return e},is:function(t,e){return t===e?0===t?1/t===1/e:!0:t!==t&&e!==e},isnt:function(t,e){return!Object.is(t,e)}}),i(Math,{acosh:function(t){return Math.log(t+Math.sqrt(t*t-1))},asinh:function(t){return Math.log(t+Math.sqrt(t*t+1))},atanh:function(t){return.5*Math.log((1+t)/(1-t))},cosh:function(t){return 0>t&&(t=-t),t>21?Math.exp(t)/2:(Math.exp(t)+Math.exp(-t))/2},expm1:function(t){for(var e=0,r=50,i=1;r>i;i++)e+=Math.pow(t,i)/n(i);return e},hypot:function(t,e){return Math.sqrt(t*t+e*e)||0},log2:function(t){return Math.log(t)*(1/Math.LN2)},log10:function(t){return Math.log(t)*(1/Math.LN10)},log1p:function(t){var e=0,n=50;if(-1>=t)return-1/0;if(0>t||t>1)return Math.log(1+t);for(var r=1;n>r;r++)r%2===0?e-=Math.pow(t,r)/r:e+=Math.pow(t,r)/r;return e},sign:function(t){var e=+t;return 0===e?e:Object.is(e,0/0)?e:0>e?-1:1},sinh:function(t){return(Math.exp(t)-Math.exp(-t))/2},tanh:function(t){return(Math.exp(t)-Math.exp(-t))/(Math.exp(t)+Math.exp(-t))},trunc:function(t){return~~t}}),i(t,{Map:function(){function t(){return this instanceof t?(r(this,"_keys",[]),r(this,"_values",[]),r(this,"_size",0),void Object.defineProperty(this,"size",{configurable:!0,enumerable:!1,get:function(){return this._size}.bind(this)})):new t}var e=function(t,e){for(var n=0,r=t.length;r>n;n++)if(Object.is(t[n],e))return n;return-1};return i(t.prototype,{get:function(t){var n=e(this._keys,t);return 0>n?void 0:this._values[n]},has:function(t){return e(this._keys,t)>=0},set:function(t,n){var r=this._keys,i=this._values,o=e(r,t);0>o&&(o=r.length),r[o]=t,i[o]=n,this._size+=1},"delete":function(t){var n=this._keys,r=this._values,i=e(n,t);return 0>i?!1:(n.splice(i,1),r.splice(i,1),this._size-=1,!0)},keys:function(){return this._keys},values:function(){return this._values}}),t}(),Set:function(){function t(){return this instanceof t?(r(this,"[[SetData]]",new Map),void Object.defineProperty(this,"size",{configurable:!0,enumerable:!1,get:function(){return this["[[SetData]]"].size}.bind(this)})):new t}return i(t.prototype,{has:function(t){return this["[[SetData]]"].has(t)},add:function(t){this["[[SetData]]"].set(t,!0)},"delete":function(t){return this["[[SetData]]"]["delete"](t)},clear:function(){Object.defineProperty(this,"[[SetData]]",{configurable:!0,enumerable:!1,writable:!0,value:new Map})}}),t}()})};"function"==typeof define&&"object"==typeof define.amd&&define.amd?define(main):main();
+621
View File
@@ -0,0 +1,621 @@
// ES6-shim 0.7.0 (c) 2013 Paul Miller (paulmillr.com)
// ES6-shim may be freely distributed under the MIT license.
// For more details and documentation:
// https://github.com/paulmillr/es6-shim/
var main = function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var supportsDescriptors = !!Object.defineProperty;
// Define configurable, writable and non-enumerable props
// if they dont exist.
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
var method = map[name];
if (name in object) return;
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
} else {
object[name] = method;
}
});
};
var ES = {
ToInt32: function(x) {
return x >> 0;
},
ToUint32: function(x) {
return x >>> 0;
}
};
defineProperties(String, {
fromCodePoint: function() {
var points = arguments;
var result = [];
var next;
for (var i = 0, length = points.length; i < length; i++) {
next = Number(points[i]);
if (!Object.is(next, Number.toInteger(next)) ||
next < 0 || next > 0x10FFFF) {
throw new RangeError('Invalid code point ' + next);
}
if (next < 0x10000) {
result.push(String.fromCharCode(next));
} else {
next -= 0x10000;
result.push(String.fromCharCode((next >> 10) + 0xD800));
result.push(String.fromCharCode((next % 0x400) + 0xDC00));
}
}
return result.join('');
}
});
defineProperties(String.prototype, {
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
repeat: function(times) {
times = Number.toInteger(times);
if (times < 0 || times === Infinity) {
throw new RangeError();
}
if (times < 1) return '';
if (times % 2) return this.repeat(times - 1) + this;
var half = this.repeat(times / 2);
return half + half;
},
startsWith: function(searchString) {
var position = arguments[1];
var searchStr = searchString.toString();
var s = String(this);
var pos = (position === undefined) ? 0 : Number.toInteger(position);
var len = s.length;
var start = Math.min(Math.max(pos, 0), len);
var searchLength = searchString.length;
if ((searchLength + start) > len) return false;
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
endsWith: function(searchString) {
var endPosition = arguments[1];
var s = String(this);
var searchStr = searchString.toString();
var len = s.length;
var pos = (endPosition === undefined) ?
len : Number.toInteger(endPosition);
var end = Math.min(Math.max(pos, 0), len);
var searchLength = searchString.length;
var start = end - searchLength;
if (start < 0) return false;
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
contains: function(searchString) {
var position = arguments[1];
// Somehow this trick makes method 100% compat with the spec.
return ''.indexOf.call(this, searchString, position) !== -1;
},
codePointAt: function(pos) {
var s = String(this);
var position = Number.toInteger(pos);
var length = s.length;
if (position < 0 || position >= length) return undefined;
var first = s.charCodeAt(position);
var isEnd = (position + 1 === length);
if (first < 0xD800 || first > 0xDBFF || isEnd) return first;
var second = s.charCodeAt(position + 1);
if (second < 0xDC00 || second > 0xDFFF) return first;
return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
}
});
defineProperties(Array, {
from: function(iterable) {
var mapFn = arguments[1];
var thisArg = arguments[2];
var list = Object(iterable);
var length = ES.ToUint32(list.length);
var result = typeof this === 'function' ?
Object(new this(length)) : new Array(length);
for (var i = 0; i < length; i++) {
var value = list[i];
result[i] = mapFn ? mapFn.call(thisArg, value) : value;
}
result.length = length;
return result;
},
of: function() {
return Array.from(arguments);
}
});
defineProperties(Array.prototype, {
find: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return undefined;
if (typeof predicate !== 'function') {
throw new TypeError('Array#find: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return value;
}
return undefined;
},
findIndex: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return -1;
if (typeof predicate !== 'function') {
throw new TypeError('Array#findIndex: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return i;
}
return -1;
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740991,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
if (supportsDescriptors) {
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var addProperty = function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
};
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}
return result;
},
// 15.2.3.17
assign: function(target, source) {
return Object.keys(source).reduce(function(target, key) {
target[key] = source[key];
return target;
}, target);
},
// 15.2.3.18
mixin: function(target, source) {
var props = Object.getOwnPropertyNames(source);
return props.reduce(function(target, property) {
var descriptor = Object.getOwnPropertyDescriptor(source, property);
return Object.defineProperty(target, property, descriptor);
}, target);
}
});
}
defineProperties(Object, {
getOwnPropertyKeys: function(subject) {
return Object.keys(subject);
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical.
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return x !== x && y !== y;
}
});
defineProperties(Math, {
acosh: function(value) {
if (Number.isNaN(value) || value < 1) {
return NaN;
} else if (value === 1) {
return +0;
} else if (value === Infinity) {
return Infinity;
}
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity || value === -Infinity) {
return value;
}
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
if (Number.isNaN(value) || value < -1 || value > 1) {
return NaN;
} else if (value === -1) {
return -Infinity;
} else if (value === 1) {
return Infinity;
} else if (value === 0) {
return value;
}
return 0.5 * Math.log((1 + value) / (1 - value));
},
cbrt: function (value) {
if (value === 0) {
return value;
}
var negate = value < 0, result;
if (negate) { value = -value; }
result = Math.pow(value, 1/3);
return negate ? -result : result;
},
cosh: function(value) {
if (value === 0) { // +0 or -0
return 1;
} else if (value === Infinity || value === -Infinity) {
return value;
} else if (Number.isNaN(value)) {
return NaN;
}
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity) {
return Infinity;
} else if (value === -Infinity) {
return -1;
}
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
for (var j = 2, factorial = 1; j <= i; j++) {
factorial *= j;
}
result += Math.pow(value, i) / factorial;
}
return result;
},
hypot: function(x, y, z) {
var anyNaN = false;
var anyInfinity = false;
var allZero = true;
[x, y, z].some(function (num) {
if (Number.isNaN(num)) {
anyNaN = true;
} else if (num === Infinity || num === -Infinity) {
anyInfinity = true;
} else if (num !== 0) {
allZero = false;
}
return anyInfinity || anyNaN;
});
if (anyInfinity) {
return Infinity;
} else if (anyNaN) {
return NaN;
} else if (allZero) {
return 0;
}
if (x == null) x = 0;
if (y == null) y = 0;
if (z == null) z = 0;
return Math.sqrt(x * x + y * y + z * z);
},
log2: function(value) {
if (Number.isNaN(value) || value < 0) {
return NaN;
} else if (value === 0) {
return -Infinity;
} else if (value === 1) {
return 0;
} else if (value === Infinity) {
return Infinity;
}
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
if (Number.isNaN(value) || value < 0) {
return NaN;
} else if (value === 0) {
return -Infinity;
} else if (value === 1) {
return 0;
} else if (value === Infinity) {
return Infinity;
}
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
if (Number.isNaN(value) || value < -1) {
return NaN;
} else if (value === -1) {
return -Infinity;
} else if (value === 0) {
return value;
} else if (value === Infinity) {
return Infinity;
}
var result = 0;
var n = 50;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity || value === -Infinity) {
return value;
}
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity) {
return 1;
} else if (value === -Infinity) {
return -1;
}
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === Infinity || value === -Infinity) {
return value;
} else if (value === 0) {
return value;
}
return ~~value;
}
});
if (supportsDescriptors) {
// Map and Set require a true ES5 environment
defineProperties(globals, {
Map: (function() {
var indexOfIdentical = function(keys, key) {
for (var i = 0, length = keys.length; i < length; i++) {
if (Object.is(keys[i], key)) return i;
}
return -1;
};
function Map() {
if (!(this instanceof Map)) return new Map();
defineProperties(this, {
'_keys': [],
'_values': [],
'_size': 0
});
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this._size;
}).bind(this)
});
}
defineProperties(Map.prototype, {
get: function(key) {
var index = indexOfIdentical(this._keys, key);
return index < 0 ? undefined : this._values[index];
},
has: function(key) {
return indexOfIdentical(this._keys, key) >= 0;
},
set: function(key, value) {
var keys = this._keys;
var values = this._values;
var index = indexOfIdentical(keys, key);
if (index < 0) index = keys.length;
keys[index] = key;
values[index] = value;
this._size += 1;
},
'delete': function(key) {
var keys = this._keys;
var values = this._values;
var index = indexOfIdentical(keys, key);
if (index < 0) return false;
keys.splice(index, 1);
values.splice(index, 1);
this._size -= 1;
return true;
},
keys: function() {
return this._keys;
},
values: function() {
return this._values;
}
});
return Map;
})(),
Set: (function() {
function Set() {
if (!(this instanceof Set)) return new Set();
defineProperties(this, {'[[SetData]]': new Map()});
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this['[[SetData]]'].size;
}).bind(this)
});
}
defineProperties(Set.prototype, {
has: function(key) {
return this['[[SetData]]'].has(key);
},
add: function(key) {
this['[[SetData]]'].set(key, true);
},
'delete': function(key) {
return this['[[SetData]]']['delete'](key);
},
clear: function() {
Object.defineProperty(this, '[[SetData]]', {
configurable: true,
enumerable: false,
writable: true,
value: new Map()
});
}
});
return Set;
})()
});
}
};
if (typeof define === 'function' && typeof define.amd == 'object' && define.amd) {
define(main); // RequireJS
} else {
main(); // CommonJS and <script>
}
File diff suppressed because one or more lines are too long
+846
View File
@@ -0,0 +1,846 @@
// ES6-shim 0.8.0 (c) 2013 Paul Miller (paulmillr.com)
// ES6-shim may be freely distributed under the MIT license.
// For more details and documentation:
// https://github.com/paulmillr/es6-shim/
var arePropertyDescriptorsSupported = function () {
var attempt = function () {
Object.defineProperty({}, 'x', {});
return true;
};
var supported = false;
try { supported = attempt(); }
catch (e) { /* this is IE 8. */ }
return supported;
};
var main = function() {
'use strict';
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
// Define configurable, writable and non-enumerable props
// if they dont exist.
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
var method = map[name];
if (name in object) return;
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
} else {
object[name] = method;
}
});
};
var ES = {
ToInt32: function(x) {
return x >> 0;
},
ToUint32: function(x) {
return x >>> 0;
}
};
defineProperties(String, {
fromCodePoint: function() {
var points = arguments;
var result = [];
var next;
for (var i = 0, length = points.length; i < length; i++) {
next = Number(points[i]);
if (!Object.is(next, Number.toInteger(next)) ||
next < 0 || next > 0x10FFFF) {
throw new RangeError('Invalid code point ' + next);
}
if (next < 0x10000) {
result.push(String.fromCharCode(next));
} else {
next -= 0x10000;
result.push(String.fromCharCode((next >> 10) + 0xD800));
result.push(String.fromCharCode((next % 0x400) + 0xDC00));
}
}
return result.join('');
},
raw: function() {
var callSite = arguments[0];
var substitutions = Array.prototype.slice.call(arguments, 1);
var cooked = Object(callSite);
var rawValue = cooked.raw;
var raw = Object(rawValue);
var len = Object.keys(raw).length;
var literalsegments = ES.ToUint32(len);
if (literalsegments === 0) {
return '';
}
var stringElements = [];
var nextIndex = 0;
var nextKey, next, nextSeg, nextSub;
while (nextIndex < literalsegments) {
nextKey = String(nextIndex);
next = raw[nextKey];
nextSeg = String(next);
stringElements.push(nextSeg);
if (nextIndex + 1 >= literalsegments) {
break;
}
next = substitutions[nextKey];
if (typeof next === 'undefined') {
break;
}
nextSub = String(next);
stringElements.push(nextSub);
nextIndex++;
}
return stringElements.join('');
}
});
defineProperties(String.prototype, {
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
// alternative - return new Array(times + 1).join(s);
repeat: function(times) {
times = Number.toInteger(times);
if (times < 0 || times === Infinity) {
throw new RangeError();
}
var s = String(this);
if (times < 1) return '';
if (times % 2) return s.repeat(times - 1) + s;
var half = s.repeat(times / 2);
return half + half;
},
startsWith: function(searchString) {
var position = arguments[1];
var searchStr = searchString.toString();
var s = String(this);
var pos = (position === undefined) ? 0 : Number.toInteger(position);
var len = s.length;
var start = Math.min(Math.max(pos, 0), len);
var searchLength = searchString.length;
if ((searchLength + start) > len) return false;
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
endsWith: function(searchString) {
var endPosition = arguments[1];
var s = String(this);
var searchStr = searchString.toString();
var len = s.length;
var pos = (endPosition === undefined) ?
len : Number.toInteger(endPosition);
var end = Math.min(Math.max(pos, 0), len);
var searchLength = searchString.length;
var start = end - searchLength;
if (start < 0) return false;
var index = ''.indexOf.call(s, searchString, start);
return index === start;
},
contains: function(searchString) {
var position = arguments[1];
// Somehow this trick makes method 100% compat with the spec.
return ''.indexOf.call(this, searchString, position) !== -1;
},
codePointAt: function(pos) {
var s = String(this);
var position = Number.toInteger(pos);
var length = s.length;
if (position < 0 || position >= length) return undefined;
var first = s.charCodeAt(position);
var isEnd = (position + 1 === length);
if (first < 0xD800 || first > 0xDBFF || isEnd) return first;
var second = s.charCodeAt(position + 1);
if (second < 0xDC00 || second > 0xDFFF) return first;
return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
}
});
defineProperties(Array, {
from: function(iterable) {
var mapFn = arguments[1];
var thisArg = arguments[2];
var list = Object(iterable);
var length = ES.ToUint32(list.length);
var result = typeof this === 'function' ?
Object(new this(length)) : new Array(length);
for (var i = 0; i < length; i++) {
var value = list[i];
result[i] = mapFn ? mapFn.call(thisArg, value) : value;
}
result.length = length;
return result;
},
of: function() {
return Array.from(arguments);
}
});
defineProperties(Array.prototype, {
find: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return undefined;
if (typeof predicate !== 'function') {
throw new TypeError('Array#find: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return value;
}
return undefined;
},
findIndex: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return -1;
if (typeof predicate !== 'function') {
throw new TypeError('Array#findIndex: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return i;
}
return -1;
}
});
defineProperties(Number, {
MAX_INTEGER: 9007199254740991,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isInteger: function(value) {
return Number.isFinite(value) &&
value >= -9007199254740992 && value <= Number.MAX_INTEGER &&
Math.floor(value) === value;
},
isNaN: function(value) {
return Object.is(value, NaN);
},
toInteger: function(value) {
var number = +value;
if (Object.is(number, NaN)) return +0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
if (supportsDescriptors) {
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var addProperty = function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
};
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}
return result;
},
// 15.2.3.17
assign: function(target, source) {
return Object.keys(source).reduce(function(target, key) {
target[key] = source[key];
return target;
}, target);
},
// 15.2.3.18
mixin: function(target, source) {
var props = Object.getOwnPropertyNames(source);
return props.reduce(function(target, property) {
var descriptor = Object.getOwnPropertyDescriptor(source, property);
return Object.defineProperty(target, property, descriptor);
}, target);
}
});
// 15.2.3.2
// shim from https://gist.github.com/WebReflection/5593554
defineProperties(Object, {
setPrototypeOf: (function(Object, magic) {
var set;
var checkArgs = function(O, proto) {
if (typeof O !== 'object' || O === null) {
throw new TypeError('can not set prototype on a non-object');
}
if (typeof proto !== 'object' && proto !== null) {
throw new TypeError('can only set prototype to an object or null');
}
};
var setPrototypeOf = function(O, proto) {
checkArgs(O, proto);
set.call(O, proto);
return O;
};
try {
// this works already in Firefox and Safari
set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
set.call({}, null);
} catch (e) {
if (Object.prototype !== {}[magic]) {
// IE < 11 cannot be shimmed
return;
}
// probably Chrome or some old Mobile stock browser
set = function(proto) {
this[magic] = proto;
};
// please note that this will **not** work
// in those browsers that do not inherit
// __proto__ by mistake from Object.prototype
// in these cases we should probably throw an error
// or at least be informed about the issue
setPrototypeOf.polyfill = setPrototypeOf(
setPrototypeOf({}, null),
Object.prototype
) instanceof Object;
// setPrototypeOf.polyfill === true means it works as meant
// setPrototypeOf.polyfill === false means it's not 100% reliable
// setPrototypeOf.polyfill === undefined
// or
// setPrototypeOf.polyfill == null means it's not a polyfill
// which means it works as expected
// we can even delete Object.prototype.__proto__;
}
return setPrototypeOf;
})(Object, '__proto__')
});
}
defineProperties(Object, {
getOwnPropertyKeys: function(subject) {
return Object.keys(subject);
},
is: function(x, y) {
if (x === y) {
// 0 === -0, but they are not identical.
if (x === 0) {
return 1 / x === 1 / y;
} else {
return true;
}
}
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is a NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return x !== x && y !== y;
}
});
defineProperties(Math, {
acosh: function(value) {
if (Number.isNaN(value) || value < 1) {
return NaN;
} else if (value === 1) {
return +0;
} else if (value === Infinity) {
return Infinity;
}
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity || value === -Infinity) {
return value;
}
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
if (Number.isNaN(value) || value < -1 || value > 1) {
return NaN;
} else if (value === -1) {
return -Infinity;
} else if (value === 1) {
return Infinity;
} else if (value === 0) {
return value;
}
return 0.5 * Math.log((1 + value) / (1 - value));
},
cbrt: function (value) {
if (value === 0) {
return value;
}
var negate = value < 0, result;
if (negate) { value = -value; }
result = Math.pow(value, 1/3);
return negate ? -result : result;
},
cosh: function(value) {
if (value === 0) { // +0 or -0
return 1;
} else if (value === Infinity || value === -Infinity) {
return value;
} else if (Number.isNaN(value)) {
return NaN;
}
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity) {
return Infinity;
} else if (value === -Infinity) {
return -1;
}
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
for (var j = 2, factorial = 1; j <= i; j++) {
factorial *= j;
}
result += Math.pow(value, i) / factorial;
}
return result;
},
hypot: function(x, y, z) {
var anyNaN = false;
var anyInfinity = false;
var allZero = true;
[x, y, z].some(function (num) {
if (Number.isNaN(num)) {
anyNaN = true;
} else if (num === Infinity || num === -Infinity) {
anyInfinity = true;
} else if (num !== 0) {
allZero = false;
}
return anyInfinity || anyNaN;
});
if (anyInfinity) {
return Infinity;
} else if (anyNaN) {
return NaN;
} else if (allZero) {
return 0;
}
if (x == null) x = 0;
if (y == null) y = 0;
if (z == null) z = 0;
return Math.sqrt(x * x + y * y + z * z);
},
log2: function(value) {
if (Number.isNaN(value) || value < 0) {
return NaN;
} else if (value === 0) {
return -Infinity;
} else if (value === 1) {
return 0;
} else if (value === Infinity) {
return Infinity;
}
return Math.log(value) * (1 / Math.LN2);
},
log10: function(value) {
if (Number.isNaN(value) || value < 0) {
return NaN;
} else if (value === 0) {
return -Infinity;
} else if (value === 1) {
return 0;
} else if (value === Infinity) {
return Infinity;
}
return Math.log(value) * (1 / Math.LN10);
},
log1p: function(value) {
if (Number.isNaN(value) || value < -1) {
return NaN;
} else if (value === -1) {
return -Infinity;
} else if (value === 0) {
return value;
} else if (value === Infinity) {
return Infinity;
}
var result = 0;
var n = 50;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Object.is(number, NaN)) return number;
return (number < 0) ? -1 : 1;
},
sinh: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity || value === -Infinity) {
return value;
}
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === 0) {
return value;
} else if (value === Infinity) {
return 1;
} else if (value === -Infinity) {
return -1;
}
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
if (Number.isNaN(value)) {
return NaN;
} else if (value === Infinity || value === -Infinity) {
return value;
} else if (value === 0) {
return value;
}
return ~~value;
}
});
if (supportsDescriptors) {
// Map and Set require a true ES5 environment
var collectionShims = {
Map: (function() {
var empty = {};
function MapEntry(key, value) {
this.key = key;
this.value = value;
this.next = null;
}
MapEntry.prototype.isRemoved = function () {
return this.key === empty;
};
function MapIterator(map, kind) {
this.i = map._head;
this.kind = kind;
}
MapIterator.prototype = {
next: function () {
var i = this.i;
if (i !== null) {
while (i.isRemoved()) {
i = i.next;
}
i = i.next;
this.i = i;
}
if (i === null) {
throw new Error();
}
var kind = this.kind;
if (kind === "key") {
return i.key;
}
if (kind === "value") {
return i.value;
}
return [i.key, i.value];
}
};
function Map() {
if (!(this instanceof Map)) return new Map();
var head = new MapEntry(null, null);
defineProperties(this, {
'_head': head,
'_size': 0
});
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this._size;
}).bind(this)
});
}
defineProperties(Map.prototype, {
get: function(key) {
var i = this._head;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
return i.value;
}
}
return undefined;
},
has: function(key) {
var i = this._head;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
return true;
}
}
return false;
},
set: function(key, value) {
var i = this._head;
var p = i;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
i.value = value;
return;
}
p = i;
}
var entry = new MapEntry(key, value);
p.next = entry;
this._size += 1;
},
'delete': function(key) {
var i = this._head;
var p = i;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
p.next = i.next;
i.key = empty;
i.value = empty;
i.next = p;
this._size -= 1;
return true;
}
p = i;
}
return false;
},
clear: function () {
var p = this._head;
var i = p.next;
this._size = 0;
p.next = null;
while (i !== null) {
var x = i.next;
i.key = empty;
i.value = empty;
i.next = p;
i = x;
}
},
keys: function() {
return new MapIterator(this, "key");
},
values: function() {
return new MapIterator(this, "value");
},
entries: function() {
return new MapIterator(this, "key+value");
},
forEach: function(callback) {
var context = arguments.length > 1 ? arguments[1] : null;
var entireMap = this;
var i = this._head;
while ((i = i.next) !== null) {
callback.call(context, i.value, i.key, entireMap);
while (i.isRemoved()) {
i = i.next;
}
}
}
});
return Map;
})(),
Set: (function() {
var SetShim = function Set() {
if (!(this instanceof SetShim)) return new SetShim();
defineProperties(this, {'[[SetData]]': new Map()});
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this['[[SetData]]'].size;
}).bind(this)
});
}
defineProperties(SetShim.prototype, {
has: function(key) {
return this['[[SetData]]'].has(key);
},
add: function(key) {
return this['[[SetData]]'].set(key, key);
},
'delete': function(key) {
return this['[[SetData]]']['delete'](key);
},
clear: function() {
return this['[[SetData]]'].clear();
},
keys: function() {
return this['[[SetData]]'].keys();
},
values: function() {
return this['[[SetData]]'].values();
},
entries: function() {
return this['[[SetData]]'].entries();
},
forEach: function (callback) {
var context = arguments.length > 1 ? arguments[1] : null;
var entireSet = this;
this['[[SetData]]'].forEach(function (value, key) {
callback.call(context, key, key, entireSet);
});
}
});
return SetShim;
})()
};
defineProperties(globals, collectionShims);
if (globals.Map || globals.Set) {
/*
- In Firefox < 23, Map#size is a function.
- In all current Firefox, Set#entries/keys/values & Map#clear do not exist
- https://bugzilla.mozilla.org/show_bug.cgi?id=869996
*/
var hasNoMapClear = typeof globals.Map.prototype.clear !== 'function';
var setSizeIsFunc = typeof (new globals.Set()).size !== 0;
var mapSizeIsFunc = typeof (new globals.Map()).size !== 0;
var hasNoSetKeys = typeof Set.prototype.keys !== 'function';
if (hasNoMapClear || setSizeIsFunc || mapSizeIsFunc || hasNoSetKeys) {
globals.Map = collectionShims.Map;
globals.Set = collectionShims.Set;
}
}
}
};
if (typeof define === 'function' && typeof define.amd == 'object' && define.amd) {
define(main); // RequireJS
} else {
main(); // CommonJS and <script>
}
File diff suppressed because one or more lines are too long
+857
View File
@@ -0,0 +1,857 @@
// ES6-shim 0.9.0 (c) 2013 Paul Miller (paulmillr.com)
// ES6-shim may be freely distributed under the MIT license.
// For more details and documentation:
// https://github.com/paulmillr/es6-shim/
(function(undefined) {
'use strict';
var arePropertyDescriptorsSupported = function() {
try {
Object.defineProperty({}, 'x', {});
return true;
} catch (e) { /* this is IE 8. */
return false;
}
};
var main = function() {
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
var _slice = Array.prototype.slice;
var _indexOf = String.prototype.indexOf;
var _toString = Object.prototype.toString;
// Define configurable, writable and non-enumerable props
// if they dont exist.
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
var method = map[name];
if (name in object) return;
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
} else {
object[name] = method;
}
});
};
var ES = {
ToInt32: function(x) {
return x >> 0;
},
ToUint32: function(x) {
return x >>> 0;
},
toInteger: function(value) {
var number = +value;
if (Number.isNaN(number)) return 0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
};
defineProperties(String, {
fromCodePoint: function() {
var points = _slice.call(arguments, 0);
var result = [];
var next;
for (var i = 0, length = points.length; i < length; i++) {
next = Number(points[i]);
if (!Object.is(next, ES.toInteger(next)) ||
next < 0 || next > 0x10FFFF) {
throw new RangeError('Invalid code point ' + next);
}
if (next < 0x10000) {
result.push(String.fromCharCode(next));
} else {
next -= 0x10000;
result.push(String.fromCharCode((next >> 10) + 0xD800));
result.push(String.fromCharCode((next % 0x400) + 0xDC00));
}
}
return result.join('');
},
raw: function() {
var callSite = arguments[0];
var substitutions = _slice.call(arguments, 1);
var cooked = Object(callSite);
var rawValue = cooked.raw;
var raw = Object(rawValue);
var len = Object.keys(raw).length;
var literalsegments = ES.ToUint32(len);
if (literalsegments === 0) {
return '';
}
var stringElements = [];
var nextIndex = 0;
var nextKey, next, nextSeg, nextSub;
while (nextIndex < literalsegments) {
nextKey = String(nextIndex);
next = raw[nextKey];
nextSeg = String(next);
stringElements.push(nextSeg);
if (nextIndex + 1 >= literalsegments) {
break;
}
next = substitutions[nextKey];
if (next === undefined) {
break;
}
nextSub = String(next);
stringElements.push(nextSub);
nextIndex++;
}
return stringElements.join('');
}
});
defineProperties(String.prototype, {
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
// Perf: http://jsperf.com/string-repeat2/2
repeat: (function() {
var repeat = function(s, times) {
if (times < 1) return '';
if (times % 2) return repeat(s, times - 1) + s;
var half = repeat(s, times / 2);
return half + half;
};
return function(times) {
times = ES.toInteger(times);
if (times < 0 || times === Infinity) {
throw new RangeError();
}
return repeat(String(this), times);
};
})(),
startsWith: function(searchStr) {
if (this == null) throw new TypeError("Cannot call method 'startsWith' of " + this);
var thisStr = String(this);
searchStr = String(searchStr);
var start = Math.max(ES.toInteger(arguments[1]), 0);
return thisStr.slice(start, start + searchStr.length) === searchStr;
},
endsWith: function(searchStr) {
if (this == null) throw new TypeError("Cannot call method 'endsWith' of " + this);
var thisStr = String(this);
searchStr = String(searchStr);
var thisLen = thisStr.length;
var pos = (arguments[1] === undefined) ?
thisLen : ES.toInteger(arguments[1]);
var end = Math.min(pos, thisLen);
return thisStr.slice(end - searchStr.length, end) === searchStr;
},
contains: function(searchString) {
var position = arguments[1];
// Somehow this trick makes method 100% compat with the spec.
return _indexOf.call(this, searchString, position) !== -1;
},
codePointAt: function(pos) {
var s = String(this);
var position = ES.toInteger(pos);
var length = s.length;
if (position < 0 || position >= length) return undefined;
var first = s.charCodeAt(position);
var isEnd = (position + 1 === length);
if (first < 0xD800 || first > 0xDBFF || isEnd) return first;
var second = s.charCodeAt(position + 1);
if (second < 0xDC00 || second > 0xDFFF) return first;
return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
}
});
defineProperties(Array, {
from: function(iterable) {
var mapFn = arguments[1];
var thisArg = arguments[2];
if (mapFn !== undefined && _toString.call(mapFn) !== '[object Function]') {
throw new TypeError('when provided, the second argument must be a function');
}
var list = Object(iterable);
var length = ES.ToUint32(list.length);
var result = typeof this === 'function' ? Object(new this(length)) : new Array(length);
for (var i = 0; i < length; i++) {
var value = list[i];
if (mapFn !== undefined) {
result[i] = thisArg ? mapFn.call(thisArg, value) : mapFn(value);
} else {
result[i] = value;
}
}
result.length = length;
return result;
},
of: function() {
return Array.from(arguments);
}
});
defineProperties(globals, {
ArrayIterator: function(array, kind) {
this.i = 0;
this.array = array;
this.kind = kind;
}
});
defineProperties(ArrayIterator.prototype, {
next: function() {
var i = this.i;
this.i = i + 1;
var array = this.array;
if (i >= array.length) {
throw new Error();
}
if (array.hasOwnProperty(i)) {
var kind = this.kind;
var retval;
if (kind === "key") {
retval = i;
}
if (kind === "value") {
retval = array[i];
}
if (kind === "entry") {
retval = [i, array[i]];
}
} else {
retval = this.next();
}
return retval;
}
});
defineProperties(Array.prototype, {
fill: function(value) {
var len = this.length;
var start = arguments.length > 1 ? ES.toInteger(arguments[1]) : 0;
var end = arguments.length > 2 ? ES.toInteger(arguments[2]) : len;
var relativeStart = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
for (var i = relativeStart; i < len && i < end; ++i) {
this[i] = value;
}
return this;
},
find: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return undefined;
if (typeof predicate !== 'function') {
throw new TypeError('Array#find: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return value;
}
return undefined;
},
findIndex: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return -1;
if (typeof predicate !== 'function') {
throw new TypeError('Array#findIndex: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return i;
}
return -1;
},
keys: function() {
return new ArrayIterator(this, "key");
},
values: function() {
return new ArrayIterator(this, "value");
},
entries: function() {
return new ArrayIterator(this, "entry");
}
});
defineProperties(Number, {
MAX_SAFE_INTEGER: Math.pow(2, 53) - 1,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isSafeInteger: function(value) {
return typeof value === 'number' &&
!Number.isNaN(value) &&
Number.isFinite(value) &&
parseInt(value, 10) === value &&
Math.abs(value) <= Number.MAX_SAFE_INTEGER;
},
isNaN: function(value) {
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return value !== value;
},
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
if (supportsDescriptors) {
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var addProperty = function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
};
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}
return result;
},
// 15.2.3.17
assign: function(target, source) {
return Object.keys(source).reduce(function(target, key) {
target[key] = source[key];
return target;
}, target);
},
// 15.2.3.18
mixin: function(target, source) {
var props = Object.getOwnPropertyNames(source);
return props.reduce(function(target, property) {
var descriptor = Object.getOwnPropertyDescriptor(source, property);
return Object.defineProperty(target, property, descriptor);
}, target);
}
});
// 15.2.3.2
// shim from https://gist.github.com/WebReflection/5593554
defineProperties(Object, {
setPrototypeOf: (function(Object, magic) {
var set;
var checkArgs = function(O, proto) {
if (typeof O !== 'object' || O === null) {
throw new TypeError('cannot set prototype on a non-object');
}
if (typeof proto !== 'object') {
throw new TypeError('can only set prototype to an object or null');
}
};
var setPrototypeOf = function(O, proto) {
checkArgs(O, proto);
set.call(O, proto);
return O;
};
try {
// this works already in Firefox and Safari
set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
set.call({}, null);
} catch (e) {
if (Object.prototype !== {}[magic]) {
// IE < 11 cannot be shimmed
return;
}
// probably Chrome or some old Mobile stock browser
set = function(proto) {
this[magic] = proto;
};
// please note that this will **not** work
// in those browsers that do not inherit
// __proto__ by mistake from Object.prototype
// in these cases we should probably throw an error
// or at least be informed about the issue
setPrototypeOf.polyfill = setPrototypeOf(
setPrototypeOf({}, null),
Object.prototype
) instanceof Object;
// setPrototypeOf.polyfill === true means it works as meant
// setPrototypeOf.polyfill === false means it's not 100% reliable
// setPrototypeOf.polyfill === undefined
// or
// setPrototypeOf.polyfill == null means it's not a polyfill
// which means it works as expected
// we can even delete Object.prototype.__proto__;
}
return setPrototypeOf;
})(Object, '__proto__')
});
}
defineProperties(Object, {
getOwnPropertyKeys: function(subject) {
return Object.keys(subject);
},
is: function(a, b) {
if (a === b) {
// 0 === -0, but they are not identical.
if (a === 0) return 1 / a === 1 / b;
return true;
}
return Number.isNaN(a) && Number.isNaN(b);
}
});
defineProperties(Math, {
acosh: function(value) {
value = Number(value);
if (Number.isNaN(value) || value < 1) return NaN;
if (value === 1) return 0;
if (value === Infinity) return value;
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
value = Number(value);
if (value === 0 || !global_isFinite(value)) {
return value;
}
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
value = Number(value);
if (Number.isNaN(value) || value < -1 || value > 1) {
return NaN;
}
if (value === -1) return -Infinity;
if (value === 1) return Infinity;
if (value === 0) return value;
return 0.5 * Math.log((1 + value) / (1 - value));
},
cbrt: function(value) {
value = Number(value);
if (value === 0) return value;
var negate = value < 0, result;
if (negate) value = -value;
result = Math.pow(value, 1/3);
return negate ? -result : result;
},
cosh: function(value) {
value = Number(value);
if (value === 0) return 1; // +0 or -0
if (!global_isFinite(value)) return value;
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
value = Number(value);
if (value === -Infinity) return -1;
if (!global_isFinite(value) || value === 0) return value;
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
for (var j = 2, factorial = 1; j <= i; j++) {
factorial *= j;
}
result += Math.pow(value, i) / factorial;
}
return result;
},
hypot: function(x, y) {
var anyNaN = false;
var allZero = true;
var z = arguments.length > 2 ? arguments[2] : 0;
if ([x, y, z].some(function(num) {
if (Number.isNaN(num)) anyNaN = true;
else if (num === Infinity || num === -Infinity) return true;
else if (num !== 0) allZero = false;
})) return Infinity;
if (anyNaN) return NaN;
if (allZero) return 0;
if (x == null) x = 0;
if (y == null) y = 0;
if (z == null) z = 0;
return Math.sqrt(x * x + y * y + z * z);
},
log2: function(value) {
return Math.log(value) * Math.LOG2E;
},
log10: function(value) {
return Math.log(value) * Math.LOG10E;
},
log1p: function(value) {
value = Number(value);
if (value < -1 || Number.isNaN(value)) return NaN;
if (value === 0 || value === Infinity) return value;
if (value === -1) return -Infinity;
var result = 0;
var n = 50;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Number.isNaN(number)) return number;
return number < 0 ? -1 : 1;
},
sinh: function(value) {
value = Number(value);
if (!global_isFinite(value) || value === 0) return value;
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
value = Number(value);
if (Number.isNaN(value) || value === 0) return value;
if (value === Infinity) return 1;
if (value === -Infinity) return -1;
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
var number = Number(value);
return number < 0 ? -Math.floor(-number) : Math.floor(number);
},
imul: function(x, y) {
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
var ah = (x >>> 16) & 0xffff;
var al = x & 0xffff;
var bh = (y >>> 16) & 0xffff;
var bl = y & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
}
});
if (supportsDescriptors) {
// Map and Set require a true ES5 environment
var collectionShims = {
Map: (function() {
var empty = {};
function MapEntry(key, value) {
this.key = key;
this.value = value;
this.next = null;
}
MapEntry.prototype.isRemoved = function() {
return this.key === empty;
};
function MapIterator(map, kind) {
this.i = map._head;
this.kind = kind;
}
MapIterator.prototype = {
next: function() {
var i = this.i;
if (i !== null) {
while (i.isRemoved()) {
i = i.next;
}
i = i.next;
this.i = i;
}
if (i === null) {
throw new Error();
}
var kind = this.kind;
if (kind === "key") {
return i.key;
}
if (kind === "value") {
return i.value;
}
return [i.key, i.value];
}
};
function Map() {
if (!(this instanceof Map)) throw new TypeError('Map must be called with "new"');
var head = new MapEntry(null, null);
defineProperties(this, {
'_head': head,
'_size': 0
});
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this._size;
}).bind(this)
});
}
defineProperties(Map.prototype, {
get: function(key) {
var i = this._head;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
return i.value;
}
}
return undefined;
},
has: function(key) {
var i = this._head;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
return true;
}
}
return false;
},
set: function(key, value) {
var i = this._head;
var p = i;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
i.value = value;
return;
}
p = i;
}
var entry = new MapEntry(key, value);
p.next = entry;
this._size += 1;
},
'delete': function(key) {
var i = this._head;
var p = i;
while ((i = i.next) !== null) {
if (Object.is(i.key, key)) {
p.next = i.next;
i.key = empty;
i.value = empty;
i.next = p;
this._size -= 1;
return true;
}
p = i;
}
return false;
},
clear: function() {
var p = this._head;
var i = p.next;
this._size = 0;
p.next = null;
while (i !== null) {
var x = i.next;
i.key = empty;
i.value = empty;
i.next = p;
i = x;
}
},
keys: function() {
return new MapIterator(this, "key");
},
values: function() {
return new MapIterator(this, "value");
},
entries: function() {
return new MapIterator(this, "key+value");
},
forEach: function(callback) {
var context = arguments.length > 1 ? arguments[1] : null;
var entireMap = this;
var i = this._head;
while ((i = i.next) !== null) {
callback.call(context, i.value, i.key, entireMap);
while (i.isRemoved()) {
i = i.next;
}
}
}
});
return Map;
})(),
Set: (function() {
var SetShim = function Set() {
if (!(this instanceof SetShim)) throw new TypeError('Set must be called with "new"');
defineProperties(this, {'[[SetData]]': new Map()});
Object.defineProperty(this, 'size', {
configurable: true,
enumerable: false,
get: (function() {
return this['[[SetData]]'].size;
}).bind(this)
});
};
defineProperties(SetShim.prototype, {
has: function(key) {
return this['[[SetData]]'].has(key);
},
add: function(key) {
return this['[[SetData]]'].set(key, key);
},
'delete': function(key) {
return this['[[SetData]]']['delete'](key);
},
clear: function() {
return this['[[SetData]]'].clear();
},
keys: function() {
return this['[[SetData]]'].keys();
},
values: function() {
return this['[[SetData]]'].values();
},
entries: function() {
return this['[[SetData]]'].entries();
},
forEach: function(callback) {
var context = arguments.length > 1 ? arguments[1] : null;
var entireSet = this;
this['[[SetData]]'].forEach(function(value, key) {
callback.call(context, key, key, entireSet);
});
}
});
return SetShim;
})()
};
defineProperties(globals, collectionShims);
if (globals.Map || globals.Set) {
/*
- In Firefox < 23, Map#size is a function.
- In all current Firefox, Set#entries/keys/values & Map#clear do not exist
- https://bugzilla.mozilla.org/show_bug.cgi?id=869996
*/
if (
typeof globals.Map.prototype.clear !== 'function' ||
new globals.Set().size !== 0 ||
new globals.Map().size !== 0 ||
typeof globals.Set.prototype.keys !== 'function'
) {
globals.Map = collectionShims.Map;
globals.Set = collectionShims.Set;
}
}
}
};
if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
define(main); // RequireJS
} else {
main(); // CommonJS and <script>
}
})();
File diff suppressed because one or more lines are too long
+996
View File
@@ -0,0 +1,996 @@
// ES6-shim 0.9.1 (c) 2013 Paul Miller (http://paulmillr.com)
// ES6-shim may be freely distributed under the MIT license.
// For more details and documentation:
// https://github.com/paulmillr/es6-shim/
(function(undefined) {
'use strict';
var arePropertyDescriptorsSupported = function() {
try {
Object.defineProperty({}, 'x', {});
return true;
} catch (e) { /* this is IE 8. */
return false;
}
};
var main = function() {
var globals = (typeof global === 'undefined') ? window : global;
var global_isFinite = globals.isFinite;
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
var _slice = Array.prototype.slice;
var _indexOf = String.prototype.indexOf;
var _toString = Object.prototype.toString;
var _hasOwnProperty = Object.prototype.hasOwnProperty;
// Define configurable, writable and non-enumerable props
// if they dont exist.
var defineProperties = function(object, map) {
Object.keys(map).forEach(function(name) {
var method = map[name];
if (name in object) return;
if (supportsDescriptors) {
Object.defineProperty(object, name, {
configurable: true,
enumerable: false,
writable: true,
value: method
});
} else {
object[name] = method;
}
});
};
var ES = {
ToInt32: function(x) {
return x >> 0;
},
ToUint32: function(x) {
return x >>> 0;
},
toInteger: function(value) {
var number = +value;
if (Number.isNaN(number)) return 0;
if (number === 0 || !Number.isFinite(number)) return number;
return Math.sign(number) * Math.floor(Math.abs(number));
}
};
defineProperties(String, {
fromCodePoint: function() {
var points = _slice.call(arguments, 0);
var result = [];
var next;
for (var i = 0, length = points.length; i < length; i++) {
next = Number(points[i]);
if (!Object.is(next, ES.toInteger(next)) ||
next < 0 || next > 0x10FFFF) {
throw new RangeError('Invalid code point ' + next);
}
if (next < 0x10000) {
result.push(String.fromCharCode(next));
} else {
next -= 0x10000;
result.push(String.fromCharCode((next >> 10) + 0xD800));
result.push(String.fromCharCode((next % 0x400) + 0xDC00));
}
}
return result.join('');
},
raw: function() {
var callSite = arguments[0];
var substitutions = _slice.call(arguments, 1);
var cooked = Object(callSite);
var rawValue = cooked.raw;
var raw = Object(rawValue);
var len = Object.keys(raw).length;
var literalsegments = ES.ToUint32(len);
if (literalsegments === 0) {
return '';
}
var stringElements = [];
var nextIndex = 0;
var nextKey, next, nextSeg, nextSub;
while (nextIndex < literalsegments) {
nextKey = String(nextIndex);
next = raw[nextKey];
nextSeg = String(next);
stringElements.push(nextSeg);
if (nextIndex + 1 >= literalsegments) {
break;
}
next = substitutions[nextKey];
if (next === undefined) {
break;
}
nextSub = String(next);
stringElements.push(nextSub);
nextIndex++;
}
return stringElements.join('');
}
});
defineProperties(String.prototype, {
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
// Perf: http://jsperf.com/string-repeat2/2
repeat: (function() {
var repeat = function(s, times) {
if (times < 1) return '';
if (times % 2) return repeat(s, times - 1) + s;
var half = repeat(s, times / 2);
return half + half;
};
return function(times) {
times = ES.toInteger(times);
if (times < 0 || times === Infinity) {
throw new RangeError();
}
return repeat(String(this), times);
};
})(),
startsWith: function(searchStr) {
if (this == null) throw new TypeError("Cannot call method 'startsWith' of " + this);
var thisStr = String(this);
searchStr = String(searchStr);
var start = Math.max(ES.toInteger(arguments[1]), 0);
return thisStr.slice(start, start + searchStr.length) === searchStr;
},
endsWith: function(searchStr) {
if (this == null) throw new TypeError("Cannot call method 'endsWith' of " + this);
var thisStr = String(this);
searchStr = String(searchStr);
var thisLen = thisStr.length;
var pos = (arguments[1] === undefined) ?
thisLen : ES.toInteger(arguments[1]);
var end = Math.min(pos, thisLen);
return thisStr.slice(end - searchStr.length, end) === searchStr;
},
contains: function(searchString) {
var position = arguments[1];
// Somehow this trick makes method 100% compat with the spec.
return _indexOf.call(this, searchString, position) !== -1;
},
codePointAt: function(pos) {
var s = String(this);
var position = ES.toInteger(pos);
var length = s.length;
if (position < 0 || position >= length) return undefined;
var first = s.charCodeAt(position);
var isEnd = (position + 1 === length);
if (first < 0xD800 || first > 0xDBFF || isEnd) return first;
var second = s.charCodeAt(position + 1);
if (second < 0xDC00 || second > 0xDFFF) return first;
return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
}
});
defineProperties(Array, {
from: function(iterable) {
var mapFn = arguments[1];
var thisArg = arguments[2];
if (mapFn !== undefined && _toString.call(mapFn) !== '[object Function]') {
throw new TypeError('when provided, the second argument must be a function');
}
var list = Object(iterable);
var length = ES.ToUint32(list.length);
var result = typeof this === 'function' ? Object(new this(length)) : new Array(length);
for (var i = 0; i < length; i++) {
var value = list[i];
if (mapFn !== undefined) {
result[i] = thisArg ? mapFn.call(thisArg, value) : mapFn(value);
} else {
result[i] = value;
}
}
result.length = length;
return result;
},
of: function() {
return Array.from(arguments);
}
});
defineProperties(globals, {
ArrayIterator: function(array, kind) {
this.i = 0;
this.array = array;
this.kind = kind;
}
});
defineProperties(ArrayIterator.prototype, {
next: function() {
var i = this.i;
this.i = i + 1;
var array = this.array;
if (i >= array.length) {
throw new Error();
}
if (array.hasOwnProperty(i)) {
var kind = this.kind;
var retval;
if (kind === "key") {
retval = i;
}
if (kind === "value") {
retval = array[i];
}
if (kind === "entry") {
retval = [i, array[i]];
}
} else {
retval = this.next();
}
return retval;
}
});
defineProperties(Array.prototype, {
copyWithin: function(target, start) {
var o = Object(this);
var len = Math.max(ES.toInteger(o.length), 0);
var to = target < 0 ? Math.max(len + target, 0) : Math.min(target, len);
var from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
var end = arguments.length > 2 ? arguments[2] : len;
var final = end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
var count = Math.min(final - from, len - to);
var direction = 1;
if (from < to && to < (from + count)) {
direction = -1;
from += count - 1;
to += count - 1;
}
while (count > 0) {
if (_hasOwnProperty.call(o, from)) {
o[to] = o[from];
} else {
delete o[from];
}
from += direction;
to += direction;
count -= 1;
}
return o;
},
fill: function(value) {
var len = this.length;
var start = arguments.length > 1 ? ES.toInteger(arguments[1]) : 0;
var end = arguments.length > 2 ? ES.toInteger(arguments[2]) : len;
var relativeStart = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
for (var i = relativeStart; i < len && i < end; ++i) {
this[i] = value;
}
return this;
},
find: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return undefined;
if (typeof predicate !== 'function') {
throw new TypeError('Array#find: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return value;
}
return undefined;
},
findIndex: function(predicate) {
var list = Object(this);
var length = ES.ToUint32(list.length);
if (length === 0) return -1;
if (typeof predicate !== 'function') {
throw new TypeError('Array#findIndex: predicate must be a function');
}
var thisArg = arguments[1];
for (var i = 0, value; i < length && i in list; i++) {
value = list[i];
if (predicate.call(thisArg, value, i, list)) return i;
}
return -1;
},
keys: function() {
return new ArrayIterator(this, "key");
},
values: function() {
return new ArrayIterator(this, "value");
},
entries: function() {
return new ArrayIterator(this, "entry");
}
});
var maxSafeInteger = Math.pow(2, 53) - 1;
defineProperties(Number, {
MAX_SAFE_INTEGER: maxSafeInteger,
MIN_SAFE_INTEGER: -maxSafeInteger,
EPSILON: 2.220446049250313e-16,
parseInt: globals.parseInt,
parseFloat: globals.parseFloat,
isFinite: function(value) {
return typeof value === 'number' && global_isFinite(value);
},
isSafeInteger: function(value) {
return typeof value === 'number' &&
!Number.isNaN(value) &&
Number.isFinite(value) &&
parseInt(value, 10) === value &&
Math.abs(value) <= Number.MAX_SAFE_INTEGER;
},
isNaN: function(value) {
// NaN !== NaN, but they are identical.
// NaNs are the only non-reflexive value, i.e., if x !== x,
// then x is NaN.
// isNaN is broken: it converts its argument to number, so
// isNaN('foo') => true
return value !== value;
},
});
defineProperties(Number.prototype, {
clz: function() {
var number = +this;
if (!number || !Number.isFinite(number)) return 32;
number = number < 0 ? Math.ceil(number) : Math.floor(number);
number = number - Math.floor(number / 0x100000000) * 0x100000000;
return 32 - (number).toString(2).length;
}
});
if (supportsDescriptors) {
defineProperties(Object, {
getOwnPropertyDescriptors: function(subject) {
var descs = {};
Object.getOwnPropertyNames(subject).forEach(function(propName) {
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
});
return descs;
},
getPropertyDescriptor: function(subject, name) {
var pd = Object.getOwnPropertyDescriptor(subject, name);
var proto = Object.getPrototypeOf(subject);
while (pd === undefined && proto !== null) {
pd = Object.getOwnPropertyDescriptor(proto, name);
proto = Object.getPrototypeOf(proto);
}
return pd;
},
getPropertyNames: function(subject) {
var result = Object.getOwnPropertyNames(subject);
var proto = Object.getPrototypeOf(subject);
var addProperty = function(property) {
if (result.indexOf(property) === -1) {
result.push(property);
}
};
while (proto !== null) {
Object.getOwnPropertyNames(proto).forEach(addProperty);
proto = Object.getPrototypeOf(proto);
}
return result;
},
// 19.1.3.1
assign: function(target, source) {
return Object.keys(source).reduce(function(target, key) {
target[key] = source[key];
return target;
}, target);
},
// 19.1.3.15
mixin: function(target, source) {
var props = Object.getOwnPropertyNames(source);
return props.reduce(function(target, property) {
var descriptor = Object.getOwnPropertyDescriptor(source, property);
return Object.defineProperty(target, property, descriptor);
}, target);
}
});
// 19.1.3.9
// shim from https://gist.github.com/WebReflection/5593554
defineProperties(Object, {
setPrototypeOf: (function(Object, magic) {
var set;
var checkArgs = function(O, proto) {
if (typeof O !== 'object' || O === null) {
throw new TypeError('cannot set prototype on a non-object');
}
if (typeof proto !== 'object') {
throw new TypeError('can only set prototype to an object or null');
}
};
var setPrototypeOf = function(O, proto) {
checkArgs(O, proto);
set.call(O, proto);
return O;
};
try {
// this works already in Firefox and Safari
set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
set.call({}, null);
} catch (e) {
if (Object.prototype !== {}[magic]) {
// IE < 11 cannot be shimmed
return;
}
// probably Chrome or some old Mobile stock browser
set = function(proto) {
this[magic] = proto;
};
// please note that this will **not** work
// in those browsers that do not inherit
// __proto__ by mistake from Object.prototype
// in these cases we should probably throw an error
// or at least be informed about the issue
setPrototypeOf.polyfill = setPrototypeOf(
setPrototypeOf({}, null),
Object.prototype
) instanceof Object;
// setPrototypeOf.polyfill === true means it works as meant
// setPrototypeOf.polyfill === false means it's not 100% reliable
// setPrototypeOf.polyfill === undefined
// or
// setPrototypeOf.polyfill == null means it's not a polyfill
// which means it works as expected
// we can even delete Object.prototype.__proto__;
}
return setPrototypeOf;
})(Object, '__proto__')
});
}
defineProperties(Object, {
getOwnPropertyKeys: function(subject) {
return Object.keys(subject);
},
is: function(a, b) {
if (a === b) {
// 0 === -0, but they are not identical.
if (a === 0) return 1 / a === 1 / b;
return true;
}
return Number.isNaN(a) && Number.isNaN(b);
}
});
defineProperties(Math, {
acosh: function(value) {
value = Number(value);
if (Number.isNaN(value) || value < 1) return NaN;
if (value === 1) return 0;
if (value === Infinity) return value;
return Math.log(value + Math.sqrt(value * value - 1));
},
asinh: function(value) {
value = Number(value);
if (value === 0 || !global_isFinite(value)) {
return value;
}
return Math.log(value + Math.sqrt(value * value + 1));
},
atanh: function(value) {
value = Number(value);
if (Number.isNaN(value) || value < -1 || value > 1) {
return NaN;
}
if (value === -1) return -Infinity;
if (value === 1) return Infinity;
if (value === 0) return value;
return 0.5 * Math.log((1 + value) / (1 - value));
},
cbrt: function(value) {
value = Number(value);
if (value === 0) return value;
var negate = value < 0, result;
if (negate) value = -value;
result = Math.pow(value, 1/3);
return negate ? -result : result;
},
cosh: function(value) {
value = Number(value);
if (value === 0) return 1; // +0 or -0
if (!global_isFinite(value)) return value;
if (value < 0) value = -value;
if (value > 21) return Math.exp(value) / 2;
return (Math.exp(value) + Math.exp(-value)) / 2;
},
expm1: function(value) {
value = Number(value);
if (value === -Infinity) return -1;
if (!global_isFinite(value) || value === 0) return value;
var result = 0;
var n = 50;
for (var i = 1; i < n; i++) {
for (var j = 2, factorial = 1; j <= i; j++) {
factorial *= j;
}
result += Math.pow(value, i) / factorial;
}
return result;
},
hypot: function(x, y) {
var anyNaN = false;
var allZero = true;
var anyInfinity = false;
var numbers = [];
Array.prototype.every.call(arguments, function(arg) {
var num = Number(arg);
if (Number.isNaN(num)) anyNaN = true;
else if (num === Infinity || num === -Infinity) anyInfinity = true;
else if (num !== 0) allZero = false;
if (anyInfinity) {
return false;
} else if (!anyNaN) {
numbers.push(Math.abs(num));
}
return true;
});
if (anyInfinity) return Infinity;
if (anyNaN) return NaN;
if (allZero) return 0;
numbers.sort(function (a, b) { return b - a; });
var largest = numbers[0];
var divided = numbers.map(function (number) { return number / largest; });
var sum = divided.reduce(function (sum, number) { return sum += number * number; }, 0);
return largest * Math.sqrt(sum);
},
log2: function(value) {
return Math.log(value) * Math.LOG2E;
},
log10: function(value) {
return Math.log(value) * Math.LOG10E;
},
log1p: function(value) {
value = Number(value);
if (value < -1 || Number.isNaN(value)) return NaN;
if (value === 0 || value === Infinity) return value;
if (value === -1) return -Infinity;
var result = 0;
var n = 50;
if (value < 0 || value > 1) return Math.log(1 + value);
for (var i = 1; i < n; i++) {
if ((i % 2) === 0) {
result -= Math.pow(value, i) / i;
} else {
result += Math.pow(value, i) / i;
}
}
return result;
},
sign: function(value) {
var number = +value;
if (number === 0) return number;
if (Number.isNaN(number)) return number;
return number < 0 ? -1 : 1;
},
sinh: function(value) {
value = Number(value);
if (!global_isFinite(value) || value === 0) return value;
return (Math.exp(value) - Math.exp(-value)) / 2;
},
tanh: function(value) {
value = Number(value);
if (Number.isNaN(value) || value === 0) return value;
if (value === Infinity) return 1;
if (value === -Infinity) return -1;
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
},
trunc: function(value) {
var number = Number(value);
return number < 0 ? -Math.floor(-number) : Math.floor(number);
},
imul: function(x, y) {
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
var ah = (x >>> 16) & 0xffff;
var al = x & 0xffff;
var bh = (y >>> 16) & 0xffff;
var bl = y & 0xffff;
// the shift by 0 fixes the sign on the high part
// the final |0 converts the unsigned value into a signed value
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
}
});
// Map and Set require a true ES5 environment
if (supportsDescriptors) {
var fastkey = function fastkey(key) {
var type = typeof key;
if (type === 'string') {
return '$' + key;
} else if (type === 'number' && !Object.is(key, -0)) {
return key;
}
return null;
};
var emptyObject = function emptyObject() {
// accomodate some older not-quite-ES5 browsers
return Object.create ? Object.create(null) : {};
};
var collectionShims = {
Map: (function() {
var empty = {};
function MapEntry(key, value) {
this.key = key;
this.value = value;
this.next = null;
this.prev = null;
}
MapEntry.prototype.isRemoved = function() {
return this.key === empty;
};
function MapIterator(map, kind) {
this.head = map._head;
this.i = this.head.next;
this.kind = kind;
}
MapIterator.prototype = {
next: function() {
var i = this.i, kind = this.kind, head = this.head, result;
while (i !== head) {
this.i = i.next;
if (!i.isRemoved()) {
if (kind === "key") {
result = i.key;
} else if (kind === "value") {
result = i.value;
} else {
result = [i.key, i.value];
}
return { value: result, done: false };
}
i = this.i;
}
return { value: undefined, done: true };
}
};
function Map() {
if (!(this instanceof Map)) throw new TypeError('Map must be called with "new"');
var head = new MapEntry(null, null);
// circular doubly-linked list.
head.next = head.prev = head;
defineProperties(this, {
'_head': head,
'_storage': emptyObject(),
'_size': 0
});
}
Object.defineProperty(Map.prototype, 'size', {
configurable: true,
enumerable: false,
get: function() {
return this._size;
}
});
defineProperties(Map.prototype, {
get: function(key) {
var fkey = fastkey(key);
if (fkey !== null) {
// fast O(1) path
var entry = this._storage[fkey];
return entry ? entry.value : undefined;
}
var head = this._head, i = head;
while ((i = i.next) !== head) {
if (Object.is(i.key, key)) {
return i.value;
}
}
return undefined;
},
has: function(key) {
var fkey = fastkey(key);
if (fkey !== null) {
// fast O(1) path
return fkey in this._storage;
}
var head = this._head, i = head;
while ((i = i.next) !== head) {
if (Object.is(i.key, key)) {
return true;
}
}
return false;
},
set: function(key, value) {
var head = this._head, i = head, entry;
var fkey = fastkey(key);
if (fkey !== null) {
// fast O(1) path
if (fkey in this._storage) {
this._storage[fkey].value = value;
return;
} else {
entry = this._storage[fkey] = new MapEntry(key, value);
i = head.prev;
// fall through
}
}
while ((i = i.next) !== head) {
if (Object.is(i.key, key)) {
i.value = value;
return;
}
}
entry = entry ? entry : new MapEntry(key, value);
entry.next = this._head;
entry.prev = this._head.prev;
entry.prev.next = entry;
entry.next.prev = entry;
this._size += 1;
},
'delete': function(key) {
var head = this._head, i = head;
var fkey = fastkey(key);
if (fkey !== null) {
// fast O(1) path
if (!(fkey in this._storage)) {
return false;
}
i = this._storage[fkey].prev;
delete this._storage[fkey];
// fall through
}
while ((i = i.next) !== head) {
if (Object.is(i.key, key)) {
i.key = i.value = empty;
i.prev.next = i.next;
i.next.prev = i.prev;
this._size -= 1;
return true;
}
}
return false;
},
clear: function() {
this._size = 0;
this._storage = emptyObject();
var head = this._head, i = head, p = i.next;
while ((i = p) !== head) {
i.key = i.value = empty;
p = i.next;
i.next = i.prev = head;
}
head.next = head.prev = head;
},
keys: function() {
return new MapIterator(this, "key");
},
values: function() {
return new MapIterator(this, "value");
},
entries: function() {
return new MapIterator(this, "key+value");
},
forEach: function(callback) {
var context = arguments.length > 1 ? arguments[1] : null;
var entireMap = this;
var head = this._head, i = head;
while ((i = i.next) !== head) {
if (!i.isRemoved()) {
callback.call(context, i.value, i.key, entireMap);
}
}
}
});
return Map;
})(),
Set: (function() {
// Creating a Map is expensive. To speed up the common case of
// Sets containing only string or numeric keys, we use an object
// as backing storage and lazily create a full Map only when
// required.
var SetShim = function Set() {
if (!(this instanceof SetShim)) throw new TypeError('Set must be called with "new"');
defineProperties(this, {
'[[SetData]]': null,
'_storage': emptyObject()
});
};
// Switch from the object backing storage to a full Map.
var ensureMap = function ensureMap(set) {
if (!set['[[SetData]]']) {
var m = set['[[SetData]]'] = new collectionShims.Map();
Object.keys(set._storage).forEach(function(k) {
// fast check for leading '$'
if (k.charCodeAt(0) === 36) {
k = k.substring(1);
} else {
k = +k;
}
m.set(k, k);
});
set._storage = null; // free old backing storage
}
};
Object.defineProperty(SetShim.prototype, 'size', {
configurable: true,
enumerable: false,
get: function() {
ensureMap(this);
return this['[[SetData]]'].size;
}
});
defineProperties(SetShim.prototype, {
has: function(key) {
var fkey;
if (this._storage && (fkey = fastkey(key)) !== null) {
return !!this._storage[fkey];
}
ensureMap(this);
return this['[[SetData]]'].has(key);
},
add: function(key) {
var fkey;
if (this._storage && (fkey = fastkey(key)) !== null) {
this._storage[fkey]=true;
return;
}
ensureMap(this);
return this['[[SetData]]'].set(key, key);
},
'delete': function(key) {
var fkey;
if (this._storage && (fkey = fastkey(key)) !== null) {
delete this._storage[fkey];
return;
}
ensureMap(this);
return this['[[SetData]]']['delete'](key);
},
clear: function() {
if (this._storage) {
this._storage = emptyObject();
return;
}
return this['[[SetData]]'].clear();
},
keys: function() {
ensureMap(this);
return this['[[SetData]]'].keys();
},
values: function() {
ensureMap(this);
return this['[[SetData]]'].values();
},
entries: function() {
ensureMap(this);
return this['[[SetData]]'].entries();
},
forEach: function(callback) {
var context = arguments.length > 1 ? arguments[1] : null;
var entireSet = this;
ensureMap(this);
this['[[SetData]]'].forEach(function(value, key) {
callback.call(context, key, key, entireSet);
});
}
});
return SetShim;
})()
};
defineProperties(globals, collectionShims);
if (globals.Map || globals.Set) {
/*
- In Firefox < 23, Map#size is a function.
- In all current Firefox, Set#entries/keys/values & Map#clear do not exist
- https://bugzilla.mozilla.org/show_bug.cgi?id=869996
- In Firefox 24, Map and Set do not implement forEach
*/
if (
typeof globals.Map.prototype.clear !== 'function' ||
new globals.Set().size !== 0 ||
new globals.Map().size !== 0 ||
typeof globals.Set.prototype.keys !== 'function' ||
typeof globals.Map.prototype.forEach !== 'function' ||
typeof globals.Set.prototype.forEach !== 'function'
) {
globals.Map = collectionShims.Map;
globals.Set = collectionShims.Set;
}
}
}
};
if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
define(main); // RequireJS
} else {
main(); // CommonJS and <script>
}
})();
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+1 -1
View File
@@ -2,7 +2,7 @@
"name": "es6-shim",
"author": "Paul Miller (http://paulmillr.com)",
"filename": "es6-shim.min.js",
"version": "0.11.0",
"version": "0.16.0",
"description": "ECMAScript 6 (Harmony) compatibility shims for legacy JavaScript engines",
"keywords": [
"ecmascript",