Skip to content
Myr

fix creating array proxy

Before adoption: this commit came in with the history the project adopted, so no landing records it.

maybe hasOwnProperty should be used on its object.

authored by iruca3 · committed by iruca3 · parent 17e9bfb · Browse files · 4 files+10 added−10 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+10 added−10 removed

  • tests:+9 added−4 removed
  • other:+1 added−6 removed

4 files+10 added−10 removed

modified:__tests__/base.js+9 added-4 removed
1"use strict"2import produce, {setAutoFreeze, setUseProxies} from "../src/immer"3import deepFreeze from "deep-freeze"4import cloneDeep from "lodash.clonedeep"5import find from "lodash.find"56jest.setTimeout(1000)78runBaseTest("proxy (no freeze)", true, false)
107 unmodified lines
116 expect(nextState).not.toBe(baseState)117 expect(nextState).toEqual(baseState)118 })119121 it("processes with lodash.find", () => {120 it("processes with for loop", () => {121 const base = [{id: 1, a: 1}, {id: 2, a: 1}]122 const findById = (collection, id) => {123 for (const item of collection) {124 if (item.id === id) return item125 }126 return null127 }128 const result = produce(base, draft => {124 const obj1 = find(draft, {id: 1})125 const obj2 = find(draft, {id: 2})129 const obj1 = findById(draft, 1)130 const obj2 = findById(draft, 2)131 obj1.a = 2132 obj2.a = 2133 })134 expect(result[0].a).toEqual(2)
653 unmodified lines
modified:src/common.js+1 added-1 removed
modified:package.json-1 removed
51 unmodified lines
52 "deep-freeze": "^0.0.1",53 "immutable": "^3.8.2",54 "jest": "^22.0.4",55 "lodash.clonedeep": "^4.5.0",56 "lodash.find": "^4.6.0",56 "pre-commit": "^1.2.2",57 "prettier": "^1.9.2",58 "regenerator-runtime": "^0.11.1",59 "rimraf": "^2.6.2",
20 unmodified lines
modified:yarn.lock-4 removed
2276 unmodified lines
2277lodash.clonedeep@^4.5.0:2278 version "4.5.0"2279 resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"22802281lodash.find@^4.6.0:2282 version "4.6.0"2283 resolved "https://registry.yarnpkg.com/lodash.find/-/lodash.find-4.6.0.tgz#cb0704d47ab71789ffa0de8b97dd926fb88b13b1"22842281lodash.sortby@^4.7.0:2282 version "4.7.0"2283 resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"2284
1254 unmodified lines