removed bforescript command
Before adoption: this commit came in with the history the project adopted, so no landing records it.
authored by Gregory Assasie · committed by Gregory Assasie · parent 8843dfd · Browse files · 13 files·+498 added−466 removed
This commit
State
Before adoption: this commit came in with the history the project adopted, so no landing records it.
Diff stats
13 files+498 added−466 removed
- tests:+236 added−57 removed
- other:+262 added−409 removed
Provenance
- Commit
1f1cab5- Tree
0a32051- Author
Gregory Assasie <gregjarvez@gmail.com>- Committer
Gregory Assasie <gregjarvez@gmail.com>- Parent
8843dfd
13 files changed+498 added−466 removed
modified:__tests__/base.js+59 added-57 removed
1+"use strict"2 import immer from ".."3 4 describe("base", () => {5 let baseState10 unmodified lines16 17 it("should return the original without modifications when reading stuff", () => {18 const nextState = immer(baseState, s => {19 expect(s.aProp).toBe("hi")19- expect(s.anObject.nested).toEqual({ yummie: true })20+ expect(s.anObject.nested).toEqual({yummie: true})21 })22 expect(nextState).toBe(baseState)23 })24 25 it("should not return any value: thunk", () => {25- const warning = jest.spyOn(console, "warn");26+ const warning = jest.spyOn(console, "warn")27 immer(baseState, () => ({bad: "don't do this"}))27- immer(baseState, () => [1,2,3])28+ immer(baseState, () => [1, 2, 3])29 immer(baseState, () => false)30 immer(baseState, () => "")31 31- expect(warning).toHaveBeenCalledTimes(4);32+ expect(warning).toHaveBeenCalledTimes(4)33 })34 35 it("should return a copy when modifying stuff", () => {36 const nextState = immer(baseState, s => {18 unmodified lines55 })56 57 it("can add props", () => {58 const nextState = immer(baseState, s => {58- s.anObject.cookie = { tasty: true }59+ s.anObject.cookie = {tasty: true}60 })61 expect(nextState).not.toBe(baseState)62 expect(nextState.anObject).not.toBe(baseState.anObject)63 expect(nextState.anObject.nested).toBe(baseState.anObject.nested)63- expect(nextState.anObject.cookie).toEqual({ tasty: true })64+ expect(nextState.anObject.cookie).toEqual({tasty: true})65 })66 67 it("can delete props", () => {68 const nextState = immer(baseState, s => {43 unmodified lines112 })113 expect(nextState).not.toBe(baseState)114 expect(nextState.anArray).not.toBe(baseState.anArray)115 115- expect(nextState.anArray).toEqual([3, "a", "b", { c: 3 }, 1])116+ expect(nextState.anArray).toEqual([3, "a", "b", {c: 3}, 1])117 })118 119 it("should support sorting arrays", () => {120 const nextState = immer(baseState, s => {2 unmodified lines123 s.anArray[3].c = 5124 })125 expect(nextState).not.toBe(baseState)126 expect(nextState.anArray).not.toBe(baseState.anArray)126- expect(nextState.anArray).toEqual([1, 2, 3, { c: 5 }])127+ expect(nextState.anArray).toEqual([1, 2, 3, {c: 5}])128 })129 130 it("should updating inside arrays", () => {131 const nextState = immer(baseState, s => {132 s.anArray[2].test = true133 })134 expect(nextState).not.toBe(baseState)135 expect(nextState.anArray).not.toBe(baseState.anArray)135- expect(nextState.anArray).toEqual([3, 2, { c: 3, test: true }, 1])136+ expect(nextState.anArray).toEqual([3, 2, {c: 3, test: true}, 1])137 })138 139 it("reusing object should work", () => {140 const nextState = immer(baseState, s => {140- debugger141 const obj = s.anObject142 delete s.anObject143 s.messy = obj144 })145 expect(nextState).not.toBe(baseState)146 expect(nextState.anArray).toBe(baseState.anArray)147 expect(nextState).toEqual({148- anArray: [3, 2, { c: 3 }, 1],148+ anArray: [3, 2, {c: 3}, 1],149 aProp: "hi",150 messy: {151 nested: {152- yummie: true152+ yummie: true,153 },154- coffee: false155- }154+ coffee: false,155+ },156 })157 expect(nextState.messy.nested).toBe(baseState.anObject.nested)158 })159 7 unmodified lines167 })168 expect(nextState).not.toBe(baseState)169 expect(nextState.anArray).toBe(baseState.anArray)170 expect(nextState).toEqual({171- anArray: [3, 2, { c: 3 }, 1],171+ anArray: [3, 2, {c: 3}, 1],172 aProp: "hello",173 messy: {174 nested: {175- yummie: true175+ yummie: true,176 },177- coffee: true178- }177+ coffee: true,178+ },179 })180 expect(nextState.messy.nested).toBe(baseState.anObject.nested)181 })182 1 unmodified line184 const nextState = immer(baseState, s => {185 s.aProp = undefined186 })187 expect(nextState).not.toBe(baseState)188- expect(baseState.aProp).toBe('hi')188+ expect(baseState.aProp).toBe("hi")189 expect(nextState.aProp).toBe(undefined)190 })191 192+ it("should revoke the proxy of the baseState after immer function is executed", () => {193+ let proxy194+ const nextState = immer(baseState, s => {195+ proxy = s196+ s.aProp = "hello"197+ })198+ expect(nextState).not.toBe(baseState)199+ expect(baseState.aProp).toBe("hi")200+ expect(nextState.aProp).toBe("hello")201+202+ expect(() => {203+ proxy.aProp = "Hallo"204+ }).toThrowError(/^Cannot perform.*on a proxy that has been revoked/)205+ expect(() => {206+ const aProp = proxy.aProp207+ }).toThrowError(/^Cannot perform.*on a proxy that has been revoked/)208+209+ expect(nextState).not.toBe(baseState)210+ expect(baseState.aProp).toBe("hi")211+ expect(nextState.aProp).toBe("hello")212+ })213+214+ it("should revoke the proxy of the baseState after immer function is executed - 2", () => {215+ let proxy216+ const nextState = immer(baseState, s => {217+ proxy = s.anObject218+ })219+ expect(nextState).toBe(baseState)220+ expect(() => {221+ proxy.test = "Hallo"222+ }).toThrowError(/^Cannot perform.*on a proxy that has been revoked/)223+ expect(() => {224+ const test = proxy.test225+ }).toThrowError(/^Cannot perform.*on a proxy that has been revoked/)226+ })227+228 afterEach(() => {229 expect(baseState).toBe(origBaseState)230 expect(baseState).toEqual(createBaseState())231 })232 233 function createBaseState() {234 return {199- anArray: [3, 2, { c: 3 }, 1],235+ anArray: [3, 2, {c: 3}, 1],236 aProp: "hi",237 anObject: {238 nested: {203- yummie: true239+ yummie: true,240 },205- coffee: false206- }241+ coffee: false,242+ },243 }244 }245 })210-211-describe("readme example", () => {212- it("works", () => {213- const baseState = [214- {215- todo: "Learn typescript",216- done: true217- },218- {219- todo: "Try immer",220- done: false221- }222- ]223-224- const nextState = immer(baseState, state => {225- state.push({ todo: "Tweet about it" })226- state[1].done = true227- })228-229- // the new item is only added to the next state,230- // base state is unmodified231- expect(baseState.length).toBe(2)232- expect(nextState.length).toBe(3)233-234- // same for the changed 'done' prop235- expect(baseState[1].done).toBe(false)236- expect(nextState[1].done).toBe(true)237-238- // unchanged data is structurally shared239- expect(nextState[0]).toBe(baseState[0])240- // changed data not (dûh)241- expect(nextState[1]).not.toBe(baseState[1])242- })243-})added:__tests__/frozen.js+49 added
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849"use strict"import immer from ".."
describe("auto freeze", () => { const baseState = { object: {a: 1}, array: [1, 2], }
it("should freeze objects after modifications", () => { expect(Object.isFrozen(baseState.object)).toBe(false) // initially not frozen const next = immer(baseState, draft => { draft.object.c = 2 }) expect(Object.isFrozen(next.object)).toBe(true) expect(Object.isFrozen(next)).toBe(true) expect(Object.isFrozen(next.array)).toBe(false)
expect(() => { next.object.a = 2 }).toThrow(/Cannot assign to read only property/) })
it("should freeze arrays after modifications", () => { expect(Object.isFrozen(baseState.object)).toBe(false) // initially not frozen const next = immer(baseState, draft => { draft.array.push(3) }) expect(Object.isFrozen(next.object)).toBe(false) // not touched expect(Object.isFrozen(next)).toBe(true) expect(Object.isFrozen(next.array)).toBe(true)
expect(() => { next.array.shift() }).toThrow(/Cannot add\/remove sealed array elements/) })
it("can handle already frozen trees", () => { const a = [] const b = {a: a} Object.freeze(a) Object.freeze(b) const n = immer(b, draft => { draft.c = true draft.a.push(3) }) expect(n).toEqual({c: true, a: [3]}) })})added:__tests__/performance.js+92 added
1+"use strict"2+import immer, {setAutoFreeze} from ".."3+import cloneDeep from "lodash.clonedeep"4+import {List, Record} from "immutable"5+6+describe("performance", () => {7+ const MAX = 1000008+ const MODIFY_FACTOR = 0.19+ const baseState = []10+ let frozenBazeState11+ let immutableJsBaseState12+13+ // produce the base state14+ for (let i = 0; i < MAX; i++) {15+ baseState.push({16+ todo: "todo_" + i,17+ done: false,18+ someThingCompletelyIrrelevant: [1, 2, 3, 4, 5, 6, 7, 8, 9, 0],19+ })20+ }21+22+ // Produce the frozen bazeState23+ frozenBazeState = baseState.map(todo => {24+ const newTodo = {...todo}25+ newTodo.someThingCompletelyIrrelevant = todo.someThingCompletelyIrrelevant.slice()26+ Object.freeze(newTodo.someThingCompletelyIrrelevant)27+ Object.freeze(newTodo)28+ return newTodo29+ })30+ Object.freeze(frozenBazeState)31+32+ // generate immutalbeJS base state33+ const todoRecord = Record({34+ todo: "",35+ done: false,36+ someThingCompletelyIrrelevant: [],37+ })38+ immutableJsBaseState = List(baseState.map(todo => todoRecord(todo)))39+40+ // The benchmarks41+42+ test("just mutate", () => {43+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {44+ baseState[i].done = true45+ }46+ })47+48+ test("deepclone, then mutate", () => {49+ const draft = cloneDeep(baseState)50+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {51+ draft[i].done = true52+ }53+ })54+55+ test("handcrafted reducer", () => {56+ const nextState = [57+ ...baseState.slice(0, MAX * MODIFY_FACTOR).map(todo => ({58+ ...todo,59+ done: true,60+ })),61+ ...baseState.slice(MAX * MODIFY_FACTOR),62+ ]63+ })64+65+ test("immutableJS", () => {66+ let state = immutableJsBaseState67+ state.withMutations(state => {68+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {69+ state.setIn([i, "done"], true)70+ }71+ })72+ })73+74+ test("immer - with autofreeze", () => {75+ setAutoFreeze(true)76+ immer(frozenBazeState, draft => {77+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {78+ draft[i].done = true79+ }80+ })81+ })82+83+ test("immer - without autofreeze", () => {84+ setAutoFreeze(false)85+ immer(baseState, draft => {86+ for (let i = 0; i < MAX * MODIFY_FACTOR; i++) {87+ draft[i].done = true88+ }89+ })90+ setAutoFreeze(true)91+ })92+})added:__tests__/readme.js+36 added
123456789101112131415161718192021222324252627282930313233343536"use strict"import immer from ".."
describe("readme example", () => { it("works", () => { const baseState = [ { todo: "Learn typescript", done: true, }, { todo: "Try immer", done: false, }, ]
const nextState = immer(baseState, draft => { draft.push({todo: "Tweet about it"}) draft[1].done = true })
// the new item is only added to the next state, // base state is unmodified expect(baseState.length).toBe(2) expect(nextState.length).toBe(3)
// same for the changed 'done' prop expect(baseState[1].done).toBe(false) expect(nextState[1].done).toBe(true)
// unchanged data is structurally shared expect(nextState[0]).toBe(baseState[0]) // changed data not (dûh) expect(nextState[1]).not.toBe(baseState[1]) })})modified:.gitignore+1 added
55 unmodified lines56 57 # dotenv environment variables file58 .env59 60+.ideaadded:.prettierrc+19 added
1+{2+ "bracketSpacing": false,3+ "printWidth": 80,4+ "proseWrap": "never",5+ "requirePragma": false,6+ "semi": false,7+ "singleQuote": false,8+ "tabWidth": 4,9+ "trailingComma": "all",10+ "useTabs": false,11+ "overrides": [12+ {13+ "files": "*.json",14+ "options": {15+ "printWidth": 20016+ }17+ }18+ ]19+}added:.travis.yml+9 added
123456789language: node_jsnode_js: - "node" - "8"env:- NODE_ENV=TESTcache: directories: - "node_modules"added:changelog.md+14 added
1234567891011121314# Changelog
### 0.1.0 (1-1-2018)
* Fixed `immer` function export, it is now properly exposed as the `default` export. So `import immer from "immer"`. See [#15](https://github.com/mweststrate/immer/pull/15)* Immer now automatically freezes any state modifications made. Turn this is using `setAutoFreeze(false)` for more efficiency in production builds. See [#15](https://github.com/mweststrate/immer/pull/15)* Added support for frozen state trees in strict mode. See [#15](https://github.com/mweststrate/immer/pull/15)* `immer` will now warn if you accidentally return something from the _thunk_. Fixes [#] through [#16](https://github.com/mweststrate/immer/pull/16/). By [Gregory Assasie](https://github.com/Gregjarvez).* Proxies are now automatically cleaned up. This makes it impossible to read proxies after the `immer` function has finished. This prevents users from accidentally reading stale date. [#14](https://github.com/mweststrate/immer/pull/14) by [@benbraou](https://github.com/benbraou)
### 0.0.4 (31-12-2017)
* Added typescript typings [#11](https://github.com/mweststrate/immer/pull/11) by [@benbraou](https://github.com/benbraou)* Fixed bug when setting properties to `undefined`. Fixes [#12](https://github.com/mweststrate/immer/issues/12) through [#13](https://github.com/mweststrate/immer/pull/13) by [@benbraou](https://github.com/benbraou)modified:immer.js+110 added-38 removed
1+"use strict"2 // @ts-check3 3-const isProxySymbol = Symbol("immer-proxy")4+/**5+ * @typedef {Object} RevocableProxy6+ * @property {any} proxy7+ * @property {Function} revoke8+ */9 10+const IMMER_PROXY = Symbol("immer-proxy") // TODO: create per closure, to avoid sharing proxies between multiple immer version11+12+// This property indicates that the current object is cloned for another object,13+// to make sure the proxy of a frozen object is writeable14+const CLONE_TARGET = Symbol("immer-clone-target")15+16+let autoFreeze = true17+18 /**19 * Immer takes a state, and runs a function against it.20 * That function can freely mutate the state, as it will create copies-on-write.21 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned3 unmodified lines25 * @param {Function} thunk - function that receives a proxy of the base state as first argument and which can be freely modified26 * @returns {any} a new state, or the base state if nothing was modified27 */28 function immer(baseState, thunk) {16- // Maps baseState objects to proxies17- const proxies = new Map()29+ /**30+ * Maps baseState objects to revocable proxies31+ * @type {Map<Object,RevocableProxy>}32+ */33+ const revocableProxies = new Map()34 // Maps baseState objects to their copies35+36 const copies = new Map()37 38 const objectTraps = {39 get(target, prop) {23- if (prop === isProxySymbol) return target40+ if (prop === IMMER_PROXY) return target41 return createProxy(getCurrentSource(target)[prop])42 },43 has(target, prop) {44 return prop in getCurrentSource(target)5 unmodified lines50 const current = createProxy(getCurrentSource(target)[prop])51 const newValue = createProxy(value)52 if (current !== newValue) {53 const copy = getOrCreateCopy(target)37- copy[prop] = isProxy(newValue) ? newValue[isProxySymbol] : newValue54+ copy[prop] = isProxy(newValue)55+ ? newValue[IMMER_PROXY]56+ : newValue57 }58 return true59 },60 deleteProperty(target, property) {61 const copy = getOrCreateCopy(target)62 delete copy[property]63 return true45- }64+ },65 }66 67 // creates a copy for a base object if there ain't one68 function getOrCreateCopy(base) {69 let copy = copies.get(base)51- if (!copy) {52- copy = Array.isArray(base) ? base.slice() : Object.assign({}, base)53- copies.set(base, copy)70+ if (copy) return copy71+ const cloneTarget = base[CLONE_TARGET]72+ if (cloneTarget) {73+ // base is a clone already (source was frozen), no need to create addtional copy74+ copies.set(cloneTarget, base)75+ return base76 }77+ // create a fresh copy78+ copy = Array.isArray(base) ? base.slice() : Object.assign({}, base)79+ copies.set(base, copy)80 return copy81 }82 83 // returns the current source of truth for a base object5 unmodified lines89 // creates a proxy for plain objects / arrays90 function createProxy(base) {91 if (isPlainObject(base) || Array.isArray(base)) {92 if (isProxy(base)) return base // avoid double wrapping68- if (proxies.has(base)) return proxies.get(base)69- const proxy = new Proxy(base, objectTraps)70- proxies.set(base, proxy)71- return proxy93+ if (revocableProxies.has(base))94+ return revocableProxies.get(base).proxy95+ let proxyTarget96+ // special case, if the base tree is frozen, we cannot modify it's proxy it in strict mode, clone first.97+ if (Object.isFrozen(base)) {98+ proxyTarget = Array.isArray(base)99+ ? base.slice()100+ : Object.assign({}, base)101+ Object.defineProperty(proxyTarget, CLONE_TARGET, {102+ enumerable: false,103+ value: base,104+ configurable: true,105+ })106+ } else {107+ proxyTarget = base108+ }109+ // create the proxy110+ const revocableProxy = Proxy.revocable(proxyTarget, objectTraps)111+ revocableProxies.set(base, revocableProxy)112+ return revocableProxy.proxy113 }114 return base115 }116 117 // checks if the given base object has modifications, either because it is modified, or118 // because one of it's children is119 function hasChanges(base) {79- const proxy = proxies.get(base)120+ const proxy = revocableProxies.get(base)121 if (!proxy) return false // nobody did read this object122 if (copies.has(base)) return true // a copy was created, so there are changes123 // look deeper124 const keys = Object.keys(base)125 for (let i = 0; i < keys.length; i++) {126 const value = base[keys[i]]86- if ((Array.isArray(value) || isPlainObject(value)) && hasChanges(value)) return true127+ if (128+ (Array.isArray(value) || isPlainObject(value)) &&129+ hasChanges(value)130+ )131+ return true132 }133 return false134 }135 5 unmodified lines141 }142 143 function finalizeObject(thing) {144 if (!hasChanges(thing)) return thing100- const copy = getOrCreateCopy(thing)145+ const copy = getOrCreateCopy(thing) // TODO: getOrCreate is weird here..146 Object.keys(copy).forEach(prop => {147 copy[prop] = finalize(copy[prop])148 })104- return copy149+ delete copy[CLONE_TARGET]150+ return freeze(copy)151 }152 153 function finalizeArray(thing) {154 if (!hasChanges(thing)) return thing109- const copy = getOrCreateCopy(thing)155+ const copy = getOrCreateCopy(thing) // TODO: getOrCreate is weird here..156 copy.forEach((value, index) => {157 copy[index] = finalize(copy[index])158 })113- return copy159+ delete copy[CLONE_TARGET]160+ return freeze(copy)161 }162 116- function prettify(msg){117- const isObject = typeof msg === 'object' && !Array.isArray(msg) &&118- 'an object';119-120- const isEmptyString = (/ /.test(msg) || (typeof msg === 'string' && msg.length === 0)) &&121- 'an empty string';122-123- const prettyObjectOrEmptyStringMsg = (isObject || isEmptyString);124-125- return prettyObjectOrEmptyStringMsg || msg;126- }127-163 // create proxy for root164 const rootClone = createProxy(baseState)165 // execute the thunk166 const maybeVoidReturn = thunk(rootClone)132-133- //coerce undefined || null values to short circuit : returning something will trigger warning;134- !Object.is(maybeVoidReturn, undefined) &&135- console.warn(`Immer callback expects no return value. However %s was returned`, prettify(maybeVoidReturn))136-167+ //values either than undefined will trigger warning;168+ !Object.is(maybeVoidReturn, undefined) &&169+ console.warn(170+ `Immer callback expects no return value. However ${typeof maybeVoidReturn} was returned`,171+ )172+ // console.log(`proxies: ${revocableProxies.size}, copies: ${copies.size}`)173+ // revoke all proxies174+ revoke(revocableProxies)175 // and finalize the modified proxy176 return finalize(baseState)177 }178 179+/**180+ * Revoke all the proxies stored in the revocableProxies map181+ *182+ * @param {Map<Object,RevocableProxy>} revocableProxies183+ */184+function revoke(revocableProxies) {185+ for (var revocableProxy of revocableProxies.values()) {186+ revocableProxy.revoke()187+ }188+}189+190 function isPlainObject(value) {191 if (value === null || typeof value !== "object") return false192 const proto = Object.getPrototypeOf(value)193 return proto === Object.prototype || proto === null194 }195 196 function isProxy(value) {148- return !!value && !!value[isProxySymbol]197+ return !!value && !!value[IMMER_PROXY]198 }199 200+function freeze(value) {201+ if (autoFreeze) {202+ Object.freeze(value)203+ }204+ return value205+}206+207+/**208+ * Automatically freezes any state trees generated by immer.209+ * This protects against accidental modifications of the state tree outside of an immer function.210+ * This comes with a performance impact, so it is recommended to disable this option in production.211+ * It is by default enabled.212+ *213+ * @returns {void}214+ */215+function setAutoFreeze(enableAutoFreeze) {216+ autoFreeze = enableAutoFreeze217+}218+219+Object.defineProperty(exports, "__esModule", {220+ value: true,221+})151-module.exports = immer222+module.exports.default = immer223+module.exports.setAutoFreeze = setAutoFreezemodified:index.d.ts+13 added-2 removed
1 /**2 * Immer takes a state, and runs a function against it.3 * That function can freely mutate the state, as it will create copies-on-write.4 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned5- * 5+ *6 * @param currentState - the state to start with7 * @param thunk - function that receives a proxy of the current state as first argument and which can be freely modified8 * @returns The next state: a new state, or the current state if nothing was modified9 */10-export function immer<S = any>(currentState: S, thunk: (draftState: S) => void): S;10+export default function<S = any>(11+ currentState: S,12+ thunk: (draftState: S) => void,13+): S14+15+/**16+ * Automatically freezes any state trees generated by immer.17+ * This protects against accidental modifications of the state tree outside of an immer function.18+ * This comes with a performance impact, so it is recommended to disable this option in production.19+ * It is by default enabled.20+ */21+export function setAutoFreeze(autoFreeze: boolean)modified:package.json+10 added-2 removed
1 {2 "name": "immer",3- "version": "0.0.4",3+ "version": "0.1.0",4 "description": "Create your next immutable state by mutating the current one",5 "main": "immer.js",6 "types": "./index.d.ts",7 "scripts": {8- "test": "jest"8+ "test": "jest",9+ "prettier": "prettier \"*/**/*.js\" --ignore-path ./.prettierignore --write && git add . && git status"10 },11+ "pre-commit": [12+ "prettier"13+ ],14 "repository": {15 "type": "git",16 "url": "git+https://github.com/mweststrate/immer.git"17 },15 unmodified lines33 "@types/jest": "^22.0.0",34 "babel-core": "^6.26.0",35 "babel-jest": "^22.0.4",36 "babel-preset-env": "^1.6.1",37+ "immutable": "^3.8.2",38 "jest": "^22.0.4",39+ "lodash.clonedeep": "^4.5.0",40+ "pre-commit": "^1.2.2",41+ "prettier": "^1.9.2",42 "regenerator-runtime": "^0.11.1",43 "typescript": "^2.6.2"44 },45 "jest": {5 unmodified linesmodified:readme.md+37 added-15 removed
1 # Immer2 3-_Your personal assistant for creating your next immutable state_3+_Create the next immutable state tree by simply modifying the current tree_4 5 ---6 7 Immer (German for: always) is a tiny package that allows you to work with immutable state in a more convenient way.4 unmodified lines12 <center>13 14 15 16-Using immer is like having a personal assistant; he takes a letter (the current state), and gives you a copy (draft) to jot changes onto. Once you are done the assistant will take your draft and produce the real immutable, final letter for you (the next state).16+Using immer is like having a personal assistant; he takes a letter (the current state), and gives you a copy (draft) to jot changes onto. Once you are done, the assistant will take your draft and produce the real immutable, final letter for you (the next state).17 </center>18 19 ## API20 46 unmodified lines67 * Deep updates are trivial68 * Small, dependency free library with minimal api surface69 * No accidental mutations of current state, but intentional mutations of a draft state70 71+## Auto freezing72+73+ Immer automatically freezes any state trees that are modified using `immer.74+ This protects against accidental modifications of the state tree outside of an immer function.75+ This comes with a performance impact, so it is recommended to disable this option in production.76+ It is by default enabled.77+78+ Use `setAutoFreeze(true / false)` to turn this feature on or off.79+80 ## Reducer Example81 73-A lot of words; here is a simple example of what difference that could make in practice.82+A lot of words; here is a simple example of the difference that this approach could make in practice.83 The todo reducers from the official Redux [todos-with-undo example](https://codesandbox.io/s/github/reactjs/redux/tree/master/examples/todos-with-undo)84 76-_Note, this is just a sample application of the `immer` package. Immer is designed to just simplify Redux reducers. It can be used in any context where you have an immutable data tree that you want to clone and modify (with structural sharing)_85+_Note, this is just a sample application of the `immer` package. Immer is not just designed to simplify Redux reducers. It can be used in any context where you have an immutable data tree that you want to clone and modify (with structural sharing)_86 87 ```javascript88 const todo = (state, action) => {89 switch (action.type) {57 unmodified lines147 }148 })149 ```150 142-Creating middleware or reducer wrapper that applies `immer` automatically is left as exercise to the reader :-).151+Creating middleware or a reducer wrapper that applies `immer` automatically is left as exercise for the reader :-).152 153+## Performance154+155+Here is a [simple benchmark](__tests__/performance.js) on the performance of `immer`.156+This test takes 100.000 todo items, and updates 10.000 of them.157+These tests were executed on Node 8.4.0158+159+```160+ performance161+ ✓ just mutate (1ms) // No immutability at all162+ ✓ deepclone, then mutate (647ms) // Clone entire tree, then mutate (no structural sharing!)163+ ✓ handcrafted reducer (17ms) // Implement it as typical Redux reducer, with slices and spread operator164+ ✓ immutableJS (81ms) // Use immutableJS and leverage `withMutations` for best performance165+ ✓ immer - with autofreeze (309ms) // Immer, with auto freeze enabled166+ ✓ immer - without autofreeze (148ms) // Immer, but without auto freeze enabled167+```168+169 ## Limitations170 146-* This package requires Proxies, so Safari > 10, no Internet Explorer147-* Currently only tree shaped states are supported. Cycles could potentially be supported as well (PR's welcome)148-* Currently only supports plain objects and arrays. Non-plain data structures (like `Map`, `Set`) not (yet). (PR's welcome)171+* This package requires Proxies, so Safari > 9, no Internet Explorer, no React Native on Android. This can potentially done, so feel free to upvote on [#8](https://github.com/mweststrate/immer/issues/8) if you need this :)172+* Currently, only tree shaped states are supported. Cycles could potentially be supported as well (PR's welcome)173+* Currently, only supports plain objects and arrays. Non-plain data structures (like `Map`, `Set`) not (yet). (PR's welcome)174 175 ## Pitfalls:176 152-* Make sure to modify the state you get passed in the callback function, not the original base state that was passed as first argument to `immer`!153-* Since immer uses proxies, reading huge amounts of data from state comes with an overhead. If this ever becomes an issue (measure before optimize!), do the current state analysis before entering the `immer` block or read from the `currentState` rather than the `draftState`177+* Make sure to modify the draft state you get passed in in the callback function, not the original current state that was passed as the first argument to `immer`!178+* Since immer uses proxies, reading huge amounts of data from state comes with an overhead. If this ever becomes an issue (measure before you optimize!), do the current state analysis before entering the `immer` block or read from the `currentState` rather than the `draftState`179 155-## Changelog180+## Credits181 157-### 0.0.4 (31-12-2017)158-159-* Added typescript typings [#11](https://github.com/mweststrate/immer/pull/11) by [@benbraou](https://github.com/benbraou)160-* Fixed bug when setting properties to `undefined`. Fixes [#12](https://github.com/mweststrate/immer/issues/12) through [#13](https://github.com/mweststrate/immer/pull/13) by [@benbraou](https://github.com/benbraou)182+Special thanks goes to @Mendix, which supports it's employees to experiment completely freely two full days a month, which formed the kick-start for this project.modified:yarn.lock+49 added-352 removed
30 unmodified lines31 resolved "https://registry.yarnpkg.com/acorn-globals/-/acorn-globals-4.1.0.tgz#ab716025dbe17c54d3ef81d32ece2b2d99fe2538"32 dependencies:33 acorn "^5.0.0"34 35-acorn-jsx@^3.0.0:36- version "3.0.1"37- resolved "https://registry.yarnpkg.com/acorn-jsx/-/acorn-jsx-3.0.1.tgz#afdf9488fb1ecefc8348f6fb22f464e32a58b36b"38- dependencies:39- acorn "^3.0.4"40-41-acorn@^3.0.4:42- version "3.3.0"43- resolved "https://registry.yarnpkg.com/acorn/-/acorn-3.3.0.tgz#45e37fb39e8da3f25baee3ff5369e2bb5f22017a"44-45-acorn@^5.0.0, acorn@^5.1.2, acorn@^5.2.1:35+acorn@^5.0.0, acorn@^5.1.2:36 version "5.3.0"37 resolved "https://registry.yarnpkg.com/acorn/-/acorn-5.3.0.tgz#7446d39459c54fb49a80e6ee6478149b940ec822"38 49-ajv-keywords@^2.1.0:50- version "2.1.1"51- resolved "https://registry.yarnpkg.com/ajv-keywords/-/ajv-keywords-2.1.1.tgz#617997fc5f60576894c435f940d819e135b80762"52-39 ajv@^4.9.1:40 version "4.11.8"41 resolved "https://registry.yarnpkg.com/ajv/-/ajv-4.11.8.tgz#82ffb02b29e662ae53bdc20af15947706739c536"42 dependencies:43 co "^4.6.0"44 json-stable-stringify "^1.0.1"45 60-ajv@^5.1.0, ajv@^5.2.3, ajv@^5.3.0:46+ajv@^5.1.0:47 version "5.5.2"48 resolved "https://registry.yarnpkg.com/ajv/-/ajv-5.5.2.tgz#73b5eeca3fab653e3d3f9422b341ad42205dc965"49 dependencies:50 co "^4.6.0"78 unmodified lines129 array-equal@^1.0.0:130 version "1.0.0"131 resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"132 147-array-union@^1.0.1:148- version "1.0.2"149- resolved "https://registry.yarnpkg.com/array-union/-/array-union-1.0.2.tgz#9a34410e4f4e3da23dea375be5be70f24778ec39"150- dependencies:151- array-uniq "^1.0.1"152-153-array-uniq@^1.0.1:154- version "1.0.3"155- resolved "https://registry.yarnpkg.com/array-uniq/-/array-uniq-1.0.3.tgz#af6ac877a25cc7f74e058894753858dfdb24fdb6"156-133 array-unique@^0.2.1:134 version "0.2.1"135 resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"136 161-arrify@^1.0.0, arrify@^1.0.1:137+arrify@^1.0.1:138 version "1.0.1"139 resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"140 141 asn1@~0.2.3:37 unmodified lines179 aws4@^1.2.1, aws4@^1.6.0:180 version "1.6.0"181 resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.6.0.tgz#83ef5ca860b2b32e4a0deedee8c771b9db57471e"182 207-babel-code-frame@^6.22.0, babel-code-frame@^6.26.0:183+babel-code-frame@^6.26.0:184 version "6.26.0"185 resolved "https://registry.yarnpkg.com/babel-code-frame/-/babel-code-frame-6.26.0.tgz#63fd43f7dc1e3bb7ce35947db8fe369a3f58c74b"186 dependencies:187 chalk "^1.1.3"559 unmodified lines747 builtin-modules@^1.0.0:748 version "1.1.1"749 resolved "https://registry.yarnpkg.com/builtin-modules/-/builtin-modules-1.1.1.tgz#270f076c5a72c02f5b65a47df94c5fe3a278892f"750 775-caller-path@^0.1.0:776- version "0.1.0"777- resolved "https://registry.yarnpkg.com/caller-path/-/caller-path-0.1.0.tgz#94085ef63581ecd3daa92444a8fe94e82577751f"778- dependencies:779- callsites "^0.2.0"780-781-callsites@^0.2.0:782- version "0.2.0"783- resolved "https://registry.yarnpkg.com/callsites/-/callsites-0.2.0.tgz#afab96262910a7f33c19a5775825c69f34e350ca"784-751 callsites@^2.0.0:752 version "2.0.0"753 resolved "https://registry.yarnpkg.com/callsites/-/callsites-2.0.0.tgz#06eb84f00eea413da86affefacbffb36093b3c50"754 29 unmodified lines784 has-ansi "^2.0.0"785 strip-ansi "^3.0.0"786 supports-color "^2.0.0"787 822-chalk@^2.0.0, chalk@^2.0.1, chalk@^2.1.0:788+chalk@^2.0.0, chalk@^2.0.1:789 version "2.3.0"790 resolved "https://registry.yarnpkg.com/chalk/-/chalk-2.3.0.tgz#b5ea48efc9c1793dccc9b4767c93914d3f2d52ba"791 dependencies:792 ansi-styles "^3.1.0"793 escape-string-regexp "^1.0.5"794 supports-color "^4.0.0"795 830-chardet@^0.4.0:831- version "0.4.2"832- resolved "https://registry.yarnpkg.com/chardet/-/chardet-0.4.2.tgz#b5473b33dc97c424e5d98dc87d55d4d8a29c8bf2"833-796 ci-info@^1.0.0:797 version "1.1.2"798 resolved "https://registry.yarnpkg.com/ci-info/-/ci-info-1.1.2.tgz#03561259db48d0474c8bdc90f5b47b068b6bbfb4"799 838-circular-json@^0.3.1:839- version "0.3.3"840- resolved "https://registry.yarnpkg.com/circular-json/-/circular-json-0.3.3.tgz#815c99ea84f6809529d2f45791bdf82711352d66"841-842-cli-cursor@^2.1.0:843- version "2.1.0"844- resolved "https://registry.yarnpkg.com/cli-cursor/-/cli-cursor-2.1.0.tgz#b35dac376479facc3e94747d41d0d0f5238ffcb5"845- dependencies:846- restore-cursor "^2.0.0"847-848-cli-width@^2.0.0:849- version "2.2.0"850- resolved "https://registry.yarnpkg.com/cli-width/-/cli-width-2.2.0.tgz#ff19ede8a9a5e579324147b0c11f0fbcbabed639"851-800 cliui@^2.1.0:801 version "2.1.0"802 resolved "https://registry.yarnpkg.com/cliui/-/cliui-2.1.0.tgz#4b475760ff80264c762c3a1719032e91c7fea0d1"803 dependencies:36 unmodified lines840 concat-map@0.0.1:841 version "0.0.1"842 resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"843 896-concat-stream@^1.6.0:844+concat-stream@^1.4.7:845 version "1.6.0"846 resolved "https://registry.yarnpkg.com/concat-stream/-/concat-stream-1.6.0.tgz#0aac662fd52be78964d5532f694784e70110acf7"847 dependencies:848 inherits "^2.0.3"19 unmodified lines868 core-util-is@1.0.2, core-util-is@~1.0.0:869 version "1.0.2"870 resolved "https://registry.yarnpkg.com/core-util-is/-/core-util-is-1.0.2.tgz#b5fd54220aa2bc5ab57aab7140c940754503c1a7"871 924-cross-spawn@^5.0.1, cross-spawn@^5.1.0:872+cross-spawn@^5.0.1:873 version "5.1.0"874 resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-5.1.0.tgz#e8bd0efee58fcff6f8f94510a0a554bbfa235449"875 dependencies:876 lru-cache "^4.0.1"64 unmodified lines941 dependencies:942 foreach "^2.0.5"943 object-keys "^1.0.8"944 997-del@^2.0.2:998- version "2.2.2"999- resolved "https://registry.yarnpkg.com/del/-/del-2.2.2.tgz#c12c981d067846c84bcaf862cff930d907ffd1a8"1000- dependencies:1001- globby "^5.0.0"1002- is-path-cwd "^1.0.0"1003- is-path-in-cwd "^1.0.0"1004- object-assign "^4.0.1"1005- pify "^2.0.0"1006- pinkie-promise "^2.0.0"1007- rimraf "^2.2.8"1008-945 delayed-stream@~1.0.0:946 version "1.0.0"947 resolved "https://registry.yarnpkg.com/delayed-stream/-/delayed-stream-1.0.0.tgz#df3ae199acadfb7d440aaae0b29e2272b24ec619"948 18 unmodified lines967 diff@^3.2.0:968 version "3.4.0"969 resolved "https://registry.yarnpkg.com/diff/-/diff-3.4.0.tgz#b1d85507daf3964828de54b37d0d73ba67dda56c"970 1035-doctrine@^2.0.2:1036- version "2.0.2"1037- resolved "https://registry.yarnpkg.com/doctrine/-/doctrine-2.0.2.tgz#68f96ce8efc56cc42651f1faadb4f175273b0075"1038- dependencies:1039- esutils "^2.0.2"1040-971 domexception@^1.0.0:972 version "1.0.0"973 resolved "https://registry.yarnpkg.com/domexception/-/domexception-1.0.0.tgz#81fe5df81b3f057052cde3a9fa9bf536a85b9ab0"974 51 unmodified lines1026 optionator "^0.8.1"1027 optionalDependencies:1028 source-map "~0.5.6"1029 1100-eslint-scope@^3.7.1:1101- version "3.7.1"1102- resolved "https://registry.yarnpkg.com/eslint-scope/-/eslint-scope-3.7.1.tgz#3d63c3edfda02e06e01a452ad88caacc7cdcb6e8"1103- dependencies:1104- esrecurse "^4.1.0"1105- estraverse "^4.1.1"1106-1107-eslint-visitor-keys@^1.0.0:1108- version "1.0.0"1109- resolved "https://registry.yarnpkg.com/eslint-visitor-keys/-/eslint-visitor-keys-1.0.0.tgz#3f3180fb2e291017716acb4c9d6d5b5c34a6a81d"1110-1111-eslint@^4.14.0:1112- version "4.14.0"1113- resolved "https://registry.yarnpkg.com/eslint/-/eslint-4.14.0.tgz#96609768d1dd23304faba2d94b7fefe5a5447a82"1114- dependencies:1115- ajv "^5.3.0"1116- babel-code-frame "^6.22.0"1117- chalk "^2.1.0"1118- concat-stream "^1.6.0"1119- cross-spawn "^5.1.0"1120- debug "^3.1.0"1121- doctrine "^2.0.2"1122- eslint-scope "^3.7.1"1123- eslint-visitor-keys "^1.0.0"1124- espree "^3.5.2"1125- esquery "^1.0.0"1126- esutils "^2.0.2"1127- file-entry-cache "^2.0.0"1128- functional-red-black-tree "^1.0.1"1129- glob "^7.1.2"1130- globals "^11.0.1"1131- ignore "^3.3.3"1132- imurmurhash "^0.1.4"1133- inquirer "^3.0.6"1134- is-resolvable "^1.0.0"1135- js-yaml "^3.9.1"1136- json-stable-stringify-without-jsonify "^1.0.1"1137- levn "^0.3.0"1138- lodash "^4.17.4"1139- minimatch "^3.0.2"1140- mkdirp "^0.5.1"1141- natural-compare "^1.4.0"1142- optionator "^0.8.2"1143- path-is-inside "^1.0.2"1144- pluralize "^7.0.0"1145- progress "^2.0.0"1146- require-uncached "^1.0.3"1147- semver "^5.3.0"1148- strip-ansi "^4.0.0"1149- strip-json-comments "~2.0.1"1150- table "^4.0.1"1151- text-table "~0.2.0"1152-1153-espree@^3.5.2:1154- version "3.5.2"1155- resolved "https://registry.yarnpkg.com/espree/-/espree-3.5.2.tgz#756ada8b979e9dcfcdb30aad8d1a9304a905e1ca"1156- dependencies:1157- acorn "^5.2.1"1158- acorn-jsx "^3.0.0"1159-1030 esprima@^3.1.3:1031 version "3.1.3"1032 resolved "https://registry.yarnpkg.com/esprima/-/esprima-3.1.3.tgz#fdca51cee6133895e3c88d535ce49dbff62a4633"1033 1034 esprima@^4.0.0:1035 version "4.0.0"1036 resolved "https://registry.yarnpkg.com/esprima/-/esprima-4.0.0.tgz#4499eddcd1110e0b218bacf2fa7f7f59f55ca804"1037 1168-esquery@^1.0.0:1169- version "1.0.0"1170- resolved "https://registry.yarnpkg.com/esquery/-/esquery-1.0.0.tgz#cfba8b57d7fba93f17298a8a006a04cda13d80fa"1171- dependencies:1172- estraverse "^4.0.0"1173-1174-esrecurse@^4.1.0:1038+estraverse@^4.2.0:1039 version "4.2.0"1176- resolved "https://registry.yarnpkg.com/esrecurse/-/esrecurse-4.2.0.tgz#fa9568d98d3823f9a41d91e902dcab9ea6e5b163"1177- dependencies:1178- estraverse "^4.1.0"1179- object-assign "^4.0.1"1180-1181-estraverse@^4.0.0, estraverse@^4.1.0, estraverse@^4.1.1, estraverse@^4.2.0:1182- version "4.2.0"1040 resolved "https://registry.yarnpkg.com/estraverse/-/estraverse-4.2.0.tgz#0dee3fed31fcd469618ce7342099fc1afa0bdb13"1041 1042 esutils@^2.0.2:1043 version "2.0.2"43 unmodified lines1087 extend@~3.0.0, extend@~3.0.1:1088 version "3.0.1"1089 resolved "https://registry.yarnpkg.com/extend/-/extend-3.0.1.tgz#a755ea7bc1adfcc5a31ce7e762dbaadc5e636444"1090 1234-external-editor@^2.0.4:1235- version "2.1.0"1236- resolved "https://registry.yarnpkg.com/external-editor/-/external-editor-2.1.0.tgz#3d026a21b7f95b5726387d4200ac160d372c3b48"1237- dependencies:1238- chardet "^0.4.0"1239- iconv-lite "^0.4.17"1240- tmp "^0.0.33"1241-1091 extglob@^0.3.1:1092 version "0.3.2"1093 resolved "https://registry.yarnpkg.com/extglob/-/extglob-0.3.2.tgz#2e18ff3d2f49ab2765cec9023f011daa8d8349a1"1094 dependencies:24 unmodified lines1119 resolved "https://registry.yarnpkg.com/fb-watchman/-/fb-watchman-2.0.0.tgz#54e9abf7dfa2f26cd9b1636c588c1afc05de5d58"1120 dependencies:1121 bser "^2.0.0"1122 1274-figures@^2.0.0:1275- version "2.0.0"1276- resolved "https://registry.yarnpkg.com/figures/-/figures-2.0.0.tgz#3ab1a2d2a62c8bfb431a0c94cb797a2fce27c962"1277- dependencies:1278- escape-string-regexp "^1.0.5"1279-1280-file-entry-cache@^2.0.0:1281- version "2.0.0"1282- resolved "https://registry.yarnpkg.com/file-entry-cache/-/file-entry-cache-2.0.0.tgz#c392990c3e684783d838b8c84a45d8a048458361"1283- dependencies:1284- flat-cache "^1.2.1"1285- object-assign "^4.0.1"1286-1123 filename-regex@^2.0.0:1124 version "2.0.1"1125 resolved "https://registry.yarnpkg.com/filename-regex/-/filename-regex-2.0.1.tgz#c1c4b9bee3e09725ddb106b75c1e301fe2f18b26"1126 26 unmodified lines1153 resolved "https://registry.yarnpkg.com/find-up/-/find-up-2.1.0.tgz#45d1b7e506c717ddd482775a2b77920a3c0c57a7"1154 dependencies:1155 locate-path "^2.0.0"1156 1321-flat-cache@^1.2.1:1322- version "1.3.0"1323- resolved "https://registry.yarnpkg.com/flat-cache/-/flat-cache-1.3.0.tgz#d3030b32b38154f4e3b7e9c709f490f7ef97c481"1324- dependencies:1325- circular-json "^0.3.1"1326- del "^2.0.2"1327- graceful-fs "^4.1.2"1328- write "^0.2.1"1329-1157 for-in@^1.0.1:1158 version "1.0.2"1159 resolved "https://registry.yarnpkg.com/for-in/-/for-in-1.0.2.tgz#81068d295a8142ec0ac726c6e2200c30fb6d5e80"1160 58 unmodified lines1219 function-bind@^1.0.2, function-bind@^1.1.1:1220 version "1.1.1"1221 resolved "https://registry.yarnpkg.com/function-bind/-/function-bind-1.1.1.tgz#a56899d3ea3c9bab874bb9773b7c5ede92f4895d"1222 1396-functional-red-black-tree@^1.0.1:1397- version "1.0.1"1398- resolved "https://registry.yarnpkg.com/functional-red-black-tree/-/functional-red-black-tree-1.0.1.tgz#1b0ab3bd553b2a0d6399d29c0e3ea0b252078327"1399-1223 gauge@~2.7.3:1224 version "2.7.4"1225 resolved "https://registry.yarnpkg.com/gauge/-/gauge-2.7.4.tgz#2c03405c7538c39d7eb37b317022e325fb018bf7"1226 dependencies:43 unmodified lines1270 minimatch "^3.0.4"1271 once "^1.3.0"1272 path-is-absolute "^1.0.0"1273 1451-globals@^11.0.1:1452- version "11.1.0"1453- resolved "https://registry.yarnpkg.com/globals/-/globals-11.1.0.tgz#632644457f5f0e3ae711807183700ebf2e4633e4"1454-1274 globals@^9.18.0:1275 version "9.18.0"1276 resolved "https://registry.yarnpkg.com/globals/-/globals-9.18.0.tgz#aa3896b3e69b487f17e31ed2143d69a8e30c2d8a"1277 1459-globby@^5.0.0:1460- version "5.0.0"1461- resolved "https://registry.yarnpkg.com/globby/-/globby-5.0.0.tgz#ebd84667ca0dbb330b99bcfc68eac2bc54370e0d"1462- dependencies:1463- array-union "^1.0.1"1464- arrify "^1.0.0"1465- glob "^7.0.3"1466- object-assign "^4.0.1"1467- pify "^2.0.0"1468- pinkie-promise "^2.0.0"1469-1278 graceful-fs@^4.1.11, graceful-fs@^4.1.2:1279 version "4.1.11"1280 resolved "https://registry.yarnpkg.com/graceful-fs/-/graceful-fs-4.1.11.tgz#0e8bdfe4d1ddb8854d64e04ea7c00e2a026e5658"1281 115 unmodified lines1397 assert-plus "^1.0.0"1398 jsprim "^1.2.2"1399 sshpk "^1.7.0"1400 1593-iconv-lite@0.4.19, iconv-lite@^0.4.17:1401+iconv-lite@0.4.19:1402 version "0.4.19"1403 resolved "https://registry.yarnpkg.com/iconv-lite/-/iconv-lite-0.4.19.tgz#f7468f60135f5e5dad3399c0a81be9a1603a082b"1404 1597-ignore@^3.3.3:1598- version "3.3.7"1599- resolved "https://registry.yarnpkg.com/ignore/-/ignore-3.3.7.tgz#612289bfb3c220e186a58118618d5be8c1bab021"1405+immutable@^3.8.2:1406+ version "3.8.2"1407+ resolved "https://registry.yarnpkg.com/immutable/-/immutable-3.8.2.tgz#c2439951455bb39913daf281376f1530e104adf3"1408 1409 imurmurhash@^0.1.4:1410 version "0.1.4"1411 resolved "https://registry.yarnpkg.com/imurmurhash/-/imurmurhash-0.1.4.tgz#9218b9b2b928a238b13dc4fb6b6d576f231453ea"12 unmodified lines1424 ini@~1.3.0:1425 version "1.3.5"1426 resolved "https://registry.yarnpkg.com/ini/-/ini-1.3.5.tgz#eee25f56db1c9ec6085e0c22778083f596abf927"1427 1620-inquirer@^3.0.6:1621- version "3.3.0"1622- resolved "https://registry.yarnpkg.com/inquirer/-/inquirer-3.3.0.tgz#9dd2f2ad765dcab1ff0443b491442a20ba227dc9"1623- dependencies:1624- ansi-escapes "^3.0.0"1625- chalk "^2.0.0"1626- cli-cursor "^2.1.0"1627- cli-width "^2.0.0"1628- external-editor "^2.0.4"1629- figures "^2.0.0"1630- lodash "^4.3.0"1631- mute-stream "0.0.7"1632- run-async "^2.2.0"1633- rx-lite "^4.0.8"1634- rx-lite-aggregates "^4.0.8"1635- string-width "^2.1.0"1636- strip-ansi "^4.0.0"1637- through "^2.3.6"1638-1428 invariant@^2.2.2:1429 version "2.2.2"1430 resolved "https://registry.yarnpkg.com/invariant/-/invariant-2.2.2.tgz#9e1f56ac0acdb6bf303306f338be3b204ae60360"1431 dependencies:82 unmodified lines1514 resolved "https://registry.yarnpkg.com/is-number/-/is-number-3.0.0.tgz#24fd6201a4782cf50561c810276afc7d12d71195"1515 dependencies:1516 kind-of "^3.0.2"1517 1729-is-path-cwd@^1.0.0:1730- version "1.0.0"1731- resolved "https://registry.yarnpkg.com/is-path-cwd/-/is-path-cwd-1.0.0.tgz#d225ec23132e89edd38fda767472e62e65f1106d"1732-1733-is-path-in-cwd@^1.0.0:1734- version "1.0.0"1735- resolved "https://registry.yarnpkg.com/is-path-in-cwd/-/is-path-in-cwd-1.0.0.tgz#6477582b8214d602346094567003be8a9eac04dc"1736- dependencies:1737- is-path-inside "^1.0.0"1738-1739-is-path-inside@^1.0.0:1740- version "1.0.1"1741- resolved "https://registry.yarnpkg.com/is-path-inside/-/is-path-inside-1.0.1.tgz#8ef5b7de50437a3fdca6b4e865ef7aa55cb48036"1742- dependencies:1743- path-is-inside "^1.0.1"1744-1518 is-posix-bracket@^0.1.0:1519 version "0.1.1"1520 resolved "https://registry.yarnpkg.com/is-posix-bracket/-/is-posix-bracket-0.1.1.tgz#3334dc79774368e92f016e6fbc0a88f5cd6e6bc4"1521 1522 is-primitive@^2.0.0:1523 version "2.0.0"1524 resolved "https://registry.yarnpkg.com/is-primitive/-/is-primitive-2.0.0.tgz#207bab91638499c07b2adf240a41a87210034575"1525 1753-is-promise@^2.1.0:1754- version "2.1.0"1755- resolved "https://registry.yarnpkg.com/is-promise/-/is-promise-2.1.0.tgz#79a2a9ece7f096e80f36d2b2f3bc16c1ff4bf3fa"1756-1526 is-regex@^1.0.4:1527 version "1.0.4"1528 resolved "https://registry.yarnpkg.com/is-regex/-/is-regex-1.0.4.tgz#5517489b547091b0930e095654ced25ee97e9491"1529 dependencies:1530 has "^1.0.1"1531 1763-is-resolvable@^1.0.0:1764- version "1.0.1"1765- resolved "https://registry.yarnpkg.com/is-resolvable/-/is-resolvable-1.0.1.tgz#acca1cd36dbe44b974b924321555a70ba03b1cf4"1766-1532 is-stream@^1.1.0:1533 version "1.1.0"1534 resolved "https://registry.yarnpkg.com/is-stream/-/is-stream-1.1.0.tgz#12d4a3dd4e68e0b79ceb8dbc84173ae80d91ca44"1535 339 unmodified lines1875 js-tokens@^3.0.0, js-tokens@^3.0.2:1876 version "3.0.2"1877 resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"1878 2114-js-yaml@^3.7.0, js-yaml@^3.9.1:1879+js-yaml@^3.7.0:1880 version "3.10.0"1881 resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-3.10.0.tgz#2e78441646bd4682e963f22b6e92823c309c62dc"1882 dependencies:1883 argparse "^1.0.7"47 unmodified lines1931 json-schema@0.2.3:1932 version "0.2.3"1933 resolved "https://registry.yarnpkg.com/json-schema/-/json-schema-0.2.3.tgz#b480c892e59a2f05954ce727bd3f2a4e882f9e13"1934 2170-json-stable-stringify-without-jsonify@^1.0.1:2171- version "1.0.1"2172- resolved "https://registry.yarnpkg.com/json-stable-stringify-without-jsonify/-/json-stable-stringify-without-jsonify-1.0.1.tgz#9db7b59496ad3f3cfef30a75142d2d930ad72651"2173-1935 json-stable-stringify@^1.0.1:1936 version "1.0.1"1937 resolved "https://registry.yarnpkg.com/json-stable-stringify/-/json-stable-stringify-1.0.1.tgz#9a759d39c5f2ff503fd5300646ed445f88c4f9af"1938 dependencies:49 unmodified lines1988 leven@^2.1.0:1989 version "2.1.0"1990 resolved "https://registry.yarnpkg.com/leven/-/leven-2.1.0.tgz#c2e7a9f772094dee9d34202ae8acce4687875580"1991 2231-levn@^0.3.0, levn@~0.3.0:1992+levn@~0.3.0:1993 version "0.3.0"1994 resolved "https://registry.yarnpkg.com/levn/-/levn-0.3.0.tgz#3b09924edf9f083c0490fdd4c0bc4421e04764ee"1995 dependencies:1996 prelude-ls "~1.1.2"15 unmodified lines2012 dependencies:2013 p-locate "^2.0.0"2014 path-exists "^3.0.0"2015 2016+lodash.clonedeep@^4.5.0:2017+ version "4.5.0"2018+ resolved "https://registry.yarnpkg.com/lodash.clonedeep/-/lodash.clonedeep-4.5.0.tgz#e23f3f9c4f8fbdde872529c1071857a086e5ccef"2019+2020 lodash.sortby@^4.7.0:2021 version "4.7.0"2022 resolved "https://registry.yarnpkg.com/lodash.sortby/-/lodash.sortby-4.7.0.tgz#edd14c824e2cc9c1e0b0a1b42bb5210516a42438"2023 2259-lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4, lodash@^4.3.0:2024+lodash@^4.13.1, lodash@^4.14.0, lodash@^4.17.4:2025 version "4.17.4"2026 resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"2027 2028 longest@^1.0.1:94 unmodified lines2123 ms@2.0.0:2124 version "2.0.0"2125 resolved "https://registry.yarnpkg.com/ms/-/ms-2.0.0.tgz#5608aeadfc00be6c2901df5f9861788de0d597c8"2126 2362-mute-stream@0.0.7:2363- version "0.0.7"2364- resolved "https://registry.yarnpkg.com/mute-stream/-/mute-stream-0.0.7.tgz#3075ce93bc21b8fab43e1bc4da7e8115ed1e7bab"2365-2127 nan@^2.0.5, nan@^2.3.0:2128 version "2.8.0"2129 resolved "https://registry.yarnpkg.com/nan/-/nan-2.8.0.tgz#ed715f3fe9de02b57a5e6252d90a96675e1f085a"2130 78 unmodified lines2209 oauth-sign@~0.8.1, oauth-sign@~0.8.2:2210 version "0.8.2"2211 resolved "https://registry.yarnpkg.com/oauth-sign/-/oauth-sign-0.8.2.tgz#46a6ab7f0aead8deae9ec0565780b7d4efeb9d43"2212 2452-object-assign@^4.0.1, object-assign@^4.1.0:2213+object-assign@^4.1.0:2214 version "4.1.1"2215 resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"2216 2217 object-keys@^1.0.8:19 unmodified lines2237 resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"2238 dependencies:2239 wrappy "1"2240 2480-onetime@^2.0.0:2481- version "2.0.1"2482- resolved "https://registry.yarnpkg.com/onetime/-/onetime-2.0.1.tgz#067428230fd67443b2794b22bba528b6867962d4"2483- dependencies:2484- mimic-fn "^1.0.0"2485-2241 optimist@^0.6.1:2242 version "0.6.1"2243 resolved "https://registry.yarnpkg.com/optimist/-/optimist-0.6.1.tgz#da3ea74686fa21a19a111c326e90eb15a0196686"2244 dependencies:2245 minimist "~0.0.1"2246 wordwrap "~0.0.2"2247 2493-optionator@^0.8.1, optionator@^0.8.2:2248+optionator@^0.8.1:2249 version "0.8.2"2250 resolved "https://registry.yarnpkg.com/optionator/-/optionator-0.8.2.tgz#364c5e409d3f4d6301d6c0b4c05bba50180aeb64"2251 dependencies:2252 deep-is "~0.1.3"14 unmodified lines2267 execa "^0.7.0"2268 lcid "^1.0.0"2269 mem "^1.1.0"2270 2271+os-shim@^0.1.2:2272+ version "0.1.3"2273+ resolved "https://registry.yarnpkg.com/os-shim/-/os-shim-0.1.3.tgz#6b62c3791cf7909ea35ed46e17658bb417cb3917"2274+2516-os-tmpdir@^1.0.0, os-tmpdir@^1.0.1, os-tmpdir@~1.0.2:2275+os-tmpdir@^1.0.0, os-tmpdir@^1.0.1:2276 version "1.0.2"2277 resolved "https://registry.yarnpkg.com/os-tmpdir/-/os-tmpdir-1.0.2.tgz#bbe67406c79aa85c5cfec766fe5734555dfa1274"2278 2279 osenv@^0.1.4:51 unmodified lines2331 path-is-absolute@^1.0.0, path-is-absolute@^1.0.1:2332 version "1.0.1"2333 resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"2334 2576-path-is-inside@^1.0.1, path-is-inside@^1.0.2:2577- version "1.0.2"2578- resolved "https://registry.yarnpkg.com/path-is-inside/-/path-is-inside-1.0.2.tgz#365417dede44430d1c11af61027facf074bdfc53"2579-2335 path-key@^2.0.0:2336 version "2.0.1"2337 resolved "https://registry.yarnpkg.com/path-key/-/path-key-2.0.1.tgz#411cadb574c5a140d3a4b1910d40d80cc9f40b40"2338 30 unmodified lines2369 pinkie@^2.0.0:2370 version "2.0.4"2371 resolved "https://registry.yarnpkg.com/pinkie/-/pinkie-2.0.4.tgz#72556b80cfa0d48a974e80e77248e80ed4f7f870"2372 2618-pluralize@^7.0.0:2619- version "7.0.0"2620- resolved "https://registry.yarnpkg.com/pluralize/-/pluralize-7.0.0.tgz#298b89df8b93b0221dbf421ad2b1b1ea23fc6777"2621-2373 pn@^1.0.0:2374 version "1.0.0"2375 resolved "https://registry.yarnpkg.com/pn/-/pn-1.0.0.tgz#1cf5a30b0d806cd18f88fc41a6b5d4ad615b3ba9"2376 2377+pre-commit@^1.2.2:2378+ version "1.2.2"2379+ resolved "https://registry.yarnpkg.com/pre-commit/-/pre-commit-1.2.2.tgz#dbcee0ee9de7235e57f79c56d7ce94641a69eec6"2380+ dependencies:2381+ cross-spawn "^5.0.1"2382+ spawn-sync "^1.0.15"2383+ which "1.2.x"2384+2385 prelude-ls@~1.1.2:2386 version "1.1.2"2387 resolved "https://registry.yarnpkg.com/prelude-ls/-/prelude-ls-1.1.2.tgz#21932a549f5e52ffd9a827f570e04be62a97da54"2388 19 unmodified lines2408 process-nextick-args@~1.0.6:2409 version "1.0.7"2410 resolved "https://registry.yarnpkg.com/process-nextick-args/-/process-nextick-args-1.0.7.tgz#150e20b756590ad3f91093f25a4f2ad8bff30ba3"2411 2653-progress@^2.0.0:2654- version "2.0.0"2655- resolved "https://registry.yarnpkg.com/progress/-/progress-2.0.0.tgz#8a1be366bf8fc23db2bd23f10c6fe920b4389d1f"2656-2412 pseudomap@^1.0.2:2413 version "1.0.2"2414 resolved "https://registry.yarnpkg.com/pseudomap/-/pseudomap-1.0.2.tgz#f052a28da70e618917ef0a8ac34c1ae5a68286b3"2415 195 unmodified lines2611 require-main-filename@^1.0.1:2612 version "1.0.1"2613 resolved "https://registry.yarnpkg.com/require-main-filename/-/require-main-filename-1.0.1.tgz#97f717b69d48784f5f526a6c5aa8ffdda055a4d1"2614 2860-require-uncached@^1.0.3:2861- version "1.0.3"2862- resolved "https://registry.yarnpkg.com/require-uncached/-/require-uncached-1.0.3.tgz#4e0d56d6c9662fd31e43011c4b95aa49955421d3"2863- dependencies:2864- caller-path "^0.1.0"2865- resolve-from "^1.0.0"2866-2867-resolve-from@^1.0.0:2868- version "1.0.1"2869- resolved "https://registry.yarnpkg.com/resolve-from/-/resolve-from-1.0.1.tgz#26cbfe935d1aeeeabb29bc3fe5aeb01e93d44226"2870-2615 resolve@1.1.7:2616 version "1.1.7"2617 resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"2618 2875-restore-cursor@^2.0.0:2876- version "2.0.0"2877- resolved "https://registry.yarnpkg.com/restore-cursor/-/restore-cursor-2.0.0.tgz#9f7ee287f82fd326d4fd162923d62129eee0dfaf"2878- dependencies:2879- onetime "^2.0.0"2880- signal-exit "^3.0.2"2881-2619 right-align@^0.1.1:2620 version "0.1.3"2621 resolved "https://registry.yarnpkg.com/right-align/-/right-align-0.1.3.tgz#61339b722fe6a3515689210d24e14c96148613ef"2622 dependencies:2623 align-text "^0.1.1"2624 2888-rimraf@2, rimraf@^2.2.8, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:2625+rimraf@2, rimraf@^2.5.1, rimraf@^2.5.4, rimraf@^2.6.1:2626 version "2.6.2"2627 resolved "https://registry.yarnpkg.com/rimraf/-/rimraf-2.6.2.tgz#2ed8150d24a16ea8651e6d6ef0f47c4158ce7a36"2628 dependencies:2629 glob "^7.0.5"2630 2894-run-async@^2.2.0:2895- version "2.3.0"2896- resolved "https://registry.yarnpkg.com/run-async/-/run-async-2.3.0.tgz#0371ab4ae0bdd720d4166d7dfda64ff7a445a6c0"2897- dependencies:2898- is-promise "^2.1.0"2899-2900-rx-lite-aggregates@^4.0.8:2901- version "4.0.8"2902- resolved "https://registry.yarnpkg.com/rx-lite-aggregates/-/rx-lite-aggregates-4.0.8.tgz#753b87a89a11c95467c4ac1626c4efc4e05c67be"2903- dependencies:2904- rx-lite "*"2905-2906-rx-lite@*, rx-lite@^4.0.8:2907- version "4.0.8"2908- resolved "https://registry.yarnpkg.com/rx-lite/-/rx-lite-4.0.8.tgz#0b1e11af8bc44836f04a6407e92da42467b79444"2909-2631 safe-buffer@^5.0.1, safe-buffer@^5.1.1, safe-buffer@~5.1.0, safe-buffer@~5.1.1:2632 version "5.1.1"2633 resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.1.1.tgz#893312af69b2123def71f57889001671eeb2c853"2634 44 unmodified lines2679 slash@^1.0.0:2680 version "1.0.0"2681 resolved "https://registry.yarnpkg.com/slash/-/slash-1.0.0.tgz#c41f2f6c39fc16d1cd17ad4b5d896114ae470d55"2682 2962-slice-ansi@1.0.0:2963- version "1.0.0"2964- resolved "https://registry.yarnpkg.com/slice-ansi/-/slice-ansi-1.0.0.tgz#044f1a49d8842ff307aad6b505ed178bd950134d"2965- dependencies:2966- is-fullwidth-code-point "^2.0.0"2967-2683 sntp@1.x.x:2684 version "1.0.9"2685 resolved "https://registry.yarnpkg.com/sntp/-/sntp-1.0.9.tgz#6541184cc90aeea6c6e7b35e2659082443c66198"2686 dependencies:30 unmodified lines2717 source-map@^0.6.0:2718 version "0.6.1"2719 resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"2720 2721+spawn-sync@^1.0.15:2722+ version "1.0.15"2723+ resolved "https://registry.yarnpkg.com/spawn-sync/-/spawn-sync-1.0.15.tgz#b00799557eb7fb0c8376c29d44e8a1ea67e57476"2724+ dependencies:2725+ concat-stream "^1.4.7"2726+ os-shim "^0.1.2"2727+2728 spdx-correct@~1.0.0:2729 version "1.0.2"2730 resolved "https://registry.yarnpkg.com/spdx-correct/-/spdx-correct-1.0.2.tgz#4b3073d933ff51f3912f03ac5519498a4150db40"2731 dependencies:47 unmodified lines2779 code-point-at "^1.0.0"2780 is-fullwidth-code-point "^1.0.0"2781 strip-ansi "^3.0.0"2782 3061-string-width@^2.0.0, string-width@^2.1.0, string-width@^2.1.1:2783+string-width@^2.0.0:2784 version "2.1.1"2785 resolved "https://registry.yarnpkg.com/string-width/-/string-width-2.1.1.tgz#ab93f27a8dc13d28cac815c462143a6d9012ae9e"2786 dependencies:2787 is-fullwidth-code-point "^2.0.0"58 unmodified lines2846 symbol-tree@^3.2.1:2847 version "3.2.2"2848 resolved "https://registry.yarnpkg.com/symbol-tree/-/symbol-tree-3.2.2.tgz#ae27db38f660a7ae2e1c3b7d1bc290819b8519e6"2849 3128-table@^4.0.1:3129- version "4.0.2"3130- resolved "https://registry.yarnpkg.com/table/-/table-4.0.2.tgz#a33447375391e766ad34d3486e6e2aedc84d2e36"3131- dependencies:3132- ajv "^5.2.3"3133- ajv-keywords "^2.1.0"3134- chalk "^2.1.0"3135- lodash "^4.17.4"3136- slice-ansi "1.0.0"3137- string-width "^2.1.1"3138-2850 tar-pack@^3.4.0:2851 version "3.4.1"2852 resolved "https://registry.yarnpkg.com/tar-pack/-/tar-pack-3.4.1.tgz#e1dbc03a9b9d3ba07e896ad027317eb679a10a1f"2853 dependencies:23 unmodified lines2877 object-assign "^4.1.0"2878 read-pkg-up "^1.0.1"2879 require-main-filename "^1.0.1"2880 3170-text-table@~0.2.0:3171- version "0.2.0"3172- resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"3173-2881 throat@^4.0.0:2882 version "4.1.0"2883 resolved "https://registry.yarnpkg.com/throat/-/throat-4.1.0.tgz#89037cbc92c56ab18926e6ba4cbb200e15672a6a"2884 3178-through@^2.3.6:3179- version "2.3.8"3180- resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"3181-3182-tmp@^0.0.33:3183- version "0.0.33"3184- resolved "https://registry.yarnpkg.com/tmp/-/tmp-0.0.33.tgz#6d34335889768d21b2bcda0aa277ced3b1bfadf9"3185- dependencies:3186- os-tmpdir "~1.0.2"3187-2885 tmpl@1.0.x:2886 version "1.0.4"2887 resolved "https://registry.yarnpkg.com/tmpl/-/tmpl-1.0.4.tgz#23640dd7b42d00433911140820e5cf440e521dd1"2888 129 unmodified lines3018 which-module@^2.0.0:3019 version "2.0.0"3020 resolved "https://registry.yarnpkg.com/which-module/-/which-module-2.0.0.tgz#d9ef07dce77b9902b8a3a8fa4b31c3e3f7e6e87a"3021 3022+which@1.2.x:3023+ version "1.2.14"3024+ resolved "https://registry.yarnpkg.com/which/-/which-1.2.14.tgz#9a87c4378f03e827cecaf1acdf56c736c01c14e5"3025+ dependencies:3026+ isexe "^2.0.0"3027+3028 which@^1.2.12, which@^1.2.9:3029 version "1.3.0"3030 resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"3031 dependencies:39 unmodified lines3071 graceful-fs "^4.1.11"3072 imurmurhash "^0.1.4"3073 signal-exit "^3.0.2"3074 3372-write@^0.2.1:3373- version "0.2.1"3374- resolved "https://registry.yarnpkg.com/write/-/write-0.2.1.tgz#5fc03828e264cea3fe91455476f7a3c566cb0757"3375- dependencies:3376- mkdirp "^0.5.1"3377-3075 xml-name-validator@^2.0.1:3076 version "2.0.1"3077 resolved "https://registry.yarnpkg.com/xml-name-validator/-/xml-name-validator-2.0.1.tgz#4d8b8f1eccd3419aa362061becef515e1e559635"3078 39 unmodified lines