Skip to content
Myr

Some notes

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

authored by Michel Weststrate · committed by Michel Weststrate · parent f1918cb · Browse files · 4 files+34 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+34 added−10 removed

  • other:+34 added−10 removed

4 files+34 added−10 removed

modified:src/plugins/es5.ts+1 added-1 removed
153 unmodified lines
154 if (desc) {155 desc.enumerable = enumerable156 } else {157 descriptors[prop] = desc = {158 configurable: true,158 // configurable: true,159 enumerable,160 get(this: any) {161 return get(this[DRAFT_STATE], prop)162 },
136 unmodified lines
modified:src/plugins/mapset.ts+5 added-6 removed
68 unmodified lines
69 // TODO: smaller build size if we create a util for Object.defineProperty70 Object.defineProperty(p, "size", {71 get: function() {72 return latest(this[DRAFT_STATE]).size73 },74 enumerable: true,75 configurable: true73 }74 // enumerable: false,75 // configurable: true76 })7778 p.has = function(key: any): boolean {79 return latest(this[DRAFT_STATE]).has(key)
144 unmodified lines
224225 Object.defineProperty(p, "size", {226 get: function() {227 return latest(this[DRAFT_STATE]).size228 },229 enumerable: true,230 configurable: true228 }229 // enumerable: true,230 })231232 p.has = function(value: any): boolean {233 const state: SetState = this[DRAFT_STATE]
106 unmodified lines
modified:src/common.ts+3 added-1 removed
165 unmodified lines
166): T167export function shallowCopy(base: any, invokeGetters = false) {168 if (Array.isArray(base)) return base.slice()169 const clone = Object.create(Object.getPrototypeOf(base))170 // TODO: each?171 ownKeys(base).forEach(key => {172 if (key === DRAFT_STATE) {173 return // Never copy over draft state.174 }
31 unmodified lines
206function dontMutateFrozenCollections() {207 invariant(false, "This object has been frozen and should not be mutated")208}209210// TODO: used only once, inline211export function createHiddenProperty(212 target: AnyObject,213 prop: PropertyKey,214 value: any215) {216 Object.defineProperty(target, prop, {217 value: value,216 enumerable: false,218 // enumerable: false <- the default219 writable: true220 })221}222
7 unmodified lines
modified:notes.txt+25 added-2 removed
1Things to optimize23[x] extract errors4[x] don't enable all features by default5[ ] "undefined" "object" prototype undefined ?5[ ] "undefined" "object" "function" prototype undefined + buildin FNs ?6[x] kill hooks7[x] _ postfix all members8[ ] clean up finalize9[ ] remove die9[x] remove die10[ ] own invariant11[ ] optimize enumerations12[ ] update docs13[ ] plugin tests14[ ] check if we can create more local vars15[ ] verify performance16[ ] kill ownKeys?17[ ] kill isEnumerable?18[ ] check todos1920Import size report for immer:21┌───────────────────────┬───────────┬────────────┬───────────┐22│ (index) │ just this │ cumulative │ increment │
34 unmodified lines
57│ enableMapSet │ 4439 │ 5227 │ 799 │58│ enablePatches │ 4319 │ 5929 │ 702 │59└───────────────────────┴───────────┴────────────┴───────────┘60(this report was generated by npmjs.com/package/import-size)6162After hooks:[63 Import size report for immer:64┌───────────────────────┬───────────┬────────────┬───────────┐65│ (index) │ just this │ cumulative │ increment │66├───────────────────────┼───────────┼────────────┼───────────┤67│ import * from 'immer' │ 5983 │ 0 │ 0 │68│ produce │ 3454 │ 3454 │ 0 │69│ enableES5 │ 4270 │ 4278 │ 824 │70│ enableMapSet │ 4285 │ 5079 │ 801 │71│ enablePatches │ 4154 │ 5770 │ 691 │72└───────────────────────┴───────────┴────────────┴───────────┘73(this report was generated by npmjs.com/package/import-size)74]