Skip to content
Myr

Added flow types, implements #34

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 fa177ea · Browse files · 5 files+150 added−50 removed
This commit

State

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

Diff stats

5 files+150 added−50 removed

  • other:+150 added−50 removed

5 files+150 added−50 removed

added:src/immer.d.ts+43 added
added:src/immer.js.flow+45 added
1declare export function extendShallowObservable(target: any): any23/**4 * Immer takes a state, and runs a function against it.5 * That function can freely mutate the state, as it will create copies-on-write.6 * This means that the original state will stay unchanged, and once the function finishes, the modified state is returned7 *8 * If only one argument is passed, this is interpreted as the recipe, and will create a curried function that will execute the recipe9 * any time it is called with a base state10 *11 * @param currentState - the state to start with12 * @param thunk - function that receives a proxy of the current state as first argument and which can be freely modified13 * @returns The next state: a new state, or the current state if nothing was modified14 */15declare export default function<S>(16 currentState: S,17 recipe: (draftState: S) => void18): S19// curried invocations20declare export default function<S, A, B, C>(21 recipe: (draftState: S, a: A, b: B, c: C) => void22): (currentState: S, a: A, b: B, c: C) => S23declare export default function<S, A, B>(24 recipe: (draftState: S, a: A, b: B) => void25): (currentState: S, a: A, b: B) => S26declare export default function<S, A>(27 recipe: (draftState: S, a: A) => void28): (currentState: S) => S29declare export default function<S>(30 recipe: (draftState: S, ...extraArgs: any[]) => void31): (currentState: S, ...extraArgs: any[]) => S3233/**34 * Automatically freezes any state trees generated by immer.35 * This protects against accidental modifications of the state tree outside of an immer function.36 * This comes with a performance impact, so it is recommended to disable this option in production.37 * It is by default enabled.38 */39declare export function setAutoFreeze(autoFreeze: boolean): void4041/**42 * Manually override whether proxies should be used.43 * By default done by using feature detection44 */45declare export function setUseProxies(useProxies: boolean): void
deleted:immer.d.ts-43 removed
modified:package.json+5 added-3 removed
modified:yarn.lock+57 added-4 removed
134 unmodified lines
135array-equal@^1.0.0:136 version "1.0.0"137 resolved "https://registry.yarnpkg.com/array-equal/-/array-equal-1.0.0.tgz#8c2a5ef2472fd9ea742b04c77a75093ba2757c93"138139array-filter@~0.0.0:140 version "0.0.1"141 resolved "https://registry.yarnpkg.com/array-filter/-/array-filter-0.0.1.tgz#7da8cf2e26628ed732803581fd21f67cacd2eeec"142143array-map@~0.0.0:144 version "0.0.0"145 resolved "https://registry.yarnpkg.com/array-map/-/array-map-0.0.0.tgz#88a2bab73d1cf7bcd5c1b118a003f66f665fa662"146147array-reduce@~0.0.0:148 version "0.0.0"149 resolved "https://registry.yarnpkg.com/array-reduce/-/array-reduce-0.0.0.tgz#173899d3ffd1c7d9383e4479525dbe278cab5f2b"150151array-unique@^0.2.1:152 version "0.2.1"153 resolved "https://registry.yarnpkg.com/array-unique/-/array-unique-0.2.1.tgz#a1d97ccafcbc2625cc70fadceb36a50c58b01a53"154
573 unmodified lines
728 lodash "^4.17.4"729 mkdirp "^0.5.1"730 source-map-support "^0.4.15"731720babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0:732babel-runtime@^6.18.0, babel-runtime@^6.22.0, babel-runtime@^6.26.0, babel-runtime@^6.9.2:733 version "6.26.0"734 resolved "https://registry.yarnpkg.com/babel-runtime/-/babel-runtime-6.26.0.tgz#965c7058668e82b55d7bfe04ff2337bc8b5647fe"735 dependencies:736 core-js "^2.4.0"
176 unmodified lines
913 ansi-styles "^3.1.0"914 escape-string-regexp "^1.0.5"915 supports-color "^4.0.0"916905chokidar@^1.6.1:917chokidar@^1.6.0, chokidar@^1.6.1:918 version "1.7.0"919 resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-1.7.0.tgz#798e689778151c8076b4b360e5edd28cda2bb468"920 dependencies:921 anymatch "^1.3.0"
108 unmodified lines
1030 log-driver "^1.2.5"1031 minimist "^1.2.0"1032 request "^2.79.0"10331034cpx@^1.5.0:1035 version "1.5.0"1036 resolved "https://registry.yarnpkg.com/cpx/-/cpx-1.5.0.tgz#185be018511d87270dedccc293171e37655ab88f"1037 dependencies:1038 babel-runtime "^6.9.2"1039 chokidar "^1.6.0"1040 duplexer "^0.1.1"1041 glob "^7.0.5"1042 glob2base "^0.0.12"1043 minimatch "^3.0.2"1044 mkdirp "^0.5.1"1045 resolve "^1.1.7"1046 safe-buffer "^5.0.1"1047 shell-quote "^1.6.1"1048 subarg "^1.0.0"10491050cross-env@^5.1.3:1051 version "5.1.3"1052 resolved "https://registry.yarnpkg.com/cross-env/-/cross-env-5.1.3.tgz#f8ae18faac87692b0a8b4d2f7000d4ec3a85dfd7"1053 dependencies:
301 unmodified lines
1355 randomatic "^1.1.3"1356 repeat-element "^1.1.2"1357 repeat-string "^1.5.2"13581359find-index@^0.1.1:1360 version "0.1.1"1361 resolved "https://registry.yarnpkg.com/find-index/-/find-index-0.1.1.tgz#675d358b2ca3892d795a1ab47232f8b6e2e0dde4"13621363find-up@^1.0.0:1364 version "1.1.2"1365 resolved "https://registry.yarnpkg.com/find-up/-/find-up-1.1.2.tgz#6b2e9822b1a2ce0a60ab64d610eccad53cb24d0f"1366 dependencies:
115 unmodified lines
1482 resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-2.0.0.tgz#81383d72db054fcccf5336daa902f182f6edbb28"1483 dependencies:1484 is-glob "^2.0.0"14851486glob2base@^0.0.12:1487 version "0.0.12"1488 resolved "https://registry.yarnpkg.com/glob2base/-/glob2base-0.0.12.tgz#9d419b3e28f12e83a362164a277055922c9c0d56"1489 dependencies:1490 find-index "^0.1.1"14911492glob@^7.0.3, glob@^7.0.5, glob@^7.1.1, glob@^7.1.2:1493 version "7.1.2"1494 resolved "https://registry.yarnpkg.com/glob/-/glob-7.1.2.tgz#c19c9df9a028702d678612384a6552404c636d15"1495 dependencies:
876 unmodified lines
2372minimist@0.0.8:2373 version "0.0.8"2374 resolved "https://registry.yarnpkg.com/minimist/-/minimist-0.0.8.tgz#857fcabfc3397d2625b8228262e86aa7a011b05d"23752338minimist@^1.1.1, minimist@^1.2.0:2376minimist@^1.1.0, minimist@^1.1.1, minimist@^1.2.0:2377 version "1.2.0"2378 resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.0.tgz#a35008b20f41383eec1fb914f4cd5df79a264284"23792380minimist@~0.0.1:
522 unmodified lines
2903resolve@1.1.7:2904 version "1.1.7"2905 resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.1.7.tgz#203114d82ad2c5ed9e8e0411b3932875e889e97b"29062869resolve@^1.1.6, resolve@^1.4.0:2907resolve@^1.1.6, resolve@^1.1.7, resolve@^1.4.0:2908 version "1.5.0"2909 resolved "https://registry.yarnpkg.com/resolve/-/resolve-1.5.0.tgz#1f09acce796c9a762579f31b2c1cc4c3cddf9f36"2910 dependencies:2911 path-parse "^1.0.5"
111 unmodified lines
3023shebang-regex@^1.0.0:3024 version "1.0.0"3025 resolved "https://registry.yarnpkg.com/shebang-regex/-/shebang-regex-1.0.0.tgz#da42f49740c0b42db2ca9728571cb190c98efea3"30263027shell-quote@^1.6.1:3028 version "1.6.1"3029 resolved "https://registry.yarnpkg.com/shell-quote/-/shell-quote-1.6.1.tgz#f4781949cce402697127430ea3b3c5476f481767"3030 dependencies:3031 array-filter "~0.0.0"3032 array-map "~0.0.0"3033 array-reduce "~0.0.0"3034 jsonify "~0.0.0"30353036shellwords@^0.1.0:3037 version "0.1.1"3038 resolved "https://registry.yarnpkg.com/shellwords/-/shellwords-0.1.1.tgz#d6b9181c1a48d397324c84871efbcfc73fc0654b"3039
151 unmodified lines
3191strip-json-comments@~2.0.1:3192 version "2.0.1"3193 resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-2.0.1.tgz#3c531942e908c2697c0ec344858c286c7ca0a60a"31943195subarg@^1.0.0:3196 version "1.0.0"3197 resolved "https://registry.yarnpkg.com/subarg/-/subarg-1.0.0.tgz#f62cf17581e996b48fc965699f54c06ae268b8d2"3198 dependencies:3199 minimist "^1.1.0"32003201supports-color@^2.0.0:3202 version "2.0.0"3203 resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-2.0.0.tgz#535d045ce6b6363fa40117084629995e9df324c7"3204
330 unmodified lines