mobx 6.3.7 → 6.3.8

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "mobx",
3
- "version": "6.3.7",
3
+ "version": "6.3.8",
4
4
  "description": "Simple, scalable state management.",
5
5
  "source": "src/mobx.ts",
6
6
  "main": "dist/index.js",
package/src/core/atom.ts CHANGED
@@ -17,7 +17,7 @@ import {
17
17
  export const $mobx = Symbol("mobx administration")
18
18
 
19
19
  export interface IAtom extends IObservable {
20
- reportObserved()
20
+ reportObserved(): boolean
21
21
  reportChanged()
22
22
  }
23
23
 
@@ -175,7 +175,8 @@ export class ObservableArrayAdministration
175
175
  }
176
176
 
177
177
  setArrayLength_(newLength: number) {
178
- if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0) die("Out of range: " + newLength)
178
+ if (typeof newLength !== "number" || isNaN(newLength) || newLength < 0)
179
+ die("Out of range: " + newLength)
179
180
  let currentLength = this.values_.length
180
181
  if (newLength === currentLength) return
181
182
  else if (newLength > currentLength) {
@@ -235,9 +236,12 @@ export class ObservableArrayAdministration
235
236
  if (newItems.length < MAX_SPLICE_SIZE) {
236
237
  return this.values_.splice(index, deleteCount, ...newItems)
237
238
  } else {
239
+ // The items removed by the splice
238
240
  const res = this.values_.slice(index, index + deleteCount)
241
+ // The items that that should remain at the end of the array
239
242
  let oldItems = this.values_.slice(index + deleteCount)
240
- this.values_.length = index + newItems.length - deleteCount
243
+ // New length is the previous length + addition count - deletion count
244
+ this.values_.length += newItems.length - deleteCount
241
245
  for (let i = 0; i < newItems.length; i++) this.values_[index + i] = newItems[i]
242
246
  for (let i = 0; i < oldItems.length; i++)
243
247
  this.values_[index + newItems.length + i] = oldItems[i]