ende 0.2.9 → 0.2.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/assets/javascripts/aura/extensions/devise.js.coffee +2 -2
- data/lib/assets/javascripts/widgets/viewer/main.js.coffee +1 -1
- data/lib/ende/version.rb +1 -1
- data/vendor/assets/components/build.js +638 -133
- data/vendor/components/indefinido-indemma/.gitignore +14 -0
- data/vendor/components/indefinido-indemma/.gitignore~ +2 -0
- data/vendor/components/indefinido-indemma/.ruby-gemset +1 -0
- data/vendor/components/indefinido-indemma/.ruby-version +1 -0
- data/vendor/components/indefinido-indemma/Gemfile +13 -0
- data/vendor/components/indefinido-indemma/Guardfile +39 -0
- data/vendor/components/indefinido-indemma/History.md +0 -0
- data/vendor/components/indefinido-indemma/Readme.md +447 -0
- data/vendor/components/indefinido-indemma/build/development.js +340 -0
- data/vendor/components/indefinido-indemma/build/release.js +22039 -0
- data/vendor/components/indefinido-indemma/build/test.js +22039 -0
- data/vendor/components/indefinido-indemma/component.json +7 -3
- data/vendor/components/indefinido-indemma/components/chaijs-assertion-error/component.json +18 -0
- data/vendor/components/indefinido-indemma/components/chaijs-assertion-error/index.js +110 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/component.json +47 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/index.js +1 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/assertion.js +130 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/core/assertions.js +1270 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/interface/assert.js +1080 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/interface/expect.js +12 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/interface/should.js +76 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addChainableMethod.js +94 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addMethod.js +37 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/addProperty.js +40 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/eql.js +129 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/flag.js +32 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getActual.js +19 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getEnumerableProperties.js +25 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getMessage.js +49 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getName.js +20 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getPathValue.js +102 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/getProperties.js +35 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/index.js +108 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/inspect.js +320 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/objDisplay.js +48 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/overwriteMethod.js +51 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/overwriteProperty.js +54 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/test.js +26 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/transferFlags.js +44 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai/utils/type.js +45 -0
- data/vendor/components/indefinido-indemma/components/chaijs-chai/lib/chai.js +80 -0
- data/vendor/components/indefinido-indemma/components/component-bind/component.json +14 -0
- data/vendor/components/indefinido-indemma/components/component-bind/index.js +24 -0
- data/vendor/components/indefinido-indemma/components/component-jquery/component.json +14 -0
- data/vendor/components/indefinido-indemma/components/component-jquery/index.js +9601 -0
- data/vendor/components/indefinido-indemma/components/component-type/component.json +18 -0
- data/vendor/components/indefinido-indemma/components/component-type/index.js +32 -0
- data/vendor/components/indefinido-indemma/components/indefinido-advisable/component.json +21 -0
- data/vendor/components/indefinido-indemma/components/indefinido-advisable/index.js +1 -0
- data/vendor/components/indefinido-indemma/components/indefinido-advisable/lib/advisable.js +60 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/component.json +25 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/components/cjohansen-sinon/sinon.js +4290 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/index.js +1 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/lib/adapters/rivets.js +26 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/lib/observable.js +323 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/accessors-legacy.js +92 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/accessors.js +173 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/array.indexOf.js +8 -0
- data/vendor/components/indefinido-indemma/components/indefinido-observable/vendor/shims/object.create.js +77 -0
- data/vendor/components/indefinido-indemma/components/kapit-observe-utils/component.json +13 -0
- data/vendor/components/indefinido-indemma/components/paulmillr-es6-shim/component.json +17 -0
- data/vendor/components/indefinido-indemma/components/paulmillr-es6-shim/es6-shim.js +996 -0
- data/vendor/components/indefinido-indemma/components/pluma-assimilate/component.json +25 -0
- data/vendor/components/indefinido-indemma/components/pluma-assimilate/dist/assimilate.js +127 -0
- data/vendor/components/indefinido-indemma/karma.conf.js +86 -0
- data/vendor/components/indefinido-indemma/lib/record/associable.js +229 -82
- data/vendor/components/indefinido-indemma/lib/record/errors.js +1 -0
- data/vendor/components/indefinido-indemma/lib/record/persistable.js +32 -0
- data/vendor/components/indefinido-indemma/lib/record/queryable.js +32 -0
- data/vendor/components/indefinido-indemma/lib/record/resource.js +12 -4
- data/vendor/components/indefinido-indemma/lib/record/rest.js +1 -1
- data/vendor/components/indefinido-indemma/lib/record/restfulable.js +38 -27
- data/vendor/components/indefinido-indemma/lib/record/scopable.js +15 -2
- data/vendor/components/indefinido-indemma/lib/record/storable.js +48 -0
- data/vendor/components/indefinido-indemma/lib/record/validatable.js +10 -5
- data/vendor/components/indefinido-indemma/lib/record/validations/cpf.js +1 -1
- data/vendor/components/indefinido-indemma/lib/record.js +15 -12
- data/vendor/components/indefinido-indemma/spec/record/associable_spec.js +137 -0
- data/vendor/components/indefinido-indemma/spec/record/persistable_spec.js +36 -0
- data/vendor/components/indefinido-indemma/spec/record/queryable_spec.js +33 -0
- data/vendor/components/indefinido-indemma/spec/record/resource_spec.js +93 -0
- data/vendor/components/indefinido-indemma/spec/record/rest_spec.js +32 -0
- data/vendor/components/indefinido-indemma/spec/record/restfulable_spec.js +288 -0
- data/vendor/components/indefinido-indemma/spec/record/scopable_spec.js +212 -0
- data/vendor/components/indefinido-indemma/spec/record/storable_spec.js +53 -0
- data/vendor/components/indefinido-indemma/spec/record/translationable.js +28 -0
- data/vendor/components/indefinido-indemma/spec/record/validatable_spec.js +111 -0
- data/vendor/components/indefinido-indemma/spec/record/validations/associated_spec.js +43 -0
- data/vendor/components/indefinido-indemma/spec/record/validations/confirmation_spec.js +36 -0
- data/vendor/components/indefinido-indemma/spec/record/validations/cpf_spec.js +35 -0
- data/vendor/components/indefinido-indemma/spec/record/validations/presence_spec.js +28 -0
- data/vendor/components/indefinido-indemma/spec/record/validations/remote_spec.js +87 -0
- data/vendor/components/indefinido-indemma/spec/record/validations/type_spec.js +48 -0
- data/vendor/components/indefinido-indemma/spec/record_spec.js +37 -0
- data/vendor/components/indefinido-indemma/spec/spec_helper.js +11 -0
- data/vendor/components/indefinido-indemma/spec/support/value_objects/phone.js +45 -0
- data/vendor/components/indefinido-indemma/src/lib/extensions/rivets.coffee +17 -0
- data/vendor/components/indefinido-indemma/src/lib/record/associable.coffee +342 -0
- data/vendor/components/indefinido-indemma/src/lib/record/errors.coffee +20 -0
- data/vendor/components/indefinido-indemma/src/lib/record/maid.coffee +16 -0
- data/vendor/components/indefinido-indemma/src/lib/record/persistable.coffee +27 -0
- data/vendor/components/indefinido-indemma/src/lib/record/queryable.coffee +29 -0
- data/vendor/components/indefinido-indemma/src/lib/record/resource.coffee +106 -0
- data/vendor/components/indefinido-indemma/src/lib/record/rest.coffee +28 -0
- data/vendor/components/indefinido-indemma/src/lib/record/restfulable.coffee +348 -0
- data/vendor/components/indefinido-indemma/src/lib/record/scopable.coffee +275 -0
- data/vendor/components/indefinido-indemma/src/lib/record/storable.coffee +46 -0
- data/vendor/components/indefinido-indemma/src/lib/record/translationable.coffee +18 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validatable.coffee +217 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validations/associated.coffee +32 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validations/confirmation.coffee +19 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validations/cpf.coffee +58 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validations/presence.coffee +19 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validations/remote.coffee +65 -0
- data/vendor/components/indefinido-indemma/src/lib/record/validations/type.coffee +32 -0
- data/vendor/components/indefinido-indemma/src/lib/record.coffee +136 -0
- data/vendor/components/indefinido-indemma/src/spec/record/associable_spec.coffee +130 -0
- data/vendor/components/indefinido-indemma/src/spec/record/persistable_spec.coffee +30 -0
- data/vendor/components/indefinido-indemma/src/spec/record/queryable_spec.coffee +27 -0
- data/vendor/components/indefinido-indemma/src/spec/record/resource_spec.coffee +69 -0
- data/vendor/components/indefinido-indemma/src/spec/record/rest_spec.coffee +22 -0
- data/vendor/components/indefinido-indemma/src/spec/record/restfulable_spec.coffee +207 -0
- data/vendor/components/indefinido-indemma/src/spec/record/scopable_spec.coffee +191 -0
- data/vendor/components/indefinido-indemma/src/spec/record/storable_spec.coffee +40 -0
- data/vendor/components/indefinido-indemma/src/spec/record/translationable.coffee +19 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validatable_spec.coffee +100 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validations/associated_spec.coffee +35 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validations/confirmation_spec.coffee +25 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validations/cpf_spec.coffee +28 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validations/presence_spec.coffee +24 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validations/remote_spec.coffee +74 -0
- data/vendor/components/indefinido-indemma/src/spec/record/validations/type_spec.coffee +33 -0
- data/vendor/components/indefinido-indemma/src/spec/record_spec.coffee +23 -0
- data/vendor/components/indefinido-indemma/src/spec/spec_helper.coffee +9 -0
- data/vendor/components/indefinido-indemma/src/spec/support/value_objects/phone.coffee +30 -0
- data/vendor/components/indefinido-indemma/vendor/object/mixin.js +196 -0
- data/vendor/components/indefinido-indemma/vendor/owl/pluralize.js +190 -0
- metadata +130 -2
|
@@ -0,0 +1,996 @@
|
|
|
1
|
+
// ES6-shim 0.9.1 (c) 2013 Paul Miller (http://paulmillr.com)
|
|
2
|
+
// ES6-shim may be freely distributed under the MIT license.
|
|
3
|
+
// For more details and documentation:
|
|
4
|
+
// https://github.com/paulmillr/es6-shim/
|
|
5
|
+
|
|
6
|
+
(function(undefined) {
|
|
7
|
+
'use strict';
|
|
8
|
+
|
|
9
|
+
var arePropertyDescriptorsSupported = function() {
|
|
10
|
+
try {
|
|
11
|
+
Object.defineProperty({}, 'x', {});
|
|
12
|
+
return true;
|
|
13
|
+
} catch (e) { /* this is IE 8. */
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
var main = function() {
|
|
19
|
+
var globals = (typeof global === 'undefined') ? window : global;
|
|
20
|
+
var global_isFinite = globals.isFinite;
|
|
21
|
+
var supportsDescriptors = !!Object.defineProperty && arePropertyDescriptorsSupported();
|
|
22
|
+
var _slice = Array.prototype.slice;
|
|
23
|
+
var _indexOf = String.prototype.indexOf;
|
|
24
|
+
var _toString = Object.prototype.toString;
|
|
25
|
+
var _hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
26
|
+
|
|
27
|
+
// Define configurable, writable and non-enumerable props
|
|
28
|
+
// if they don’t exist.
|
|
29
|
+
var defineProperties = function(object, map) {
|
|
30
|
+
Object.keys(map).forEach(function(name) {
|
|
31
|
+
var method = map[name];
|
|
32
|
+
if (name in object) return;
|
|
33
|
+
if (supportsDescriptors) {
|
|
34
|
+
Object.defineProperty(object, name, {
|
|
35
|
+
configurable: true,
|
|
36
|
+
enumerable: false,
|
|
37
|
+
writable: true,
|
|
38
|
+
value: method
|
|
39
|
+
});
|
|
40
|
+
} else {
|
|
41
|
+
object[name] = method;
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
var ES = {
|
|
47
|
+
ToInt32: function(x) {
|
|
48
|
+
return x >> 0;
|
|
49
|
+
},
|
|
50
|
+
|
|
51
|
+
ToUint32: function(x) {
|
|
52
|
+
return x >>> 0;
|
|
53
|
+
},
|
|
54
|
+
|
|
55
|
+
toInteger: function(value) {
|
|
56
|
+
var number = +value;
|
|
57
|
+
if (Number.isNaN(number)) return 0;
|
|
58
|
+
if (number === 0 || !Number.isFinite(number)) return number;
|
|
59
|
+
return Math.sign(number) * Math.floor(Math.abs(number));
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
defineProperties(String, {
|
|
64
|
+
fromCodePoint: function() {
|
|
65
|
+
var points = _slice.call(arguments, 0);
|
|
66
|
+
var result = [];
|
|
67
|
+
var next;
|
|
68
|
+
for (var i = 0, length = points.length; i < length; i++) {
|
|
69
|
+
next = Number(points[i]);
|
|
70
|
+
if (!Object.is(next, ES.toInteger(next)) ||
|
|
71
|
+
next < 0 || next > 0x10FFFF) {
|
|
72
|
+
throw new RangeError('Invalid code point ' + next);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
if (next < 0x10000) {
|
|
76
|
+
result.push(String.fromCharCode(next));
|
|
77
|
+
} else {
|
|
78
|
+
next -= 0x10000;
|
|
79
|
+
result.push(String.fromCharCode((next >> 10) + 0xD800));
|
|
80
|
+
result.push(String.fromCharCode((next % 0x400) + 0xDC00));
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
return result.join('');
|
|
84
|
+
},
|
|
85
|
+
|
|
86
|
+
raw: function() {
|
|
87
|
+
var callSite = arguments[0];
|
|
88
|
+
var substitutions = _slice.call(arguments, 1);
|
|
89
|
+
var cooked = Object(callSite);
|
|
90
|
+
var rawValue = cooked.raw;
|
|
91
|
+
var raw = Object(rawValue);
|
|
92
|
+
var len = Object.keys(raw).length;
|
|
93
|
+
var literalsegments = ES.ToUint32(len);
|
|
94
|
+
if (literalsegments === 0) {
|
|
95
|
+
return '';
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
var stringElements = [];
|
|
99
|
+
var nextIndex = 0;
|
|
100
|
+
var nextKey, next, nextSeg, nextSub;
|
|
101
|
+
while (nextIndex < literalsegments) {
|
|
102
|
+
nextKey = String(nextIndex);
|
|
103
|
+
next = raw[nextKey];
|
|
104
|
+
nextSeg = String(next);
|
|
105
|
+
stringElements.push(nextSeg);
|
|
106
|
+
if (nextIndex + 1 >= literalsegments) {
|
|
107
|
+
break;
|
|
108
|
+
}
|
|
109
|
+
next = substitutions[nextKey];
|
|
110
|
+
if (next === undefined) {
|
|
111
|
+
break;
|
|
112
|
+
}
|
|
113
|
+
nextSub = String(next);
|
|
114
|
+
stringElements.push(nextSub);
|
|
115
|
+
nextIndex++;
|
|
116
|
+
}
|
|
117
|
+
return stringElements.join('');
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
|
|
121
|
+
defineProperties(String.prototype, {
|
|
122
|
+
// Fast repeat, uses the `Exponentiation by squaring` algorithm.
|
|
123
|
+
// Perf: http://jsperf.com/string-repeat2/2
|
|
124
|
+
repeat: (function() {
|
|
125
|
+
var repeat = function(s, times) {
|
|
126
|
+
if (times < 1) return '';
|
|
127
|
+
if (times % 2) return repeat(s, times - 1) + s;
|
|
128
|
+
var half = repeat(s, times / 2);
|
|
129
|
+
return half + half;
|
|
130
|
+
};
|
|
131
|
+
|
|
132
|
+
return function(times) {
|
|
133
|
+
times = ES.toInteger(times);
|
|
134
|
+
if (times < 0 || times === Infinity) {
|
|
135
|
+
throw new RangeError();
|
|
136
|
+
}
|
|
137
|
+
return repeat(String(this), times);
|
|
138
|
+
};
|
|
139
|
+
})(),
|
|
140
|
+
|
|
141
|
+
startsWith: function(searchStr) {
|
|
142
|
+
if (this == null) throw new TypeError("Cannot call method 'startsWith' of " + this);
|
|
143
|
+
var thisStr = String(this);
|
|
144
|
+
searchStr = String(searchStr);
|
|
145
|
+
var start = Math.max(ES.toInteger(arguments[1]), 0);
|
|
146
|
+
return thisStr.substr(start, searchStr.length) === searchStr;
|
|
147
|
+
},
|
|
148
|
+
|
|
149
|
+
endsWith: function(searchStr) {
|
|
150
|
+
if (this == null) throw new TypeError("Cannot call method 'endsWith' of " + this);
|
|
151
|
+
var thisStr = String(this);
|
|
152
|
+
searchStr = String(searchStr);
|
|
153
|
+
var thisLen = thisStr.length;
|
|
154
|
+
var pos = (arguments[1] === undefined) ?
|
|
155
|
+
thisLen : ES.toInteger(arguments[1]);
|
|
156
|
+
var end = Math.min(pos, thisLen);
|
|
157
|
+
return thisStr.slice(end - searchStr.length, end) === searchStr;
|
|
158
|
+
},
|
|
159
|
+
|
|
160
|
+
contains: function(searchString) {
|
|
161
|
+
var position = arguments[1];
|
|
162
|
+
|
|
163
|
+
// Somehow this trick makes method 100% compat with the spec.
|
|
164
|
+
return _indexOf.call(this, searchString, position) !== -1;
|
|
165
|
+
},
|
|
166
|
+
|
|
167
|
+
codePointAt: function(pos) {
|
|
168
|
+
var s = String(this);
|
|
169
|
+
var position = ES.toInteger(pos);
|
|
170
|
+
var length = s.length;
|
|
171
|
+
if (position < 0 || position >= length) return undefined;
|
|
172
|
+
var first = s.charCodeAt(position);
|
|
173
|
+
var isEnd = (position + 1 === length);
|
|
174
|
+
if (first < 0xD800 || first > 0xDBFF || isEnd) return first;
|
|
175
|
+
var second = s.charCodeAt(position + 1);
|
|
176
|
+
if (second < 0xDC00 || second > 0xDFFF) return first;
|
|
177
|
+
return ((first - 0xD800) * 1024) + (second - 0xDC00) + 0x10000;
|
|
178
|
+
}
|
|
179
|
+
});
|
|
180
|
+
|
|
181
|
+
defineProperties(Array, {
|
|
182
|
+
from: function(iterable) {
|
|
183
|
+
var mapFn = arguments[1];
|
|
184
|
+
var thisArg = arguments[2];
|
|
185
|
+
|
|
186
|
+
if (mapFn !== undefined && _toString.call(mapFn) !== '[object Function]') {
|
|
187
|
+
throw new TypeError('when provided, the second argument must be a function');
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
var list = Object(iterable);
|
|
191
|
+
var length = ES.ToUint32(list.length);
|
|
192
|
+
var result = typeof this === 'function' ? Object(new this(length)) : new Array(length);
|
|
193
|
+
|
|
194
|
+
for (var i = 0; i < length; i++) {
|
|
195
|
+
var value = list[i];
|
|
196
|
+
if (mapFn !== undefined) {
|
|
197
|
+
result[i] = thisArg ? mapFn.call(thisArg, value) : mapFn(value);
|
|
198
|
+
} else {
|
|
199
|
+
result[i] = value;
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
result.length = length;
|
|
204
|
+
return result;
|
|
205
|
+
},
|
|
206
|
+
|
|
207
|
+
of: function() {
|
|
208
|
+
return Array.from(arguments);
|
|
209
|
+
}
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
defineProperties(globals, {
|
|
213
|
+
ArrayIterator: function(array, kind) {
|
|
214
|
+
this.i = 0;
|
|
215
|
+
this.array = array;
|
|
216
|
+
this.kind = kind;
|
|
217
|
+
}
|
|
218
|
+
});
|
|
219
|
+
|
|
220
|
+
defineProperties(ArrayIterator.prototype, {
|
|
221
|
+
next: function() {
|
|
222
|
+
var i = this.i;
|
|
223
|
+
this.i = i + 1;
|
|
224
|
+
var array = this.array;
|
|
225
|
+
|
|
226
|
+
if (i >= array.length) {
|
|
227
|
+
throw new Error();
|
|
228
|
+
}
|
|
229
|
+
|
|
230
|
+
if (array.hasOwnProperty(i)) {
|
|
231
|
+
var kind = this.kind;
|
|
232
|
+
var retval;
|
|
233
|
+
if (kind === "key") {
|
|
234
|
+
retval = i;
|
|
235
|
+
}
|
|
236
|
+
if (kind === "value") {
|
|
237
|
+
retval = array[i];
|
|
238
|
+
}
|
|
239
|
+
if (kind === "entry") {
|
|
240
|
+
retval = [i, array[i]];
|
|
241
|
+
}
|
|
242
|
+
} else {
|
|
243
|
+
retval = this.next();
|
|
244
|
+
}
|
|
245
|
+
return retval;
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
|
|
249
|
+
defineProperties(Array.prototype, {
|
|
250
|
+
copyWithin: function(target, start) {
|
|
251
|
+
var o = Object(this);
|
|
252
|
+
var len = Math.max(ES.toInteger(o.length), 0);
|
|
253
|
+
var to = target < 0 ? Math.max(len + target, 0) : Math.min(target, len);
|
|
254
|
+
var from = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
|
|
255
|
+
var end = arguments.length > 2 ? arguments[2] : len;
|
|
256
|
+
var final = end < 0 ? Math.max(len + end, 0) : Math.min(end, len);
|
|
257
|
+
var count = Math.min(final - from, len - to);
|
|
258
|
+
var direction = 1;
|
|
259
|
+
if (from < to && to < (from + count)) {
|
|
260
|
+
direction = -1;
|
|
261
|
+
from += count - 1;
|
|
262
|
+
to += count - 1;
|
|
263
|
+
}
|
|
264
|
+
while (count > 0) {
|
|
265
|
+
if (_hasOwnProperty.call(o, from)) {
|
|
266
|
+
o[to] = o[from];
|
|
267
|
+
} else {
|
|
268
|
+
delete o[from];
|
|
269
|
+
}
|
|
270
|
+
from += direction;
|
|
271
|
+
to += direction;
|
|
272
|
+
count -= 1;
|
|
273
|
+
}
|
|
274
|
+
return o;
|
|
275
|
+
},
|
|
276
|
+
fill: function(value) {
|
|
277
|
+
var len = this.length;
|
|
278
|
+
var start = arguments.length > 1 ? ES.toInteger(arguments[1]) : 0;
|
|
279
|
+
var end = arguments.length > 2 ? ES.toInteger(arguments[2]) : len;
|
|
280
|
+
|
|
281
|
+
var relativeStart = start < 0 ? Math.max(len + start, 0) : Math.min(start, len);
|
|
282
|
+
|
|
283
|
+
for (var i = relativeStart; i < len && i < end; ++i) {
|
|
284
|
+
this[i] = value;
|
|
285
|
+
}
|
|
286
|
+
return this;
|
|
287
|
+
},
|
|
288
|
+
|
|
289
|
+
find: function(predicate) {
|
|
290
|
+
var list = Object(this);
|
|
291
|
+
var length = ES.ToUint32(list.length);
|
|
292
|
+
if (length === 0) return undefined;
|
|
293
|
+
if (typeof predicate !== 'function') {
|
|
294
|
+
throw new TypeError('Array#find: predicate must be a function');
|
|
295
|
+
}
|
|
296
|
+
var thisArg = arguments[1];
|
|
297
|
+
for (var i = 0, value; i < length && i in list; i++) {
|
|
298
|
+
value = list[i];
|
|
299
|
+
if (predicate.call(thisArg, value, i, list)) return value;
|
|
300
|
+
}
|
|
301
|
+
return undefined;
|
|
302
|
+
},
|
|
303
|
+
|
|
304
|
+
findIndex: function(predicate) {
|
|
305
|
+
var list = Object(this);
|
|
306
|
+
var length = ES.ToUint32(list.length);
|
|
307
|
+
if (length === 0) return -1;
|
|
308
|
+
if (typeof predicate !== 'function') {
|
|
309
|
+
throw new TypeError('Array#findIndex: predicate must be a function');
|
|
310
|
+
}
|
|
311
|
+
var thisArg = arguments[1];
|
|
312
|
+
for (var i = 0, value; i < length && i in list; i++) {
|
|
313
|
+
value = list[i];
|
|
314
|
+
if (predicate.call(thisArg, value, i, list)) return i;
|
|
315
|
+
}
|
|
316
|
+
return -1;
|
|
317
|
+
},
|
|
318
|
+
|
|
319
|
+
keys: function() {
|
|
320
|
+
return new ArrayIterator(this, "key");
|
|
321
|
+
},
|
|
322
|
+
|
|
323
|
+
values: function() {
|
|
324
|
+
return new ArrayIterator(this, "value");
|
|
325
|
+
},
|
|
326
|
+
|
|
327
|
+
entries: function() {
|
|
328
|
+
return new ArrayIterator(this, "entry");
|
|
329
|
+
}
|
|
330
|
+
});
|
|
331
|
+
|
|
332
|
+
var maxSafeInteger = Math.pow(2, 53) - 1;
|
|
333
|
+
defineProperties(Number, {
|
|
334
|
+
MAX_SAFE_INTEGER: maxSafeInteger,
|
|
335
|
+
MIN_SAFE_INTEGER: -maxSafeInteger,
|
|
336
|
+
EPSILON: 2.220446049250313e-16,
|
|
337
|
+
|
|
338
|
+
parseInt: globals.parseInt,
|
|
339
|
+
parseFloat: globals.parseFloat,
|
|
340
|
+
|
|
341
|
+
isFinite: function(value) {
|
|
342
|
+
return typeof value === 'number' && global_isFinite(value);
|
|
343
|
+
},
|
|
344
|
+
|
|
345
|
+
isSafeInteger: function(value) {
|
|
346
|
+
return typeof value === 'number' &&
|
|
347
|
+
!Number.isNaN(value) &&
|
|
348
|
+
Number.isFinite(value) &&
|
|
349
|
+
parseInt(value, 10) === value &&
|
|
350
|
+
Math.abs(value) <= Number.MAX_SAFE_INTEGER;
|
|
351
|
+
},
|
|
352
|
+
|
|
353
|
+
isNaN: function(value) {
|
|
354
|
+
// NaN !== NaN, but they are identical.
|
|
355
|
+
// NaNs are the only non-reflexive value, i.e., if x !== x,
|
|
356
|
+
// then x is NaN.
|
|
357
|
+
// isNaN is broken: it converts its argument to number, so
|
|
358
|
+
// isNaN('foo') => true
|
|
359
|
+
return value !== value;
|
|
360
|
+
},
|
|
361
|
+
|
|
362
|
+
});
|
|
363
|
+
|
|
364
|
+
defineProperties(Number.prototype, {
|
|
365
|
+
clz: function() {
|
|
366
|
+
var number = +this;
|
|
367
|
+
if (!number || !Number.isFinite(number)) return 32;
|
|
368
|
+
number = number < 0 ? Math.ceil(number) : Math.floor(number);
|
|
369
|
+
number = number - Math.floor(number / 0x100000000) * 0x100000000;
|
|
370
|
+
return 32 - (number).toString(2).length;
|
|
371
|
+
}
|
|
372
|
+
});
|
|
373
|
+
|
|
374
|
+
if (supportsDescriptors) {
|
|
375
|
+
defineProperties(Object, {
|
|
376
|
+
getOwnPropertyDescriptors: function(subject) {
|
|
377
|
+
var descs = {};
|
|
378
|
+
Object.getOwnPropertyNames(subject).forEach(function(propName) {
|
|
379
|
+
descs[propName] = Object.getOwnPropertyDescriptor(subject, propName);
|
|
380
|
+
});
|
|
381
|
+
return descs;
|
|
382
|
+
},
|
|
383
|
+
|
|
384
|
+
getPropertyDescriptor: function(subject, name) {
|
|
385
|
+
var pd = Object.getOwnPropertyDescriptor(subject, name);
|
|
386
|
+
var proto = Object.getPrototypeOf(subject);
|
|
387
|
+
while (pd === undefined && proto !== null) {
|
|
388
|
+
pd = Object.getOwnPropertyDescriptor(proto, name);
|
|
389
|
+
proto = Object.getPrototypeOf(proto);
|
|
390
|
+
}
|
|
391
|
+
return pd;
|
|
392
|
+
},
|
|
393
|
+
|
|
394
|
+
getPropertyNames: function(subject) {
|
|
395
|
+
var result = Object.getOwnPropertyNames(subject);
|
|
396
|
+
var proto = Object.getPrototypeOf(subject);
|
|
397
|
+
|
|
398
|
+
var addProperty = function(property) {
|
|
399
|
+
if (result.indexOf(property) === -1) {
|
|
400
|
+
result.push(property);
|
|
401
|
+
}
|
|
402
|
+
};
|
|
403
|
+
|
|
404
|
+
while (proto !== null) {
|
|
405
|
+
Object.getOwnPropertyNames(proto).forEach(addProperty);
|
|
406
|
+
proto = Object.getPrototypeOf(proto);
|
|
407
|
+
}
|
|
408
|
+
return result;
|
|
409
|
+
},
|
|
410
|
+
|
|
411
|
+
// 19.1.3.1
|
|
412
|
+
assign: function(target, source) {
|
|
413
|
+
return Object.keys(source).reduce(function(target, key) {
|
|
414
|
+
target[key] = source[key];
|
|
415
|
+
return target;
|
|
416
|
+
}, target);
|
|
417
|
+
},
|
|
418
|
+
|
|
419
|
+
// 19.1.3.15
|
|
420
|
+
mixin: function(target, source) {
|
|
421
|
+
var props = Object.getOwnPropertyNames(source);
|
|
422
|
+
return props.reduce(function(target, property) {
|
|
423
|
+
var descriptor = Object.getOwnPropertyDescriptor(source, property);
|
|
424
|
+
return Object.defineProperty(target, property, descriptor);
|
|
425
|
+
}, target);
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
|
|
429
|
+
// 19.1.3.9
|
|
430
|
+
// shim from https://gist.github.com/WebReflection/5593554
|
|
431
|
+
defineProperties(Object, {
|
|
432
|
+
setPrototypeOf: (function(Object, magic) {
|
|
433
|
+
var set;
|
|
434
|
+
|
|
435
|
+
var checkArgs = function(O, proto) {
|
|
436
|
+
if (typeof O !== 'object' || O === null) {
|
|
437
|
+
throw new TypeError('cannot set prototype on a non-object');
|
|
438
|
+
}
|
|
439
|
+
if (typeof proto !== 'object') {
|
|
440
|
+
throw new TypeError('can only set prototype to an object or null');
|
|
441
|
+
}
|
|
442
|
+
};
|
|
443
|
+
|
|
444
|
+
var setPrototypeOf = function(O, proto) {
|
|
445
|
+
checkArgs(O, proto);
|
|
446
|
+
set.call(O, proto);
|
|
447
|
+
return O;
|
|
448
|
+
};
|
|
449
|
+
|
|
450
|
+
try {
|
|
451
|
+
// this works already in Firefox and Safari
|
|
452
|
+
set = Object.getOwnPropertyDescriptor(Object.prototype, magic).set;
|
|
453
|
+
set.call({}, null);
|
|
454
|
+
} catch (e) {
|
|
455
|
+
if (Object.prototype !== {}[magic]) {
|
|
456
|
+
// IE < 11 cannot be shimmed
|
|
457
|
+
return;
|
|
458
|
+
}
|
|
459
|
+
// probably Chrome or some old Mobile stock browser
|
|
460
|
+
set = function(proto) {
|
|
461
|
+
this[magic] = proto;
|
|
462
|
+
};
|
|
463
|
+
// please note that this will **not** work
|
|
464
|
+
// in those browsers that do not inherit
|
|
465
|
+
// __proto__ by mistake from Object.prototype
|
|
466
|
+
// in these cases we should probably throw an error
|
|
467
|
+
// or at least be informed about the issue
|
|
468
|
+
setPrototypeOf.polyfill = setPrototypeOf(
|
|
469
|
+
setPrototypeOf({}, null),
|
|
470
|
+
Object.prototype
|
|
471
|
+
) instanceof Object;
|
|
472
|
+
// setPrototypeOf.polyfill === true means it works as meant
|
|
473
|
+
// setPrototypeOf.polyfill === false means it's not 100% reliable
|
|
474
|
+
// setPrototypeOf.polyfill === undefined
|
|
475
|
+
// or
|
|
476
|
+
// setPrototypeOf.polyfill == null means it's not a polyfill
|
|
477
|
+
// which means it works as expected
|
|
478
|
+
// we can even delete Object.prototype.__proto__;
|
|
479
|
+
}
|
|
480
|
+
return setPrototypeOf;
|
|
481
|
+
})(Object, '__proto__')
|
|
482
|
+
});
|
|
483
|
+
}
|
|
484
|
+
|
|
485
|
+
defineProperties(Object, {
|
|
486
|
+
getOwnPropertyKeys: function(subject) {
|
|
487
|
+
return Object.keys(subject);
|
|
488
|
+
},
|
|
489
|
+
|
|
490
|
+
is: function(a, b) {
|
|
491
|
+
if (a === b) {
|
|
492
|
+
// 0 === -0, but they are not identical.
|
|
493
|
+
if (a === 0) return 1 / a === 1 / b;
|
|
494
|
+
return true;
|
|
495
|
+
}
|
|
496
|
+
return Number.isNaN(a) && Number.isNaN(b);
|
|
497
|
+
}
|
|
498
|
+
});
|
|
499
|
+
|
|
500
|
+
defineProperties(Math, {
|
|
501
|
+
acosh: function(value) {
|
|
502
|
+
value = Number(value);
|
|
503
|
+
if (Number.isNaN(value) || value < 1) return NaN;
|
|
504
|
+
if (value === 1) return 0;
|
|
505
|
+
if (value === Infinity) return value;
|
|
506
|
+
return Math.log(value + Math.sqrt(value * value - 1));
|
|
507
|
+
},
|
|
508
|
+
|
|
509
|
+
asinh: function(value) {
|
|
510
|
+
value = Number(value);
|
|
511
|
+
if (value === 0 || !global_isFinite(value)) {
|
|
512
|
+
return value;
|
|
513
|
+
}
|
|
514
|
+
return Math.log(value + Math.sqrt(value * value + 1));
|
|
515
|
+
},
|
|
516
|
+
|
|
517
|
+
atanh: function(value) {
|
|
518
|
+
value = Number(value);
|
|
519
|
+
if (Number.isNaN(value) || value < -1 || value > 1) {
|
|
520
|
+
return NaN;
|
|
521
|
+
}
|
|
522
|
+
if (value === -1) return -Infinity;
|
|
523
|
+
if (value === 1) return Infinity;
|
|
524
|
+
if (value === 0) return value;
|
|
525
|
+
return 0.5 * Math.log((1 + value) / (1 - value));
|
|
526
|
+
},
|
|
527
|
+
|
|
528
|
+
cbrt: function(value) {
|
|
529
|
+
value = Number(value);
|
|
530
|
+
if (value === 0) return value;
|
|
531
|
+
var negate = value < 0, result;
|
|
532
|
+
if (negate) value = -value;
|
|
533
|
+
result = Math.pow(value, 1/3);
|
|
534
|
+
return negate ? -result : result;
|
|
535
|
+
},
|
|
536
|
+
|
|
537
|
+
cosh: function(value) {
|
|
538
|
+
value = Number(value);
|
|
539
|
+
if (value === 0) return 1; // +0 or -0
|
|
540
|
+
if (!global_isFinite(value)) return value;
|
|
541
|
+
if (value < 0) value = -value;
|
|
542
|
+
if (value > 21) return Math.exp(value) / 2;
|
|
543
|
+
return (Math.exp(value) + Math.exp(-value)) / 2;
|
|
544
|
+
},
|
|
545
|
+
|
|
546
|
+
expm1: function(value) {
|
|
547
|
+
value = Number(value);
|
|
548
|
+
if (value === -Infinity) return -1;
|
|
549
|
+
if (!global_isFinite(value) || value === 0) return value;
|
|
550
|
+
var result = 0;
|
|
551
|
+
var n = 50;
|
|
552
|
+
for (var i = 1; i < n; i++) {
|
|
553
|
+
for (var j = 2, factorial = 1; j <= i; j++) {
|
|
554
|
+
factorial *= j;
|
|
555
|
+
}
|
|
556
|
+
result += Math.pow(value, i) / factorial;
|
|
557
|
+
}
|
|
558
|
+
return result;
|
|
559
|
+
},
|
|
560
|
+
|
|
561
|
+
hypot: function(x, y) {
|
|
562
|
+
var anyNaN = false;
|
|
563
|
+
var allZero = true;
|
|
564
|
+
var anyInfinity = false;
|
|
565
|
+
var numbers = [];
|
|
566
|
+
Array.prototype.every.call(arguments, function(arg) {
|
|
567
|
+
var num = Number(arg);
|
|
568
|
+
if (Number.isNaN(num)) anyNaN = true;
|
|
569
|
+
else if (num === Infinity || num === -Infinity) anyInfinity = true;
|
|
570
|
+
else if (num !== 0) allZero = false;
|
|
571
|
+
if (anyInfinity) {
|
|
572
|
+
return false;
|
|
573
|
+
} else if (!anyNaN) {
|
|
574
|
+
numbers.push(Math.abs(num));
|
|
575
|
+
}
|
|
576
|
+
return true;
|
|
577
|
+
});
|
|
578
|
+
if (anyInfinity) return Infinity;
|
|
579
|
+
if (anyNaN) return NaN;
|
|
580
|
+
if (allZero) return 0;
|
|
581
|
+
|
|
582
|
+
numbers.sort(function (a, b) { return b - a; });
|
|
583
|
+
var largest = numbers[0];
|
|
584
|
+
var divided = numbers.map(function (number) { return number / largest; });
|
|
585
|
+
var sum = divided.reduce(function (sum, number) { return sum += number * number; }, 0);
|
|
586
|
+
return largest * Math.sqrt(sum);
|
|
587
|
+
},
|
|
588
|
+
|
|
589
|
+
log2: function(value) {
|
|
590
|
+
return Math.log(value) * Math.LOG2E;
|
|
591
|
+
},
|
|
592
|
+
|
|
593
|
+
log10: function(value) {
|
|
594
|
+
return Math.log(value) * Math.LOG10E;
|
|
595
|
+
},
|
|
596
|
+
|
|
597
|
+
log1p: function(value) {
|
|
598
|
+
value = Number(value);
|
|
599
|
+
if (value < -1 || Number.isNaN(value)) return NaN;
|
|
600
|
+
if (value === 0 || value === Infinity) return value;
|
|
601
|
+
if (value === -1) return -Infinity;
|
|
602
|
+
var result = 0;
|
|
603
|
+
var n = 50;
|
|
604
|
+
|
|
605
|
+
if (value < 0 || value > 1) return Math.log(1 + value);
|
|
606
|
+
for (var i = 1; i < n; i++) {
|
|
607
|
+
if ((i % 2) === 0) {
|
|
608
|
+
result -= Math.pow(value, i) / i;
|
|
609
|
+
} else {
|
|
610
|
+
result += Math.pow(value, i) / i;
|
|
611
|
+
}
|
|
612
|
+
}
|
|
613
|
+
|
|
614
|
+
return result;
|
|
615
|
+
},
|
|
616
|
+
|
|
617
|
+
sign: function(value) {
|
|
618
|
+
var number = +value;
|
|
619
|
+
if (number === 0) return number;
|
|
620
|
+
if (Number.isNaN(number)) return number;
|
|
621
|
+
return number < 0 ? -1 : 1;
|
|
622
|
+
},
|
|
623
|
+
|
|
624
|
+
sinh: function(value) {
|
|
625
|
+
value = Number(value);
|
|
626
|
+
if (!global_isFinite(value) || value === 0) return value;
|
|
627
|
+
return (Math.exp(value) - Math.exp(-value)) / 2;
|
|
628
|
+
},
|
|
629
|
+
|
|
630
|
+
tanh: function(value) {
|
|
631
|
+
value = Number(value);
|
|
632
|
+
if (Number.isNaN(value) || value === 0) return value;
|
|
633
|
+
if (value === Infinity) return 1;
|
|
634
|
+
if (value === -Infinity) return -1;
|
|
635
|
+
return (Math.exp(value) - Math.exp(-value)) / (Math.exp(value) + Math.exp(-value));
|
|
636
|
+
},
|
|
637
|
+
|
|
638
|
+
trunc: function(value) {
|
|
639
|
+
var number = Number(value);
|
|
640
|
+
return number < 0 ? -Math.floor(-number) : Math.floor(number);
|
|
641
|
+
},
|
|
642
|
+
|
|
643
|
+
imul: function(x, y) {
|
|
644
|
+
// taken from https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/imul
|
|
645
|
+
var ah = (x >>> 16) & 0xffff;
|
|
646
|
+
var al = x & 0xffff;
|
|
647
|
+
var bh = (y >>> 16) & 0xffff;
|
|
648
|
+
var bl = y & 0xffff;
|
|
649
|
+
// the shift by 0 fixes the sign on the high part
|
|
650
|
+
// the final |0 converts the unsigned value into a signed value
|
|
651
|
+
return ((al * bl) + (((ah * bl + al * bh) << 16) >>> 0)|0);
|
|
652
|
+
}
|
|
653
|
+
});
|
|
654
|
+
|
|
655
|
+
// Map and Set require a true ES5 environment
|
|
656
|
+
if (supportsDescriptors) {
|
|
657
|
+
|
|
658
|
+
var fastkey = function fastkey(key) {
|
|
659
|
+
var type = typeof key;
|
|
660
|
+
if (type === 'string') {
|
|
661
|
+
return '$' + key;
|
|
662
|
+
} else if (type === 'number' && !Object.is(key, -0)) {
|
|
663
|
+
return key;
|
|
664
|
+
}
|
|
665
|
+
return null;
|
|
666
|
+
};
|
|
667
|
+
|
|
668
|
+
var emptyObject = function emptyObject() {
|
|
669
|
+
// accomodate some older not-quite-ES5 browsers
|
|
670
|
+
return Object.create ? Object.create(null) : {};
|
|
671
|
+
};
|
|
672
|
+
|
|
673
|
+
var collectionShims = {
|
|
674
|
+
Map: (function() {
|
|
675
|
+
|
|
676
|
+
var empty = {};
|
|
677
|
+
|
|
678
|
+
function MapEntry(key, value) {
|
|
679
|
+
this.key = key;
|
|
680
|
+
this.value = value;
|
|
681
|
+
this.next = null;
|
|
682
|
+
this.prev = null;
|
|
683
|
+
}
|
|
684
|
+
|
|
685
|
+
MapEntry.prototype.isRemoved = function() {
|
|
686
|
+
return this.key === empty;
|
|
687
|
+
};
|
|
688
|
+
|
|
689
|
+
function MapIterator(map, kind) {
|
|
690
|
+
this.head = map._head;
|
|
691
|
+
this.i = this.head.next;
|
|
692
|
+
this.kind = kind;
|
|
693
|
+
}
|
|
694
|
+
|
|
695
|
+
MapIterator.prototype = {
|
|
696
|
+
next: function() {
|
|
697
|
+
var i = this.i, kind = this.kind, head = this.head, result;
|
|
698
|
+
while (i !== head) {
|
|
699
|
+
this.i = i.next;
|
|
700
|
+
if (!i.isRemoved()) {
|
|
701
|
+
if (kind === "key") {
|
|
702
|
+
result = i.key;
|
|
703
|
+
} else if (kind === "value") {
|
|
704
|
+
result = i.value;
|
|
705
|
+
} else {
|
|
706
|
+
result = [i.key, i.value];
|
|
707
|
+
}
|
|
708
|
+
return { value: result, done: false };
|
|
709
|
+
}
|
|
710
|
+
i = this.i;
|
|
711
|
+
}
|
|
712
|
+
return { value: undefined, done: true };
|
|
713
|
+
}
|
|
714
|
+
};
|
|
715
|
+
|
|
716
|
+
function Map() {
|
|
717
|
+
if (!(this instanceof Map)) throw new TypeError('Map must be called with "new"');
|
|
718
|
+
|
|
719
|
+
var head = new MapEntry(null, null);
|
|
720
|
+
// circular doubly-linked list.
|
|
721
|
+
head.next = head.prev = head;
|
|
722
|
+
|
|
723
|
+
defineProperties(this, {
|
|
724
|
+
'_head': head,
|
|
725
|
+
'_storage': emptyObject(),
|
|
726
|
+
'_size': 0
|
|
727
|
+
});
|
|
728
|
+
}
|
|
729
|
+
|
|
730
|
+
Object.defineProperty(Map.prototype, 'size', {
|
|
731
|
+
configurable: true,
|
|
732
|
+
enumerable: false,
|
|
733
|
+
get: function() {
|
|
734
|
+
return this._size;
|
|
735
|
+
}
|
|
736
|
+
});
|
|
737
|
+
|
|
738
|
+
defineProperties(Map.prototype, {
|
|
739
|
+
get: function(key) {
|
|
740
|
+
var fkey = fastkey(key);
|
|
741
|
+
if (fkey !== null) {
|
|
742
|
+
// fast O(1) path
|
|
743
|
+
var entry = this._storage[fkey];
|
|
744
|
+
return entry ? entry.value : undefined;
|
|
745
|
+
}
|
|
746
|
+
var head = this._head, i = head;
|
|
747
|
+
while ((i = i.next) !== head) {
|
|
748
|
+
if (Object.is(i.key, key)) {
|
|
749
|
+
return i.value;
|
|
750
|
+
}
|
|
751
|
+
}
|
|
752
|
+
return undefined;
|
|
753
|
+
},
|
|
754
|
+
|
|
755
|
+
has: function(key) {
|
|
756
|
+
var fkey = fastkey(key);
|
|
757
|
+
if (fkey !== null) {
|
|
758
|
+
// fast O(1) path
|
|
759
|
+
return fkey in this._storage;
|
|
760
|
+
}
|
|
761
|
+
var head = this._head, i = head;
|
|
762
|
+
while ((i = i.next) !== head) {
|
|
763
|
+
if (Object.is(i.key, key)) {
|
|
764
|
+
return true;
|
|
765
|
+
}
|
|
766
|
+
}
|
|
767
|
+
return false;
|
|
768
|
+
},
|
|
769
|
+
|
|
770
|
+
set: function(key, value) {
|
|
771
|
+
var head = this._head, i = head, entry;
|
|
772
|
+
var fkey = fastkey(key);
|
|
773
|
+
if (fkey !== null) {
|
|
774
|
+
// fast O(1) path
|
|
775
|
+
if (fkey in this._storage) {
|
|
776
|
+
this._storage[fkey].value = value;
|
|
777
|
+
return;
|
|
778
|
+
} else {
|
|
779
|
+
entry = this._storage[fkey] = new MapEntry(key, value);
|
|
780
|
+
i = head.prev;
|
|
781
|
+
// fall through
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
while ((i = i.next) !== head) {
|
|
785
|
+
if (Object.is(i.key, key)) {
|
|
786
|
+
i.value = value;
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
}
|
|
790
|
+
entry = entry ? entry : new MapEntry(key, value);
|
|
791
|
+
entry.next = this._head;
|
|
792
|
+
entry.prev = this._head.prev;
|
|
793
|
+
entry.prev.next = entry;
|
|
794
|
+
entry.next.prev = entry;
|
|
795
|
+
this._size += 1;
|
|
796
|
+
},
|
|
797
|
+
|
|
798
|
+
'delete': function(key) {
|
|
799
|
+
var head = this._head, i = head;
|
|
800
|
+
var fkey = fastkey(key);
|
|
801
|
+
if (fkey !== null) {
|
|
802
|
+
// fast O(1) path
|
|
803
|
+
if (!(fkey in this._storage)) {
|
|
804
|
+
return false;
|
|
805
|
+
}
|
|
806
|
+
i = this._storage[fkey].prev;
|
|
807
|
+
delete this._storage[fkey];
|
|
808
|
+
// fall through
|
|
809
|
+
}
|
|
810
|
+
while ((i = i.next) !== head) {
|
|
811
|
+
if (Object.is(i.key, key)) {
|
|
812
|
+
i.key = i.value = empty;
|
|
813
|
+
i.prev.next = i.next;
|
|
814
|
+
i.next.prev = i.prev;
|
|
815
|
+
this._size -= 1;
|
|
816
|
+
return true;
|
|
817
|
+
}
|
|
818
|
+
}
|
|
819
|
+
return false;
|
|
820
|
+
},
|
|
821
|
+
|
|
822
|
+
clear: function() {
|
|
823
|
+
this._size = 0;
|
|
824
|
+
this._storage = emptyObject();
|
|
825
|
+
var head = this._head, i = head, p = i.next;
|
|
826
|
+
while ((i = p) !== head) {
|
|
827
|
+
i.key = i.value = empty;
|
|
828
|
+
p = i.next;
|
|
829
|
+
i.next = i.prev = head;
|
|
830
|
+
}
|
|
831
|
+
head.next = head.prev = head;
|
|
832
|
+
},
|
|
833
|
+
|
|
834
|
+
keys: function() {
|
|
835
|
+
return new MapIterator(this, "key");
|
|
836
|
+
},
|
|
837
|
+
|
|
838
|
+
values: function() {
|
|
839
|
+
return new MapIterator(this, "value");
|
|
840
|
+
},
|
|
841
|
+
|
|
842
|
+
entries: function() {
|
|
843
|
+
return new MapIterator(this, "key+value");
|
|
844
|
+
},
|
|
845
|
+
|
|
846
|
+
forEach: function(callback) {
|
|
847
|
+
var context = arguments.length > 1 ? arguments[1] : null;
|
|
848
|
+
var entireMap = this;
|
|
849
|
+
|
|
850
|
+
var head = this._head, i = head;
|
|
851
|
+
while ((i = i.next) !== head) {
|
|
852
|
+
if (!i.isRemoved()) {
|
|
853
|
+
callback.call(context, i.value, i.key, entireMap);
|
|
854
|
+
}
|
|
855
|
+
}
|
|
856
|
+
}
|
|
857
|
+
});
|
|
858
|
+
|
|
859
|
+
return Map;
|
|
860
|
+
})(),
|
|
861
|
+
|
|
862
|
+
Set: (function() {
|
|
863
|
+
// Creating a Map is expensive. To speed up the common case of
|
|
864
|
+
// Sets containing only string or numeric keys, we use an object
|
|
865
|
+
// as backing storage and lazily create a full Map only when
|
|
866
|
+
// required.
|
|
867
|
+
var SetShim = function Set() {
|
|
868
|
+
if (!(this instanceof SetShim)) throw new TypeError('Set must be called with "new"');
|
|
869
|
+
defineProperties(this, {
|
|
870
|
+
'[[SetData]]': null,
|
|
871
|
+
'_storage': emptyObject()
|
|
872
|
+
});
|
|
873
|
+
};
|
|
874
|
+
|
|
875
|
+
// Switch from the object backing storage to a full Map.
|
|
876
|
+
var ensureMap = function ensureMap(set) {
|
|
877
|
+
if (!set['[[SetData]]']) {
|
|
878
|
+
var m = set['[[SetData]]'] = new collectionShims.Map();
|
|
879
|
+
Object.keys(set._storage).forEach(function(k) {
|
|
880
|
+
// fast check for leading '$'
|
|
881
|
+
if (k.charCodeAt(0) === 36) {
|
|
882
|
+
k = k.substring(1);
|
|
883
|
+
} else {
|
|
884
|
+
k = +k;
|
|
885
|
+
}
|
|
886
|
+
m.set(k, k);
|
|
887
|
+
});
|
|
888
|
+
set._storage = null; // free old backing storage
|
|
889
|
+
}
|
|
890
|
+
};
|
|
891
|
+
|
|
892
|
+
Object.defineProperty(SetShim.prototype, 'size', {
|
|
893
|
+
configurable: true,
|
|
894
|
+
enumerable: false,
|
|
895
|
+
get: function() {
|
|
896
|
+
ensureMap(this);
|
|
897
|
+
return this['[[SetData]]'].size;
|
|
898
|
+
}
|
|
899
|
+
});
|
|
900
|
+
|
|
901
|
+
defineProperties(SetShim.prototype, {
|
|
902
|
+
has: function(key) {
|
|
903
|
+
var fkey;
|
|
904
|
+
if (this._storage && (fkey = fastkey(key)) !== null) {
|
|
905
|
+
return !!this._storage[fkey];
|
|
906
|
+
}
|
|
907
|
+
ensureMap(this);
|
|
908
|
+
return this['[[SetData]]'].has(key);
|
|
909
|
+
},
|
|
910
|
+
|
|
911
|
+
add: function(key) {
|
|
912
|
+
var fkey;
|
|
913
|
+
if (this._storage && (fkey = fastkey(key)) !== null) {
|
|
914
|
+
this._storage[fkey]=true;
|
|
915
|
+
return;
|
|
916
|
+
}
|
|
917
|
+
ensureMap(this);
|
|
918
|
+
return this['[[SetData]]'].set(key, key);
|
|
919
|
+
},
|
|
920
|
+
|
|
921
|
+
'delete': function(key) {
|
|
922
|
+
var fkey;
|
|
923
|
+
if (this._storage && (fkey = fastkey(key)) !== null) {
|
|
924
|
+
delete this._storage[fkey];
|
|
925
|
+
return;
|
|
926
|
+
}
|
|
927
|
+
ensureMap(this);
|
|
928
|
+
return this['[[SetData]]']['delete'](key);
|
|
929
|
+
},
|
|
930
|
+
|
|
931
|
+
clear: function() {
|
|
932
|
+
if (this._storage) {
|
|
933
|
+
this._storage = emptyObject();
|
|
934
|
+
return;
|
|
935
|
+
}
|
|
936
|
+
return this['[[SetData]]'].clear();
|
|
937
|
+
},
|
|
938
|
+
|
|
939
|
+
keys: function() {
|
|
940
|
+
ensureMap(this);
|
|
941
|
+
return this['[[SetData]]'].keys();
|
|
942
|
+
},
|
|
943
|
+
|
|
944
|
+
values: function() {
|
|
945
|
+
ensureMap(this);
|
|
946
|
+
return this['[[SetData]]'].values();
|
|
947
|
+
},
|
|
948
|
+
|
|
949
|
+
entries: function() {
|
|
950
|
+
ensureMap(this);
|
|
951
|
+
return this['[[SetData]]'].entries();
|
|
952
|
+
},
|
|
953
|
+
|
|
954
|
+
forEach: function(callback) {
|
|
955
|
+
var context = arguments.length > 1 ? arguments[1] : null;
|
|
956
|
+
var entireSet = this;
|
|
957
|
+
ensureMap(this);
|
|
958
|
+
this['[[SetData]]'].forEach(function(value, key) {
|
|
959
|
+
callback.call(context, key, key, entireSet);
|
|
960
|
+
});
|
|
961
|
+
}
|
|
962
|
+
});
|
|
963
|
+
|
|
964
|
+
return SetShim;
|
|
965
|
+
})()
|
|
966
|
+
};
|
|
967
|
+
defineProperties(globals, collectionShims);
|
|
968
|
+
|
|
969
|
+
if (globals.Map || globals.Set) {
|
|
970
|
+
/*
|
|
971
|
+
- In Firefox < 23, Map#size is a function.
|
|
972
|
+
- In all current Firefox, Set#entries/keys/values & Map#clear do not exist
|
|
973
|
+
- https://bugzilla.mozilla.org/show_bug.cgi?id=869996
|
|
974
|
+
- In Firefox 24, Map and Set do not implement forEach
|
|
975
|
+
*/
|
|
976
|
+
if (
|
|
977
|
+
typeof globals.Map.prototype.clear !== 'function' ||
|
|
978
|
+
new globals.Set().size !== 0 ||
|
|
979
|
+
new globals.Map().size !== 0 ||
|
|
980
|
+
typeof globals.Set.prototype.keys !== 'function' ||
|
|
981
|
+
typeof globals.Map.prototype.forEach !== 'function' ||
|
|
982
|
+
typeof globals.Set.prototype.forEach !== 'function'
|
|
983
|
+
) {
|
|
984
|
+
globals.Map = collectionShims.Map;
|
|
985
|
+
globals.Set = collectionShims.Set;
|
|
986
|
+
}
|
|
987
|
+
}
|
|
988
|
+
}
|
|
989
|
+
};
|
|
990
|
+
|
|
991
|
+
if (typeof define === 'function' && typeof define.amd === 'object' && define.amd) {
|
|
992
|
+
define(main); // RequireJS
|
|
993
|
+
} else {
|
|
994
|
+
main(); // CommonJS and <script>
|
|
995
|
+
}
|
|
996
|
+
})();
|