@cloudcare/rum-uniapp 2.1.18 → 2.1.22

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.
Files changed (107) hide show
  1. package/README.md +42 -34
  2. package/cjs/boot/buildEnv.js +3 -4
  3. package/cjs/boot/rum.entry.js +11 -36
  4. package/cjs/boot/rum.js +2 -25
  5. package/cjs/core/baseInfo.js +6 -25
  6. package/cjs/core/boundedBuffer.js +1 -7
  7. package/cjs/core/configuration.js +15 -27
  8. package/cjs/core/contextManager.js +5 -17
  9. package/cjs/core/dataMap.js +5 -10
  10. package/cjs/core/downloadProxy.js +4 -26
  11. package/cjs/core/errorCollection.js +5 -35
  12. package/cjs/core/errorFilter.js +0 -8
  13. package/cjs/core/errorTools.js +2 -10
  14. package/cjs/core/heavyCustomerDataWarning.js +3 -9
  15. package/cjs/core/lifeCycle.js +8 -18
  16. package/cjs/core/observable.js +7 -13
  17. package/cjs/core/sdk.js +11 -19
  18. package/cjs/core/sessionManagement.js +8 -17
  19. package/cjs/core/transport.js +6 -53
  20. package/cjs/core/user.js +2 -7
  21. package/cjs/core/xhrProxy.js +4 -26
  22. package/cjs/helper/byteUtils.js +6 -12
  23. package/cjs/helper/commonContext.js +2 -3
  24. package/cjs/helper/enums.js +17 -28
  25. package/cjs/helper/jsonStringify.js +5 -12
  26. package/cjs/helper/limitModification.js +3 -21
  27. package/cjs/helper/tracekit.js +32 -145
  28. package/cjs/helper/utils.js +92 -306
  29. package/cjs/index.js +0 -1
  30. package/cjs/main.js +10 -0
  31. package/cjs/rumEventsCollection/action/actionCollection.js +0 -9
  32. package/cjs/rumEventsCollection/action/trackActions.js +46 -39
  33. package/cjs/rumEventsCollection/app/appCollection.js +0 -6
  34. package/cjs/rumEventsCollection/app/index.js +14 -25
  35. package/cjs/rumEventsCollection/assembly.js +0 -14
  36. package/cjs/rumEventsCollection/error/errorCollection.js +1 -16
  37. package/cjs/rumEventsCollection/internalContext.js +0 -2
  38. package/cjs/rumEventsCollection/page/index.js +19 -49
  39. package/cjs/rumEventsCollection/page/viewCollection.js +0 -8
  40. package/cjs/rumEventsCollection/parentContexts.js +3 -20
  41. package/cjs/rumEventsCollection/performanceCollection.js +0 -4
  42. package/cjs/rumEventsCollection/requestCollection.js +1 -14
  43. package/cjs/rumEventsCollection/resource/resourceCollection.js +0 -11
  44. package/cjs/rumEventsCollection/resource/resourceUtils.js +50 -46
  45. package/cjs/rumEventsCollection/setDataCollection.js +0 -16
  46. package/cjs/rumEventsCollection/tracing/ddtraceTracer.js +0 -6
  47. package/cjs/rumEventsCollection/tracing/jaegerTracer.js +3 -9
  48. package/cjs/rumEventsCollection/tracing/skywalkingTracer.js +3 -10
  49. package/cjs/rumEventsCollection/tracing/tracer.js +1 -25
  50. package/cjs/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -6
  51. package/cjs/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -10
  52. package/cjs/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -6
  53. package/cjs/rumEventsCollection/trackEventCounts.js +0 -8
  54. package/cjs/rumEventsCollection/trackPageActiveites.js +10 -33
  55. package/cjs/rumEventsCollection/transport/batch.js +0 -9
  56. package/esm/boot/buildEnv.js +1 -1
  57. package/esm/boot/rum.entry.js +8 -20
  58. package/esm/boot/rum.js +0 -4
  59. package/esm/core/baseInfo.js +0 -11
  60. package/esm/core/boundedBuffer.js +0 -3
  61. package/esm/core/configuration.js +13 -21
  62. package/esm/core/contextManager.js +3 -8
  63. package/esm/core/dataMap.js +2 -2
  64. package/esm/core/downloadProxy.js +2 -17
  65. package/esm/core/errorCollection.js +2 -15
  66. package/esm/core/errorFilter.js +0 -5
  67. package/esm/core/errorTools.js +0 -3
  68. package/esm/core/heavyCustomerDataWarning.js +3 -3
  69. package/esm/core/lifeCycle.js +0 -5
  70. package/esm/core/observable.js +0 -3
  71. package/esm/core/sdk.js +8 -12
  72. package/esm/core/sessionManagement.js +0 -3
  73. package/esm/core/transport.js +4 -38
  74. package/esm/core/user.js +2 -4
  75. package/esm/core/xhrProxy.js +2 -17
  76. package/esm/helper/byteUtils.js +4 -7
  77. package/esm/helper/commonContext.js +2 -2
  78. package/esm/helper/jsonStringify.js +4 -7
  79. package/esm/helper/limitModification.js +1 -11
  80. package/esm/helper/tracekit.js +29 -130
  81. package/esm/helper/utils.js +27 -125
  82. package/esm/main.js +4 -0
  83. package/esm/rumEventsCollection/action/actionCollection.js +0 -4
  84. package/esm/rumEventsCollection/action/trackActions.js +46 -31
  85. package/esm/rumEventsCollection/app/appCollection.js +0 -1
  86. package/esm/rumEventsCollection/app/index.js +12 -17
  87. package/esm/rumEventsCollection/assembly.js +0 -6
  88. package/esm/rumEventsCollection/error/errorCollection.js +0 -7
  89. package/esm/rumEventsCollection/internalContext.js +0 -1
  90. package/esm/rumEventsCollection/page/index.js +19 -43
  91. package/esm/rumEventsCollection/page/viewCollection.js +0 -3
  92. package/esm/rumEventsCollection/parentContexts.js +0 -10
  93. package/esm/rumEventsCollection/requestCollection.js +0 -4
  94. package/esm/rumEventsCollection/resource/resourceCollection.js +0 -5
  95. package/esm/rumEventsCollection/resource/resourceUtils.js +48 -39
  96. package/esm/rumEventsCollection/setDataCollection.js +0 -13
  97. package/esm/rumEventsCollection/tracing/ddtraceTracer.js +0 -4
  98. package/esm/rumEventsCollection/tracing/jaegerTracer.js +3 -7
  99. package/esm/rumEventsCollection/tracing/skywalkingTracer.js +5 -9
  100. package/esm/rumEventsCollection/tracing/tracer.js +0 -14
  101. package/esm/rumEventsCollection/tracing/w3cTraceParentTracer.js +1 -4
  102. package/esm/rumEventsCollection/tracing/zipkinMultiTracer.js +3 -8
  103. package/esm/rumEventsCollection/tracing/zipkinSingleTracer.js +1 -4
  104. package/esm/rumEventsCollection/trackEventCounts.js +0 -4
  105. package/esm/rumEventsCollection/trackPageActiveites.js +9 -22
  106. package/esm/rumEventsCollection/transport/batch.js +0 -5
  107. package/package.json +7 -4
@@ -8,13 +8,10 @@ export class sessionManagement {
8
8
  this.sessionId = UUID();
9
9
  this.isTrack = performDraw(configuration.sampleRate);
10
10
  }
11
-
12
11
  getSessionId() {
13
12
  return this.sessionId;
14
13
  }
15
-
16
14
  isTracked() {
17
15
  return this.isTrack;
18
16
  }
19
-
20
17
  }
@@ -2,21 +2,19 @@ import { findByPath, escapeRowData, isNumber, each, isString, values, extend, is
2
2
  import { sdk } from '../core/sdk';
3
3
  import { computeBytesCount } from '../helper/byteUtils';
4
4
  import { LifeCycleEventType } from '../core/lifeCycle';
5
- import { commonTags, dataMap, commonFields } from './dataMap'; // https://en.wikipedia.org/wiki/UTF-8
5
+ import { commonTags, dataMap, commonFields } from './dataMap';
6
6
 
7
+ // https://en.wikipedia.org/wiki/UTF-8
7
8
  var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
8
9
  var CUSTOM_KEYS = 'custom_keys';
9
-
10
10
  function addBatchPrecision(url) {
11
11
  if (!url) return url;
12
12
  return url + (url.indexOf('?') === -1 ? '?' : '&') + 'precision=ms';
13
13
  }
14
-
15
14
  var httpRequest = function httpRequest(endpointUrl, bytesLimit) {
16
15
  this.endpointUrl = endpointUrl;
17
16
  this.bytesLimit = bytesLimit;
18
17
  };
19
-
20
18
  httpRequest.prototype = {
21
19
  send: function send(data) {
22
20
  var url = addBatchPrecision(this.endpointUrl);
@@ -49,17 +47,13 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
49
47
  } else {
50
48
  rowStr += key + ',';
51
49
  }
52
-
53
50
  rowData.measurement = key;
54
51
  var tagsStr = [];
55
52
  var tags = extend({}, commonTags, value.tags);
56
53
  var filterFileds = ['date', 'type', CUSTOM_KEYS]; // 已经在datamap中定义过的fields和tags
57
-
58
54
  each(tags, function (value_path, _key) {
59
55
  var _value = findByPath(message, value_path);
60
-
61
56
  filterFileds.push(_key);
62
-
63
57
  if (_value || isNumber(_value)) {
64
58
  rowData.tags[_key] = escapeJsonValue(_value);
65
59
  tagsStr.push(escapeRowData(_key) + '=' + escapeRowData(_value));
@@ -70,30 +64,22 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
70
64
  each(fields, function (_value, _key) {
71
65
  if (isArray(_value) && _value.length === 2) {
72
66
  var type = _value[0],
73
- value_path = _value[1];
74
-
67
+ value_path = _value[1];
75
68
  var _valueData = findByPath(message, value_path);
76
-
77
69
  filterFileds.push(_key);
78
-
79
70
  if (_valueData || isNumber(_valueData)) {
80
71
  rowData.fields[_key] = _valueData; // 这里不需要转译
81
-
82
72
  fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_valueData));
83
73
  }
84
74
  } else if (isString(_value)) {
85
75
  var _valueData = findByPath(message, _value);
86
-
87
76
  filterFileds.push(_key);
88
-
89
77
  if (_valueData || isNumber(_valueData)) {
90
78
  rowData.fields[_key] = _valueData; // 这里不需要转译
91
-
92
79
  fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_valueData));
93
80
  }
94
81
  }
95
82
  });
96
-
97
83
  if (message.tags && isObject(message.tags) && !isEmptyObject(message.tags)) {
98
84
  // 自定义tag, 存储成field
99
85
  var _tagKeys = [];
@@ -101,42 +87,35 @@ export var processedMessageByDataMap = function processedMessageByDataMap(messag
101
87
  // 如果和之前tag重名,则舍弃
102
88
  if (filterFileds.indexOf(_key) > -1) return;
103
89
  filterFileds.push(_key);
104
-
105
90
  if (_value || isNumber(_value)) {
106
91
  _tagKeys.push(_key);
107
-
108
92
  rowData.fields[_key] = _value; // 这里不需要转译
109
-
110
93
  fieldsStr.push(escapeRowData(_key) + '=' + escapeRowField(_value));
111
94
  }
112
95
  });
113
-
114
96
  if (_tagKeys.length) {
115
97
  rowData.fields[CUSTOM_KEYS] = escapeRowField(_tagKeys);
116
98
  fieldsStr.push(escapeRowData(CUSTOM_KEYS) + '=' + escapeRowField(_tagKeys));
117
99
  }
118
100
  }
119
-
120
101
  if (tagsStr.length) {
121
102
  rowStr += tagsStr.join(',');
122
103
  }
123
-
124
104
  if (fieldsStr.length) {
125
105
  rowStr += ' ';
126
106
  rowStr += fieldsStr.join(',');
127
107
  hasFileds = true;
128
108
  }
129
-
130
109
  rowStr = rowStr + ' ' + message.date;
131
110
  rowData.time = toServerDuration(message.date); // 这里不需要转译
132
111
  }
133
112
  });
113
+
134
114
  return {
135
115
  rowStr: hasFileds ? rowStr : '',
136
116
  rowData: hasFileds ? rowData : undefined
137
117
  };
138
118
  };
139
-
140
119
  function batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, lifeCycle) {
141
120
  this.request = request;
142
121
  this.maxSize = maxSize;
@@ -151,7 +130,6 @@ function batch(request, maxSize, bytesLimit, maxMessageSize, flushTimeout, lifeC
151
130
  this.flushOnVisibilityHidden();
152
131
  this.flushPeriodically();
153
132
  }
154
-
155
133
  batch.prototype = {
156
134
  add: function add(message) {
157
135
  this.addOrUpdate(message);
@@ -175,22 +153,17 @@ batch.prototype = {
175
153
  addOrUpdate: function addOrUpdate(message, key) {
176
154
  var process = this.process(message);
177
155
  if (!process.processedMessage || process.processedMessage === '') return;
178
-
179
156
  if (process.messageBytesSize >= this.maxMessageSize) {
180
157
  console.warn('Discarded a message whose size was bigger than the maximum allowed size' + this.maxMessageSize + 'KB.');
181
158
  return;
182
159
  }
183
-
184
160
  if (this.hasMessageFor(key)) {
185
161
  this.remove(key);
186
162
  }
187
-
188
163
  if (this.willReachedBytesLimitWith(process.messageBytesSize)) {
189
164
  this.flush();
190
165
  }
191
-
192
166
  this.push(process.processedMessage, process.messageBytesSize, key);
193
-
194
167
  if (this.isFull()) {
195
168
  this.flush();
196
169
  }
@@ -208,13 +181,11 @@ batch.prototype = {
208
181
  // \n separator at serialization
209
182
  this.bufferBytesSize += 1;
210
183
  }
211
-
212
184
  if (key !== undefined) {
213
185
  this.upsertBuffer[key] = processedMessage;
214
186
  } else {
215
187
  this.pushOnlyBuffer.push(processedMessage);
216
188
  }
217
-
218
189
  this.bufferBytesSize += messageBytesSize;
219
190
  this.bufferMessageCount += 1;
220
191
  },
@@ -224,7 +195,6 @@ batch.prototype = {
224
195
  var messageBytesSize = computeBytesCount(removedMessage);
225
196
  this.bufferBytesSize -= messageBytesSize;
226
197
  this.bufferMessageCount -= 1;
227
-
228
198
  if (this.bufferMessageCount > 0) {
229
199
  this.bufferBytesSize -= 1;
230
200
  }
@@ -241,10 +211,8 @@ batch.prototype = {
241
211
  },
242
212
  flushPeriodically: function flushPeriodically() {
243
213
  var _this = this;
244
-
245
214
  setTimeout(function () {
246
215
  _this.flush();
247
-
248
216
  _this.flushPeriodically();
249
217
  }, _this.flushTimeout);
250
218
  },
@@ -254,8 +222,6 @@ batch.prototype = {
254
222
  * With sendBeacon, requests are guaranteed to be successfully sent during document unload
255
223
  */
256
224
  // @ts-ignore this function is not always defined
257
-
258
-
259
225
  this.lifeCycle.subscribe(LifeCycleEventType.APP_HIDE, function () {
260
226
  _this.flush();
261
227
  });
package/esm/core/user.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { extend, getType, each } from '../helper/utils';
2
+
2
3
  /**
3
4
  * Clone input data and ensure known user properties (id, name, email)
4
5
  * are strings, as defined here:
5
6
  * https://docs.datadoghq.com/logs/log_configuration/attributes_naming_convention/#user-related-attributes
6
7
  */
7
-
8
8
  export function sanitizeUser(newUser) {
9
9
  // We shallow clone only to prevent mutation of user data.
10
10
  var user = extend({}, newUser);
@@ -16,16 +16,14 @@ export function sanitizeUser(newUser) {
16
16
  });
17
17
  return user;
18
18
  }
19
+
19
20
  /**
20
21
  * Simple check to ensure user is valid
21
22
  */
22
-
23
23
  export function checkUser(newUser) {
24
24
  var isValid = getType(newUser) === 'object';
25
-
26
25
  if (!isValid) {
27
26
  console.error('Unsupported user:', newUser);
28
27
  }
29
-
30
28
  return isValid;
31
29
  }
@@ -17,7 +17,6 @@ export function startXhrProxy(userConfiguration) {
17
17
  }
18
18
  };
19
19
  }
20
-
21
20
  return xhrProxySingleton;
22
21
  }
23
22
  export function resetXhrProxy() {
@@ -28,13 +27,10 @@ export function resetXhrProxy() {
28
27
  sdk.request = originalXhrRequest;
29
28
  }
30
29
  }
31
-
32
30
  function proxyXhr(userConfiguration) {
33
31
  originalXhrRequest = sdk.request;
34
-
35
32
  sdk.request = function () {
36
33
  var _this = this;
37
-
38
34
  var dataflux_xhr = {
39
35
  method: arguments[0].method || 'GET',
40
36
  startTime: 0,
@@ -45,32 +41,24 @@ function proxyXhr(userConfiguration) {
45
41
  };
46
42
  dataflux_xhr.startTime = now();
47
43
  var originalSuccess = arguments[0].success;
48
-
49
44
  arguments[0].success = function () {
50
45
  reportXhr(arguments[0]);
51
-
52
46
  if (typeof originalSuccess === 'function') {
53
47
  originalSuccess.apply(_this, arguments);
54
48
  }
55
49
  };
56
-
57
50
  var originalFail = arguments[0].fail;
58
-
59
51
  arguments[0].fail = function () {
60
52
  reportXhr(arguments[0]);
61
-
62
53
  if (typeof originalFail === 'function') {
63
54
  originalFail.apply(_this, arguments);
64
55
  }
65
56
  };
66
-
67
57
  var hasBeenReported = false;
68
-
69
58
  var reportXhr = function reportXhr(res) {
70
59
  if (hasBeenReported) {
71
60
  return;
72
61
  }
73
-
74
62
  hasBeenReported = true;
75
63
  dataflux_xhr.duration = now() - dataflux_xhr.startTime;
76
64
  dataflux_xhr.response = JSON.stringify(res.data);
@@ -81,16 +69,14 @@ function proxyXhr(userConfiguration) {
81
69
  callback(dataflux_xhr);
82
70
  });
83
71
  };
84
-
85
72
  beforeSendCallbacks.forEach(function (callback) {
86
73
  callback(dataflux_xhr);
87
74
  });
88
- var result = originalXhrRequest.call(this, dataflux_xhr.option); // 判断结果是否为promise
89
-
75
+ var result = originalXhrRequest.call(this, dataflux_xhr.option);
76
+ // 判断结果是否为promise
90
77
  var isPromise = function isPromise(obj) {
91
78
  return !!obj && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function';
92
79
  };
93
-
94
80
  if (isPromise(result) && userConfiguration.isVue2) {
95
81
  // vue2 版本,success, fail 都在then返回
96
82
  return result.then(function (res) {
@@ -99,7 +85,6 @@ function proxyXhr(userConfiguration) {
99
85
  } else {
100
86
  reportXhr(res[1]);
101
87
  }
102
-
103
88
  return res;
104
89
  });
105
90
  } else if (isPromise(result) && !userConfiguration.isVue2) {
@@ -1,19 +1,17 @@
1
1
  export var ONE_KIBI_BYTE = 1024;
2
- export var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE; // eslint-disable-next-line no-control-regex
3
-
2
+ export var ONE_MEBI_BYTE = 1024 * ONE_KIBI_BYTE;
3
+ // eslint-disable-next-line no-control-regex
4
4
  var HAS_MULTI_BYTES_CHARACTERS = /[^\u0000-\u007F]/;
5
5
  export function computeBytesCount(candidate) {
6
6
  // Accurate byte size computations can degrade performances when there is a lot of events to process
7
7
  if (!HAS_MULTI_BYTES_CHARACTERS.test(candidate)) {
8
8
  return candidate.length;
9
9
  }
10
-
11
10
  var total = 0,
12
- charCode; // utf-8编码
13
-
11
+ charCode;
12
+ // utf-8编码
14
13
  for (var i = 0, len = candidate.length; i < len; i++) {
15
14
  charCode = candidate.charCodeAt(i);
16
-
17
15
  if (charCode <= 0x007f) {
18
16
  total += 1;
19
17
  } else if (charCode <= 0x07ff) {
@@ -24,6 +22,5 @@ export function computeBytesCount(candidate) {
24
22
  total += 4;
25
23
  }
26
24
  }
27
-
28
25
  return total;
29
26
  }
@@ -1,7 +1,7 @@
1
1
  export function buildCommonContext(globalContextManager, userContextManager) {
2
2
  return {
3
3
  context: globalContextManager.getContext(),
4
- user: userContextManager.getContext() // hasReplay: recorderApi.isRecording() ? true : undefined,
5
-
4
+ user: userContextManager.getContext()
5
+ // hasReplay: recorderApi.isRecording() ? true : undefined,
6
6
  };
7
7
  }
@@ -1,4 +1,5 @@
1
1
  import { noop } from './utils';
2
+
2
3
  /**
3
4
  * Custom implementation of JSON.stringify that ignores some toJSON methods. We need to do that
4
5
  * because some sites badly override toJSON on certain objects. Removing all toJSON methods from
@@ -7,19 +8,17 @@ import { noop } from './utils';
7
8
  *
8
9
  * Note: this still assumes that JSON.stringify is correct.
9
10
  */
10
-
11
11
  export function jsonStringify(value, replacer, space) {
12
12
  if (typeof value !== 'object' || value === null) {
13
13
  return JSON.stringify(value);
14
- } // Note: The order matter here. We need to detach toJSON methods on parent classes before their
15
- // subclasses.
16
-
14
+ }
17
15
 
16
+ // Note: The order matter here. We need to detach toJSON methods on parent classes before their
17
+ // subclasses.
18
18
  var restoreObjectPrototypeToJson = detachToJsonMethod(Object.prototype);
19
19
  var restoreArrayPrototypeToJson = detachToJsonMethod(Array.prototype);
20
20
  var restoreValuePrototypeToJson = detachToJsonMethod(Object.getPrototypeOf(value));
21
21
  var restoreValueToJson = detachToJsonMethod(value);
22
-
23
22
  try {
24
23
  return JSON.stringify(value, replacer, space);
25
24
  } catch (error) {
@@ -34,13 +33,11 @@ export function jsonStringify(value, replacer, space) {
34
33
  export function detachToJsonMethod(value) {
35
34
  var object = value;
36
35
  var objectToJson = object.toJSON;
37
-
38
36
  if (objectToJson) {
39
37
  delete object.toJSON;
40
38
  return () => {
41
39
  object.toJSON = objectToJson;
42
40
  };
43
41
  }
44
-
45
42
  return noop;
46
43
  }
@@ -1,49 +1,40 @@
1
1
  import { extend2Lev, each } from './utils';
2
+
2
3
  /**
3
4
  * Current limitations:
4
5
  * - field path do not support array, 'a.b.c' only
5
6
  * - modifiable fields type must be string
6
7
  */
7
-
8
8
  export function limitModification(object, modifiableFieldPaths, modifier) {
9
9
  var clone = extend2Lev({}, object);
10
10
  var result = modifier(clone);
11
11
  each(modifiableFieldPaths, function (path) {
12
12
  var originalValue = get(object, path);
13
13
  var newValue = get(clone, path);
14
-
15
14
  if (typeof originalValue === 'string' && typeof newValue === 'string') {
16
15
  set(object, path, newValue);
17
16
  }
18
17
  });
19
18
  return result;
20
19
  }
21
-
22
20
  function get(object, path) {
23
21
  var current = object;
24
-
25
22
  for (var field of path.split('.')) {
26
23
  if (!isValidObjectContaining(current, field)) {
27
24
  return;
28
25
  }
29
-
30
26
  current = current[field];
31
27
  }
32
-
33
28
  return current;
34
29
  }
35
-
36
30
  function set(object, path, value) {
37
31
  var current = object;
38
32
  var fields = path.split('.');
39
-
40
33
  for (var i = 0; i < fields.length; i += 1) {
41
34
  var field = fields[i];
42
-
43
35
  if (!isValidObjectContaining(current, field)) {
44
36
  return;
45
37
  }
46
-
47
38
  if (i !== fields.length - 1) {
48
39
  current = current[field];
49
40
  } else {
@@ -51,7 +42,6 @@ function set(object, path, value) {
51
42
  }
52
43
  }
53
44
  }
54
-
55
45
  function isValidObjectContaining(object, field) {
56
46
  return typeof object === 'object' && object !== null && field in object;
57
47
  }