UNPKG

1.73 kBJavaScriptView Raw
1// Polyfills
2
3if ( Number.EPSILON === undefined ) {
4
5 Number.EPSILON = Math.pow( 2, - 52 );
6
7}
8
9if ( Number.isInteger === undefined ) {
10
11 // Missing in IE
12 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number/isInteger
13
14 Number.isInteger = function ( value ) {
15
16 return typeof value === 'number' && isFinite( value ) && Math.floor( value ) === value;
17
18 };
19
20}
21
22//
23
24if ( Math.sign === undefined ) {
25
26 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/sign
27
28 Math.sign = function ( x ) {
29
30 return ( x < 0 ) ? - 1 : ( x > 0 ) ? 1 : + x;
31
32 };
33
34}
35
36if ( 'name' in Function.prototype === false ) {
37
38 // Missing in IE
39 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/name
40
41 Object.defineProperty( Function.prototype, 'name', {
42
43 get: function () {
44
45 return this.toString().match( /^\s*function\s*([^\(\s]*)/ )[ 1 ];
46
47 }
48
49 } );
50
51}
52
53if ( Object.assign === undefined ) {
54
55 // Missing in IE
56 // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign
57
58 ( function () {
59
60 Object.assign = function ( target ) {
61
62 'use strict';
63
64 if ( target === undefined || target === null ) {
65
66 throw new TypeError( 'Cannot convert undefined or null to object' );
67
68 }
69
70 var output = Object( target );
71
72 for ( var index = 1; index < arguments.length; index ++ ) {
73
74 var source = arguments[ index ];
75
76 if ( source !== undefined && source !== null ) {
77
78 for ( var nextKey in source ) {
79
80 if ( Object.prototype.hasOwnProperty.call( source, nextKey ) ) {
81
82 output[ nextKey ] = source[ nextKey ];
83
84 }
85
86 }
87
88 }
89
90 }
91
92 return output;
93
94 };
95
96 } )();
97
98}