@microsoft/applicationinsights-core-js 2.7.4-nightly.2202-02 → 2.7.4-nightly.2202-03
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.
- package/browser/applicationinsights-core-js.integrity.json +9 -9
- package/browser/applicationinsights-core-js.js +158 -118
- package/browser/applicationinsights-core-js.js.map +1 -1
- package/browser/applicationinsights-core-js.min.js +2 -2
- package/browser/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.api.json +39 -4
- package/dist/applicationinsights-core-js.api.md +1 -1
- package/dist/applicationinsights-core-js.d.ts +2 -2
- package/dist/applicationinsights-core-js.js +158 -118
- package/dist/applicationinsights-core-js.js.map +1 -1
- package/dist/applicationinsights-core-js.min.js +2 -2
- package/dist/applicationinsights-core-js.min.js.map +1 -1
- package/dist/applicationinsights-core-js.rollup.d.ts +2 -2
- package/dist-esm/JavaScriptSDK/AppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseCore.js +1 -1
- package/dist-esm/JavaScriptSDK/BaseTelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK/ChannelController.js +1 -1
- package/dist-esm/JavaScriptSDK/Constants.js +1 -1
- package/dist-esm/JavaScriptSDK/CookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK/CoreUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DbgExtensionUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/DiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK/EnvUtils.js +1 -1
- package/dist-esm/JavaScriptSDK/HelperFuncs.js +291 -108
- package/dist-esm/JavaScriptSDK/HelperFuncs.js.map +1 -1
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js +2 -35
- package/dist-esm/JavaScriptSDK/InstrumentHooks.js.map +1 -1
- package/dist-esm/JavaScriptSDK/NotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK/PerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK/ProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK/RandomHelper.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryHelpers.js +1 -1
- package/dist-esm/JavaScriptSDK/TelemetryPluginChain.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/EventsDiscardedReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/LoggingEnums.js +1 -1
- package/dist-esm/JavaScriptSDK.Enums/SendRequestReason.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IAppInsightsCore.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IChannelControls.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IConfiguration.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ICookieMgr.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDbgExtension.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IDiagnosticLogger.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IInstrumentHooks.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationListener.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/INotificationManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfEvent.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IPerfManager.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/IProcessTelemetryContext.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryItem.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPlugin.js +1 -1
- package/dist-esm/JavaScriptSDK.Interfaces/ITelemetryPluginChain.js +1 -1
- package/dist-esm/applicationinsights-core-js.js +1 -1
- package/package.json +1 -1
- package/src/JavaScriptSDK/HelperFuncs.ts +329 -108
- package/src/JavaScriptSDK/InstrumentHooks.ts +1 -41
- package/types/JavaScriptSDK/HelperFuncs.d.ts +40 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Microsoft Application Insights Core Javascript SDK, 2.7.4-nightly.2202-
|
|
2
|
+
* Microsoft Application Insights Core Javascript SDK, 2.7.4-nightly.2202-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*
|
|
5
5
|
* Microsoft Application Insights Team
|
|
@@ -1605,7 +1605,7 @@ export declare interface IProcessTelemetryContext {
|
|
|
1605
1605
|
/**
|
|
1606
1606
|
* Check if an object is of type Array
|
|
1607
1607
|
*/
|
|
1608
|
-
export declare function isArray(obj: any):
|
|
1608
|
+
export declare function isArray<T = any>(obj: any): obj is Array<T>;
|
|
1609
1609
|
|
|
1610
1610
|
/**
|
|
1611
1611
|
* Checks if HTML5 Beacons are supported in the current environment.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { __extendsFn as __extends } from "@microsoft/applicationinsights-shims";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
import { _InternalMessageId, LoggingSeverity } from "../JavaScriptSDK.Enums/LoggingEnums";
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
/*
|
|
2
|
-
* Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-
|
|
2
|
+
* Application Insights JavaScript SDK - Core, 2.7.4-nightly.2202-03
|
|
3
3
|
* Copyright (c) Microsoft and contributors. All rights reserved.
|
|
4
4
|
*/
|
|
5
5
|
|
|
6
6
|
|
|
7
|
-
import { strShimUndefined, strShimObject, strShimFunction, throwTypeError, ObjClass, ObjProto, ObjAssign, ObjHasOwnProperty, ObjDefineProperty } from "@microsoft/applicationinsights-shims";
|
|
7
|
+
import { strShimUndefined, strShimObject, strShimFunction, throwTypeError, ObjClass, ObjProto, ObjAssign, ObjHasOwnProperty, ObjDefineProperty, strShimPrototype } from "@microsoft/applicationinsights-shims";
|
|
8
8
|
// RESTRICT and AVOID circular dependencies you should not import other contained modules or export the contents of this file directly
|
|
9
9
|
// Added to help with minfication
|
|
10
10
|
var strOnPrefix = "on";
|
|
@@ -13,11 +13,65 @@ var strAddEventHelper = "addEventListener";
|
|
|
13
13
|
var strDetachEvent = "detachEvent";
|
|
14
14
|
var strRemoveEventListener = "removeEventListener";
|
|
15
15
|
var strToISOString = "toISOString";
|
|
16
|
+
var cStrEndsWith = "endsWith";
|
|
17
|
+
var cStrStartsWith = "startsWith";
|
|
18
|
+
var strIndexOf = "indexOf";
|
|
19
|
+
var strMap = "map";
|
|
20
|
+
var strReduce = "reduce";
|
|
21
|
+
var cStrTrim = "trim";
|
|
22
|
+
var strKeys = "keys";
|
|
23
|
+
var strToString = "toString";
|
|
24
|
+
/**
|
|
25
|
+
* Constant string defined to support minimization
|
|
26
|
+
* @ignore
|
|
27
|
+
*/
|
|
28
|
+
var str__Proto = "__proto__";
|
|
29
|
+
/**
|
|
30
|
+
* Constant string defined to support minimization
|
|
31
|
+
* @ignore
|
|
32
|
+
*/
|
|
33
|
+
var strConstructor = "constructor";
|
|
16
34
|
var _objDefineProperty = ObjDefineProperty;
|
|
17
35
|
var _objFreeze = ObjClass["freeze"];
|
|
18
36
|
var _objSeal = ObjClass["seal"];
|
|
37
|
+
var StringProto = String[strShimPrototype];
|
|
38
|
+
var _strTrim = StringProto[cStrTrim];
|
|
39
|
+
var _strEndsWith = StringProto[cStrEndsWith];
|
|
40
|
+
var _strStartsWith = StringProto[cStrStartsWith];
|
|
41
|
+
var DateProto = Date[strShimPrototype];
|
|
42
|
+
var _dataToISOString = DateProto[strToISOString];
|
|
43
|
+
var _isArray = Array.isArray;
|
|
44
|
+
var _fnToString = ObjHasOwnProperty[strToString];
|
|
45
|
+
// Cache what this browser reports as the object function constructor (as a string)
|
|
46
|
+
var _objFunctionString = _fnToString.call(ObjClass);
|
|
47
|
+
var rCamelCase = /-([a-z])/g;
|
|
48
|
+
var rNormalizeInvalid = /([^\w\d_$])/g;
|
|
49
|
+
var rLeadingNumeric = /^(\d+[\w\d_$])/;
|
|
50
|
+
/**
|
|
51
|
+
* Pre-lookup to check if we are running on a modern browser (i.e. not IE8)
|
|
52
|
+
* @ignore
|
|
53
|
+
*/
|
|
54
|
+
var _objGetPrototypeOf = Object["getPrototypeOf"];
|
|
55
|
+
/**
|
|
56
|
+
* Helper used to get the prototype of the target object as getPrototypeOf is not available in an ES3 environment.
|
|
57
|
+
* @ignore
|
|
58
|
+
*/
|
|
59
|
+
export function _getObjProto(target) {
|
|
60
|
+
if (target) {
|
|
61
|
+
// This method doesn't existing in older browsers (e.g. IE8)
|
|
62
|
+
if (_objGetPrototypeOf) {
|
|
63
|
+
return _objGetPrototypeOf(target);
|
|
64
|
+
}
|
|
65
|
+
// target[Constructor] May break if the constructor has been changed or removed
|
|
66
|
+
var newProto = target[str__Proto] || target[strShimPrototype] || target[strConstructor];
|
|
67
|
+
if (newProto) {
|
|
68
|
+
return newProto;
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
return null;
|
|
72
|
+
}
|
|
19
73
|
export function objToString(obj) {
|
|
20
|
-
return ObjProto.
|
|
74
|
+
return ObjProto[strToString].call(obj);
|
|
21
75
|
}
|
|
22
76
|
export function isTypeof(value, theType) {
|
|
23
77
|
return typeof value === theType;
|
|
@@ -35,15 +89,15 @@ export function isNotNullOrUndefined(value) {
|
|
|
35
89
|
return !isNullOrUndefined(value);
|
|
36
90
|
}
|
|
37
91
|
export function hasOwnProperty(obj, prop) {
|
|
38
|
-
return obj && ObjHasOwnProperty.call(obj, prop);
|
|
92
|
+
return !!(obj && ObjHasOwnProperty.call(obj, prop));
|
|
39
93
|
}
|
|
40
94
|
export function isObject(value) {
|
|
41
95
|
// Changing to inline for performance
|
|
42
|
-
return typeof value === strShimObject;
|
|
96
|
+
return !!(value && typeof value === strShimObject);
|
|
43
97
|
}
|
|
44
98
|
export function isFunction(value) {
|
|
45
99
|
// Changing to inline for performance
|
|
46
|
-
return typeof value === strShimFunction;
|
|
100
|
+
return !!(value && typeof value === strShimFunction);
|
|
47
101
|
}
|
|
48
102
|
/**
|
|
49
103
|
* Binds the specified function to an event, so that the function gets called whenever the event fires on the object
|
|
@@ -107,9 +161,15 @@ export function detachEvent(obj, eventNameWithoutOn, handlerRef, useCapture) {
|
|
|
107
161
|
*/
|
|
108
162
|
export function normalizeJsName(name) {
|
|
109
163
|
var value = name;
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
value =
|
|
164
|
+
if (value && isString(value)) {
|
|
165
|
+
// CamelCase everything after the "-" and remove the dash
|
|
166
|
+
value = value.replace(rCamelCase, function (_all, letter) {
|
|
167
|
+
return letter.toUpperCase();
|
|
168
|
+
});
|
|
169
|
+
value = value.replace(rNormalizeInvalid, "_");
|
|
170
|
+
value = value.replace(rLeadingNumeric, function (_all, match) {
|
|
171
|
+
return "_" + match;
|
|
172
|
+
});
|
|
113
173
|
}
|
|
114
174
|
return value;
|
|
115
175
|
}
|
|
@@ -135,24 +195,34 @@ export function objForEachKey(target, callbackfn) {
|
|
|
135
195
|
* @returns true if the given search value is found at the end of the string, otherwise false.
|
|
136
196
|
*/
|
|
137
197
|
export function strEndsWith(value, search) {
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
198
|
+
var result = false;
|
|
199
|
+
if (value && search && !(result = value === search)) {
|
|
200
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
201
|
+
result = _strEndsWith ? value[cStrEndsWith](search) : _strEndsWithPoly(value, search);
|
|
202
|
+
}
|
|
203
|
+
return result;
|
|
204
|
+
}
|
|
205
|
+
/**
|
|
206
|
+
* The _strEndsWith() method determines whether a string ends with the characters of a specified string, returning true or false as appropriate.
|
|
207
|
+
* @param value - The value to check whether it ends with the search value.
|
|
208
|
+
* @param search - The characters to be searched for at the end of the value.
|
|
209
|
+
* @returns true if the given search value is found at the end of the string, otherwise false.
|
|
210
|
+
*/
|
|
211
|
+
export function _strEndsWithPoly(value, search) {
|
|
212
|
+
var result = false;
|
|
213
|
+
var searchLen = search ? search.length : 0;
|
|
214
|
+
var valLen = value ? value.length : 0;
|
|
215
|
+
if (searchLen && valLen && valLen >= searchLen && !(result = value === search)) {
|
|
216
|
+
var pos = valLen - 1;
|
|
217
|
+
for (var lp = searchLen - 1; lp >= 0; lp--) {
|
|
218
|
+
if (value[pos] != search[lp]) {
|
|
219
|
+
return false;
|
|
151
220
|
}
|
|
152
|
-
|
|
221
|
+
pos--;
|
|
153
222
|
}
|
|
223
|
+
result = true;
|
|
154
224
|
}
|
|
155
|
-
return
|
|
225
|
+
return result;
|
|
156
226
|
}
|
|
157
227
|
/**
|
|
158
228
|
* The strStartsWith() method determines whether a string starts with the characters of the specified string, returning true or false as appropriate.
|
|
@@ -161,21 +231,30 @@ export function strEndsWith(value, search) {
|
|
|
161
231
|
* @returns true if the given search value is found at the start of the string, otherwise false.
|
|
162
232
|
*/
|
|
163
233
|
export function strStartsWith(value, checkValue) {
|
|
234
|
+
var result = false;
|
|
235
|
+
if (value && checkValue && !(result = value === checkValue)) {
|
|
236
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
237
|
+
result = _strStartsWith ? value[cStrStartsWith](checkValue) : _strStartsWithPoly(value, checkValue);
|
|
238
|
+
}
|
|
239
|
+
return result;
|
|
240
|
+
}
|
|
241
|
+
/**
|
|
242
|
+
* The strStartsWith() method determines whether a string starts with the characters of the specified string, returning true or false as appropriate.
|
|
243
|
+
* @param value - The value to check whether it ends with the search value.
|
|
244
|
+
* @param checkValue - The characters to be searched for at the start of the value.
|
|
245
|
+
* @returns true if the given search value is found at the start of the string, otherwise false.
|
|
246
|
+
*/
|
|
247
|
+
export function _strStartsWithPoly(value, checkValue) {
|
|
164
248
|
// Using helper for performance and because string startsWith() is not available on IE
|
|
165
249
|
var result = false;
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
else if (value.length >= chkLen) {
|
|
172
|
-
for (var lp = 0; lp < chkLen; lp++) {
|
|
173
|
-
if (value[lp] !== checkValue[lp]) {
|
|
174
|
-
return false;
|
|
175
|
-
}
|
|
250
|
+
var chkLen = checkValue ? checkValue.length : 0;
|
|
251
|
+
if (value && chkLen && value.length >= chkLen && !(result = value === checkValue)) {
|
|
252
|
+
for (var lp = 0; lp < chkLen; lp++) {
|
|
253
|
+
if (value[lp] !== checkValue[lp]) {
|
|
254
|
+
return false;
|
|
176
255
|
}
|
|
177
|
-
result = true;
|
|
178
256
|
}
|
|
257
|
+
result = true;
|
|
179
258
|
}
|
|
180
259
|
return result;
|
|
181
260
|
}
|
|
@@ -194,19 +273,19 @@ export function strContains(value, search) {
|
|
|
194
273
|
* Check if an object is of type Date
|
|
195
274
|
*/
|
|
196
275
|
export function isDate(obj) {
|
|
197
|
-
return objToString(obj) === "[object Date]";
|
|
276
|
+
return !!(obj && objToString(obj) === "[object Date]");
|
|
198
277
|
}
|
|
199
278
|
/**
|
|
200
279
|
* Check if an object is of type Array
|
|
201
280
|
*/
|
|
202
281
|
export function isArray(obj) {
|
|
203
|
-
return objToString(obj) === "[object Array]";
|
|
282
|
+
return _isArray ? _isArray(obj) : !!(obj && objToString(obj) === "[object Array]");
|
|
204
283
|
}
|
|
205
284
|
/**
|
|
206
285
|
* Check if an object is of type Error
|
|
207
286
|
*/
|
|
208
287
|
export function isError(obj) {
|
|
209
|
-
return objToString(obj) === "[object Error]";
|
|
288
|
+
return !!(obj && objToString(obj) === "[object Error]");
|
|
210
289
|
}
|
|
211
290
|
/**
|
|
212
291
|
* Checks if the type of value is a string.
|
|
@@ -244,32 +323,57 @@ export function isBoolean(value) {
|
|
|
244
323
|
export function isSymbol(value) {
|
|
245
324
|
return typeof value === "symbol";
|
|
246
325
|
}
|
|
326
|
+
/**
|
|
327
|
+
* Checks if the type of the value is a normal plain object (not a null or data)
|
|
328
|
+
* @param value
|
|
329
|
+
*/
|
|
330
|
+
export function isPlainObject(value) {
|
|
331
|
+
var result = false;
|
|
332
|
+
if (value && typeof value === "object") {
|
|
333
|
+
var proto = _getObjProto(value);
|
|
334
|
+
if (!proto) {
|
|
335
|
+
// No prototype found so this is a plain Object eg. `Object.create(null)`
|
|
336
|
+
result = true;
|
|
337
|
+
}
|
|
338
|
+
else {
|
|
339
|
+
// If the prototype has a constructor then it's not a plain object
|
|
340
|
+
if (hasOwnProperty(proto, strConstructor)) {
|
|
341
|
+
proto = proto[strConstructor];
|
|
342
|
+
}
|
|
343
|
+
result = isFunction(proto) && _fnToString.call(proto) === _objFunctionString;
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
247
348
|
/**
|
|
248
349
|
* Convert a date to I.S.O. format in IE8
|
|
249
350
|
*/
|
|
250
351
|
export function toISOString(date) {
|
|
251
352
|
if (date) {
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
353
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
354
|
+
return _dataToISOString ? date[strToISOString]() : _toISOStringPoly(date);
|
|
355
|
+
}
|
|
356
|
+
}
|
|
357
|
+
/**
|
|
358
|
+
* Convert a date to I.S.O. format in IE8
|
|
359
|
+
*/
|
|
360
|
+
export function _toISOStringPoly(date) {
|
|
361
|
+
if (date && date.getUTCFullYear) {
|
|
362
|
+
var pad = function (num) {
|
|
363
|
+
var r = String(num);
|
|
364
|
+
if (r.length === 1) {
|
|
365
|
+
r = "0" + r;
|
|
366
|
+
}
|
|
367
|
+
return r;
|
|
368
|
+
};
|
|
369
|
+
return date.getUTCFullYear()
|
|
370
|
+
+ "-" + pad(date.getUTCMonth() + 1)
|
|
371
|
+
+ "-" + pad(date.getUTCDate())
|
|
372
|
+
+ "T" + pad(date.getUTCHours())
|
|
373
|
+
+ ":" + pad(date.getUTCMinutes())
|
|
374
|
+
+ ":" + pad(date.getUTCSeconds())
|
|
375
|
+
+ "." + String((date.getUTCMilliseconds() / 1000).toFixed(3)).slice(2, 5)
|
|
376
|
+
+ "Z";
|
|
273
377
|
}
|
|
274
378
|
}
|
|
275
379
|
/**
|
|
@@ -304,17 +408,23 @@ export function arrForEach(arr, callbackfn, thisArg) {
|
|
|
304
408
|
* @param fromIndex The array index at which to begin the search. If fromIndex is omitted, the search starts at index 0.
|
|
305
409
|
*/
|
|
306
410
|
export function arrIndexOf(arr, searchElement, fromIndex) {
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
411
|
+
if (arr) {
|
|
412
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
413
|
+
if (arr[strIndexOf]) {
|
|
414
|
+
return arr[strIndexOf](searchElement, fromIndex);
|
|
415
|
+
}
|
|
416
|
+
var len = arr.length;
|
|
417
|
+
var from = fromIndex || 0;
|
|
418
|
+
try {
|
|
419
|
+
for (var lp = Math.max(from >= 0 ? from : len - Math.abs(from), 0); lp < len; lp++) {
|
|
420
|
+
if (lp in arr && arr[lp] === searchElement) {
|
|
421
|
+
return lp;
|
|
422
|
+
}
|
|
313
423
|
}
|
|
314
424
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
425
|
+
catch (e) {
|
|
426
|
+
// This can happen with some native browser objects, but should not happen for the type we are checking for
|
|
427
|
+
}
|
|
318
428
|
}
|
|
319
429
|
return -1;
|
|
320
430
|
}
|
|
@@ -327,18 +437,25 @@ export function arrIndexOf(arr, searchElement, fromIndex) {
|
|
|
327
437
|
* @param thisArg An object to which the this keyword can refer in the callbackfn function. If thisArg is omitted, undefined is used as the this value.
|
|
328
438
|
*/
|
|
329
439
|
export function arrMap(arr, callbackfn, thisArg) {
|
|
330
|
-
var
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
440
|
+
var results;
|
|
441
|
+
if (arr) {
|
|
442
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
443
|
+
if (arr[strMap]) {
|
|
444
|
+
return arr[strMap](callbackfn, thisArg);
|
|
445
|
+
}
|
|
446
|
+
var len = arr.length;
|
|
447
|
+
var _this = thisArg || arr;
|
|
448
|
+
results = new Array(len);
|
|
449
|
+
try {
|
|
450
|
+
for (var lp = 0; lp < len; lp++) {
|
|
451
|
+
if (lp in arr) {
|
|
452
|
+
results[lp] = callbackfn.call(_this, arr[lp], arr);
|
|
453
|
+
}
|
|
337
454
|
}
|
|
338
455
|
}
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
456
|
+
catch (e) {
|
|
457
|
+
// This can happen with some native browser objects, but should not happen for the type we are checking for
|
|
458
|
+
}
|
|
342
459
|
}
|
|
343
460
|
return results;
|
|
344
461
|
}
|
|
@@ -351,24 +468,30 @@ export function arrMap(arr, callbackfn, thisArg) {
|
|
|
351
468
|
* @param initialValue If initialValue is specified, it is used as the initial value to start the accumulation. The first call to the callbackfn function provides this value as an argument instead of an array value.
|
|
352
469
|
*/
|
|
353
470
|
export function arrReduce(arr, callbackfn, initialValue) {
|
|
354
|
-
var len = arr.length;
|
|
355
|
-
var lp = 0;
|
|
356
471
|
var value;
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
else {
|
|
362
|
-
while (lp < len && !(lp in arr)) {
|
|
363
|
-
lp++;
|
|
472
|
+
if (arr) {
|
|
473
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
474
|
+
if (arr[strReduce]) {
|
|
475
|
+
return arr[strReduce](callbackfn, initialValue);
|
|
364
476
|
}
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
if (
|
|
369
|
-
value =
|
|
477
|
+
var len = arr.length;
|
|
478
|
+
var lp = 0;
|
|
479
|
+
// Specifically checking the number of passed arguments as the value could be anything
|
|
480
|
+
if (arguments.length >= 3) {
|
|
481
|
+
value = arguments[2];
|
|
482
|
+
}
|
|
483
|
+
else {
|
|
484
|
+
while (lp < len && !(lp in arr)) {
|
|
485
|
+
lp++;
|
|
486
|
+
}
|
|
487
|
+
value = arr[lp++];
|
|
488
|
+
}
|
|
489
|
+
while (lp < len) {
|
|
490
|
+
if (lp in arr) {
|
|
491
|
+
value = callbackfn(value, arr[lp], lp, arr);
|
|
492
|
+
}
|
|
493
|
+
lp++;
|
|
370
494
|
}
|
|
371
|
-
lp++;
|
|
372
495
|
}
|
|
373
496
|
return value;
|
|
374
497
|
}
|
|
@@ -376,10 +499,11 @@ export function arrReduce(arr, callbackfn, initialValue) {
|
|
|
376
499
|
* helper method to trim strings (IE8 does not implement String.prototype.trim)
|
|
377
500
|
*/
|
|
378
501
|
export function strTrim(str) {
|
|
379
|
-
if (
|
|
380
|
-
|
|
502
|
+
if (str) {
|
|
503
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
504
|
+
str = (_strTrim && str[cStrTrim]) ? str[cStrTrim]() : (str.replace ? str.replace(/^\s+|\s+$/g, "") : str);
|
|
381
505
|
}
|
|
382
|
-
return str
|
|
506
|
+
return str;
|
|
383
507
|
}
|
|
384
508
|
var _objKeysHasDontEnumBug = !({ toString: null }).propertyIsEnumerable("toString");
|
|
385
509
|
var _objKeysDontEnums = [
|
|
@@ -402,6 +526,10 @@ export function objKeys(obj) {
|
|
|
402
526
|
if (objType !== strShimFunction && (objType !== strShimObject || obj === null)) {
|
|
403
527
|
throwTypeError("objKeys called on non-object");
|
|
404
528
|
}
|
|
529
|
+
// For Performance try and use the native instance, using string lookup of the function to easily pass the ES3 build checks and minification
|
|
530
|
+
if (!_objKeysHasDontEnumBug && obj[strKeys]) {
|
|
531
|
+
return obj[strKeys];
|
|
532
|
+
}
|
|
405
533
|
var result = [];
|
|
406
534
|
for (var prop in obj) {
|
|
407
535
|
if (obj && ObjHasOwnProperty.call(obj, prop)) {
|
|
@@ -452,16 +580,10 @@ export function objDefineAccessors(target, prop, getProp, setProp) {
|
|
|
452
580
|
return false;
|
|
453
581
|
}
|
|
454
582
|
export function objFreeze(value) {
|
|
455
|
-
|
|
456
|
-
value = _objFreeze(value);
|
|
457
|
-
}
|
|
458
|
-
return value;
|
|
583
|
+
return _objFreeze ? _objFreeze(value) : value;
|
|
459
584
|
}
|
|
460
585
|
export function objSeal(value) {
|
|
461
|
-
|
|
462
|
-
value = _objSeal(value);
|
|
463
|
-
}
|
|
464
|
-
return value;
|
|
586
|
+
return _objSeal ? _objSeal(value) : value;
|
|
465
587
|
}
|
|
466
588
|
/**
|
|
467
589
|
* Return the current time via the Date now() function (if available) and falls back to (new Date()).getTime() if now() is unavailable (IE8 or less)
|
|
@@ -469,10 +591,7 @@ export function objSeal(value) {
|
|
|
469
591
|
*/
|
|
470
592
|
export function dateNow() {
|
|
471
593
|
var dt = Date;
|
|
472
|
-
|
|
473
|
-
return dt.now();
|
|
474
|
-
}
|
|
475
|
-
return new dt().getTime();
|
|
594
|
+
return dt.now ? dt.now() : new dt().getTime();
|
|
476
595
|
}
|
|
477
596
|
/**
|
|
478
597
|
* Returns the name of object if it's an Error. Otherwise, returns empty string.
|
|
@@ -626,4 +745,68 @@ export function optimizeObject(theObject) {
|
|
|
626
745
|
}
|
|
627
746
|
return theObject;
|
|
628
747
|
}
|
|
748
|
+
/**
|
|
749
|
+
* Pass in the objects to merge as arguments, this will only "merge" (extend) properties that are owned by the object.
|
|
750
|
+
* It will NOT merge inherited or non-enumerable properties.
|
|
751
|
+
* @param obj1 - object to merge. Set this argument to 'true' for a deep extend.
|
|
752
|
+
* @param obj2 - object to merge.
|
|
753
|
+
* @param obj3 - object to merge.
|
|
754
|
+
* @param obj4 - object to merge.
|
|
755
|
+
* @param obj5 - object to merge.
|
|
756
|
+
* @returns The extended first object.
|
|
757
|
+
*/
|
|
758
|
+
export function objExtend(obj, obj2, obj3, obj4, obj5, obj6) {
|
|
759
|
+
// Variables
|
|
760
|
+
var theArgs = arguments;
|
|
761
|
+
var extended = theArgs[0] || {};
|
|
762
|
+
var argLen = theArgs.length;
|
|
763
|
+
var deep = false;
|
|
764
|
+
var idx = 1;
|
|
765
|
+
// Check for "Deep" flag
|
|
766
|
+
if (argLen > 0 && isBoolean(extended)) {
|
|
767
|
+
deep = extended;
|
|
768
|
+
extended = theArgs[idx] || {};
|
|
769
|
+
idx++;
|
|
770
|
+
}
|
|
771
|
+
// Handle case when target is a string or something (possible in deep copy)
|
|
772
|
+
if (!isObject(extended)) {
|
|
773
|
+
extended = {};
|
|
774
|
+
}
|
|
775
|
+
// Loop through each remaining object and conduct a merge
|
|
776
|
+
for (; idx < argLen; idx++) {
|
|
777
|
+
var arg = theArgs[idx];
|
|
778
|
+
var isArgArray = isArray(arg);
|
|
779
|
+
var isArgObj = isObject(arg);
|
|
780
|
+
for (var prop in arg) {
|
|
781
|
+
var propOk = (isArgArray && (prop in arg)) || (isArgObj && (ObjHasOwnProperty.call(arg, prop)));
|
|
782
|
+
if (!propOk) {
|
|
783
|
+
continue;
|
|
784
|
+
}
|
|
785
|
+
var newValue = arg[prop];
|
|
786
|
+
var isNewArray = void 0;
|
|
787
|
+
// If deep merge and property is an object, merge properties
|
|
788
|
+
if (deep && newValue && ((isNewArray = isArray(newValue)) || isPlainObject(newValue))) {
|
|
789
|
+
// Grab the current value of the extended object
|
|
790
|
+
var clone = extended[prop];
|
|
791
|
+
if (isNewArray) {
|
|
792
|
+
if (!isArray(clone)) {
|
|
793
|
+
// We can't "merge" an array with a non-array so overwrite the original
|
|
794
|
+
clone = [];
|
|
795
|
+
}
|
|
796
|
+
}
|
|
797
|
+
else if (!isPlainObject(clone)) {
|
|
798
|
+
// We can't "merge" an object with a non-object
|
|
799
|
+
clone = {};
|
|
800
|
+
}
|
|
801
|
+
// Never move the original objects always clone them
|
|
802
|
+
newValue = objExtend(deep, clone, newValue);
|
|
803
|
+
}
|
|
804
|
+
// Assign the new (or previous) value (unless undefined)
|
|
805
|
+
if (newValue !== undefined) {
|
|
806
|
+
extended[prop] = newValue;
|
|
807
|
+
}
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
return extended;
|
|
811
|
+
}
|
|
629
812
|
//# sourceMappingURL=HelperFuncs.js.map
|