[
  {
    "path": ".codeclimate.yml",
    "content": "---\nengines:\n  duplication:\n    enabled: true\n    config:\n      languages:\n      - javascript\n  eslint:\n    enabled: true\n  fixme:\n    enabled: true\nratings:\n  paths:\n  - \"**.js\"\nexclude_paths:\n  - \"**/*-test.js\"\n"
  },
  {
    "path": ".editorconfig",
    "content": "# editorconfig.org\nroot = true\n\n[*]\nindent_style = space\nindent_size = 2\nend_of_line = lf\ncharset = utf-8\ntrim_trailing_whitespace = true\ninsert_final_newline = true\n\n[*.md]\ntrim_trailing_whitespace = false\n\n[Makefile]\nindent_style = tab\n"
  },
  {
    "path": ".eslintignore",
    "content": "**/node_modules\n**/types"
  },
  {
    "path": ".eslintrc",
    "content": "{\n  \"extends\": [\n    \"eslint-config-airbnb\",\n    \"prettier\",\n    \"prettier/flowtype\",\n    \"prettier/react\"\n  ],\n  \"plugins\": [\n    \"prettier\"\n  ],\n  \"parser\": \"babel-eslint\",\n  \"env\": {\n    \"browser\": true,\n    \"node\": true,\n    \"jest\": true\n  },\n  \"globals\": {\n    \"sinon\": true\n  },\n  \"rules\": {\n    \"semi\": [2, \"never\"],\n    \"no-use-before-define\": [\"error\", { \"functions\": false }],\n    \"no-unused-vars\": [\"error\", { \"argsIgnorePattern\": \"^_\" }],\n    \"no-underscore-dangle\": [0],\n    \"no-confusing-arrow\": [0],\n    \"no-class-assign\": [0],\n    \"no-plusplus\": [0],\n    \"no-prototype-builtins\": [0],\n    \"no-return-assign\": [0],\n    \"max-len\": [\"error\", { \"code\": 120, \"ignorePattern\": \"^test\", \"ignoreUrls\": true }],\n    \"lines-between-class-members\": [0],\n    \"prefer-destructuring\": [0],\n    \"import/no-unresolved\": [0],\n    \"import/no-extraneous-dependencies\": [0],\n    \"import/extensions\": [0],\n    \"import/prefer-default-export\": [0],\n    \"import/no-useless-path-segments\": [0],\n    \"jsx-a11y/label-has-for\": [0],\n    \"react/forbid-prop-types\": [0],\n    \"react/prop-types\": [0],\n    \"react/prefer-stateless-function\": [0],\n    \"react/no-multi-comp\": [0],\n    \"react/sort-comp\": [0],\n    \"react/jsx-filename-extension\": [0],\n    \"prettier/prettier\": [\"error\", {\"semi\": false, \"trailingComma\": \"es5\", \"singleQuote\": true}],\n    \"react/destructuring-assignment\": [0],\n    \"react/jsx-curly-brace-presence\": [0],\n    \"react/no-unused-prop-types\": [0],\n    \"react/require-default-props\": [0],\n    \"react/button-has-type\": [0]\n  }\n}\n"
  },
  {
    "path": ".flowconfig",
    "content": "[ignore]\n<PROJECT_ROOT>/types/.*\n\n[include]\n\n[libs]\n\n[options]\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$ExpectError\n\n[lints]"
  },
  {
    "path": ".gitignore",
    "content": "node_modules\nrelease\nlib\ncoverage\n.vscode\nyarn-error.log\n"
  },
  {
    "path": ".npmignore",
    "content": "/**/__tests__\ncoverage\ntypes"
  },
  {
    "path": ".prettierignore",
    "content": "node_modules\npackage.json"
  },
  {
    "path": ".prettierrc",
    "content": "semi: false\nsingleQuote: true\ntrailingComma: es5"
  },
  {
    "path": ".size-snapshot.json",
    "content": "{\n  \"lib/packages/recompose/dist/Recompose.umd.js\": {\n    \"bundled\": 46425,\n    \"minified\": 16484,\n    \"gzipped\": 4625\n  },\n  \"lib/packages/recompose/dist/Recompose.min.js\": {\n    \"bundled\": 42863,\n    \"minified\": 15204,\n    \"gzipped\": 4194\n  },\n  \"lib/packages/recompose/dist/Recompose.esm.js\": {\n    \"bundled\": 32428,\n    \"minified\": 15083,\n    \"gzipped\": 3550,\n    \"treeshaked\": {\n      \"rollup\": {\n        \"code\": 310,\n        \"import_statements\": 310\n      },\n      \"webpack\": {\n        \"code\": 1838\n      }\n    }\n  }\n}\n"
  },
  {
    "path": ".travis.yml",
    "content": "language: node_js\nnode_js:\n  - \"node\"\ninstall: \"yarn install --ignore-engines\"\nbefore_script: \"npm install -g codeclimate-test-reporter\"\nscript:\n  - yarn run lint\n  - yarn test\nafter_script:\n  - \"CODECLIMATE_REPO_TOKEN=27125df6192d300baf67cd5f5eab6597c998256f4883b744a1055d0f0c18e608 codeclimate-test-reporter < coverage/lcov.info\"\n  - \"cat ./coverage/lcov.info | $(npm bin)/codecov\"\n"
  },
  {
    "path": "CHANGELOG.md",
    "content": "We are using the [Github Releases page](https://github.com/acdlite/recompose/releases) as our CHANGELOG.\n"
  },
  {
    "path": "LICENSE.md",
    "content": "The MIT License (MIT)\n\nCopyright (c) 2015-2018 Andrew Clark\n\nPermission is hereby granted, free of charge, to any person obtaining a copy\nof this software and associated documentation files (the \"Software\"), to deal\nin the Software without restriction, including without limitation the rights\nto use, copy, modify, merge, publish, distribute, sublicense, and/or sell\ncopies of the Software, and to permit persons to whom the Software is\nfurnished to do so, subject to the following conditions:\n\nThe above copyright notice and this permission notice shall be included in all\ncopies or substantial portions of the Software.\n\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\nIMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\nFITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE\nAUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\nLIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\nOUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\nSOFTWARE.\n"
  },
  {
    "path": "README.md",
    "content": "## A Note from the Author (acdlite, Oct 25 2018):\n\nHi! I created Recompose about three years ago. About a year after that, I joined the React team. Today, we announced a proposal for [*Hooks*](https://reactjs.org/hooks). Hooks solves all the problems I attempted to address with Recompose three years ago, and more on top of that. I will be discontinuing active maintenance of this package (excluding perhaps bugfixes or patches for compatibility with future React releases), and recommending that people use Hooks instead. **Your existing code with Recompose will still work**, just don't expect any new features. Thank you so, so much to [@wuct](https://github.com/wuct) and [@istarkov](https://github.com/istarkov) for their heroic work maintaining Recompose over the last few years.\n\nRead more discussion about this decision [here](https://github.com/acdlite/recompose/issues/756#issuecomment-438674573).\n\n***\n\nRecompose\n-----\n\n[![build status](https://img.shields.io/travis/acdlite/recompose/master.svg?style=flat-square)](https://travis-ci.org/acdlite/recompose)\n[![coverage](https://img.shields.io/codecov/c/github/acdlite/recompose.svg?style=flat-square)](https://codecov.io/github/acdlite/recompose)\n[![code climate](https://img.shields.io/codeclimate/github/acdlite/recompose.svg?style=flat-square)](https://codeclimate.com/github/acdlite/recompose)\n[![npm version](https://img.shields.io/npm/v/recompose.svg?style=flat-square)](https://www.npmjs.com/package/recompose)\n[![npm downloads](https://img.shields.io/npm/dm/recompose.svg?style=flat-square)](https://www.npmjs.com/package/recompose)\n\nRecompose is a React utility belt for function components and higher-order components. Think of it like lodash for React.\n\n[**Full API documentation**](docs/API.md) - Learn about each helper\n\n[**Recompose Base Fiddle**](https://jsfiddle.net/evenchange4/p3vsmrvo/1599/) - Easy way to dive in\n\n```\nnpm install recompose --save\n```\n\n**📺 Watch Andrew's [talk on Recompose at React Europe](https://www.youtube.com/watch?v=zD_judE-bXk).**\n*(Note: Performance optimizations he speaks about have been removed, more info [here](https://github.com/acdlite/recompose/releases/tag/v0.26.0))*\n\n### Related modules\n\n[**recompose-relay**](src/packages/recompose-relay) — Recompose helpers for Relay\n\n## You can use Recompose to...\n\n### ...lift state into functional wrappers\n\nHelpers like `withState()` and `withReducer()` provide a nicer way to express state updates:\n\n```js\nconst enhance = withState('counter', 'setCounter', 0)\nconst Counter = enhance(({ counter, setCounter }) =>\n  <div>\n    Count: {counter}\n    <button onClick={() => setCounter(n => n + 1)}>Increment</button>\n    <button onClick={() => setCounter(n => n - 1)}>Decrement</button>\n  </div>\n)\n```\n\nOr with a Redux-style reducer:\n\n```js\nconst counterReducer = (count, action) => {\n  switch (action.type) {\n  case INCREMENT:\n    return count + 1\n  case DECREMENT:\n    return count - 1\n  default:\n    return count\n  }\n}\n\nconst enhance = withReducer('counter', 'dispatch', counterReducer, 0)\nconst Counter = enhance(({ counter, dispatch }) =>\n  <div>\n    Count: {counter}\n    <button onClick={() => dispatch({ type: INCREMENT })}>Increment</button>\n    <button onClick={() => dispatch({ type: DECREMENT })}>Decrement</button>\n  </div>\n)\n```\n\n### ...perform the most common React patterns\n\nHelpers like `componentFromProp()` and `withContext()` encapsulate common React patterns into a simple functional interface:\n\n```js\nconst enhance = defaultProps({ component: 'button' })\nconst Button = enhance(componentFromProp('component'))\n\n<Button /> // renders <button>\n<Button component={Link} /> // renders <Link />\n```\n\n```js\nconst provide = store => withContext(\n  { store: PropTypes.object },\n  () => ({ store })\n)\n\n// Apply to base component\n// Descendants of App have access to context.store\nconst AppWithContext = provide(store)(App)\n```\n\n### ...optimize rendering performance\n\nNo need to write a new class just to implement `shouldComponentUpdate()`. Recompose helpers like `pure()` and `onlyUpdateForKeys()` do this for you:\n\n```js\n// A component that is expensive to render\nconst ExpensiveComponent = ({ propA, propB }) => {...}\n\n// Optimized version of same component, using shallow comparison of props\n// Same effect as extending React.PureComponent\nconst OptimizedComponent = pure(ExpensiveComponent)\n\n// Even more optimized: only updates if specific prop keys have changed\nconst HyperOptimizedComponent = onlyUpdateForKeys(['propA', 'propB'])(ExpensiveComponent)\n```\n\n### ...interoperate with other libraries\n\nRecompose helpers integrate really nicely with external libraries like Relay, Redux, and RxJS\n\n```js\nconst enhance = compose(\n  // This is a Recompose-friendly version of Relay.createContainer(), provided by recompose-relay\n  createContainer({\n    fragments: {\n      post: () => Relay.QL`\n        fragment on Post {\n          title,\n          content\n        }\n      `\n    }\n  }),\n  flattenProp('post')\n)\n\nconst Post = enhance(({ title, content }) =>\n  <article>\n    <h1>{title}</h1>\n    <div>{content}</div>\n  </article>\n)\n```\n\n### ...build your own libraries\n\nMany React libraries end up implementing the same utilities over and over again, like `shallowEqual()` and `getDisplayName()`. Recompose provides these utilities for you.\n\n```js\n// Any Recompose module can be imported individually\nimport getDisplayName from 'recompose/getDisplayName'\nConnectedComponent.displayName = `connect(${getDisplayName(BaseComponent)})`\n\n// Or, even better:\nimport wrapDisplayName from 'recompose/wrapDisplayName'\nConnectedComponent.displayName = wrapDisplayName(BaseComponent, 'connect')\n\nimport toClass from 'recompose/toClass'\n// Converts a function component to a class component, e.g. so it can be given\n// a ref. Returns class components as is.\nconst ClassComponent = toClass(FunctionComponent)\n```\n\n### ...and more\n\n## API docs\n\n[Read them here](docs/API.md)\n\n## Flow support\n\n[Read the docs](docs/flow.md)\n\n## Translation\n\n[Traditional Chinese](https://github.com/neighborhood999/recompose)\n\n## Why\n\nForget ES6 classes vs. `createClass()`.\n\nAn idiomatic React application consists mostly of function components.\n\n```js\nconst Greeting = props =>\n  <p>\n    Hello, {props.name}!\n  </p>\n```\n\nFunction components have several key advantages:\n\n- They help prevent abuse of the `setState()` API, favoring props instead.\n- They encourage the [\"smart\" vs. \"dumb\" component pattern](https://medium.com/@dan_abramov/smart-and-dumb-components-7ca2f9a7c7d0).\n- They encourage code that is more reusable and modular.\n- They discourage giant, complicated components that do too many things.\n- They allow React to make performance optimizations by avoiding unnecessary checks and memory allocations.\n\n(Note that although Recompose encourages the use of function components whenever possible, it works with normal React components as well.)\n\n### Higher-order components made easy\n\nMost of the time when we talk about composition in React, we're talking about composition of components. For example, a `<Blog>` component may be composed of many `<Post>` components, which are composed of many `<Comment>` components.\n\nRecompose focuses on another unit of composition: **higher-order components** (HoCs). HoCs are functions that accept a base component and return a new component with additional functionality. They can be used to abstract common tasks into reusable pieces.\n\nRecompose provides a toolkit of helper functions for creating higher-order components.\n\n## [Should I use this? Performance and other concerns](docs/performance.md)\n\n## Usage\n\nAll functions are available on the top-level export.\n\n```js\nimport { compose, mapProps, withState /* ... */ } from 'recompose'\n```\n\n**Note:** `react` is a _peer dependency_ of Recompose.  If you're using `preact`, add this to your `webpack.config.js`:\n\n```js\nresolve: {\n  alias: {\n    react: \"preact\"\n  }\n}\n```\n\n### Composition\n\nRecompose helpers are designed to be composable:\n\n```js\nconst BaseComponent = props => {...}\n\n// This will work, but it's tedious\nlet EnhancedComponent = pure(BaseComponent)\nEnhancedComponent = mapProps(/*...args*/)(EnhancedComponent)\nEnhancedComponent = withState(/*...args*/)(EnhancedComponent)\n\n// Do this instead\n// Note that the order has reversed — props flow from top to bottom\nconst enhance = compose(\n  withState(/*...args*/),\n  mapProps(/*...args*/),\n  pure\n)\nconst EnhancedComponent = enhance(BaseComponent)\n```\n\nTechnically, this also means you can use them as decorators (if that's your thing):\n\n```js\n@withState(/*...args*/)\n@mapProps(/*...args*/)\n@pure\nclass Component extends React.Component {...}\n```\n\n### Optimizing bundle size\n\nSince `0.23.1` version recompose got support of ES2015 modules.\nTo reduce size all you need is to use bundler with tree shaking support\nlike [webpack 2](https://github.com/webpack/webpack) or [Rollup](https://github.com/rollup/rollup).\n\n#### Using babel-plugin-lodash\n\n[babel-plugin-lodash](https://github.com/lodash/babel-plugin-lodash) is not only limited to [lodash](https://github.com/lodash/lodash). It can be used with `recompose` as well.\n\nThis can be done by updating `lodash` config in `.babelrc`.\n\n```diff\n {\n-  \"plugins\": [\"lodash\"]\n+  \"plugins\": [\n+    [\"lodash\", { \"id\": [\"lodash\", \"recompose\"] }]\n+  ]\n }\n```\n\nAfter that, you can do imports like below without actually including the entire library content.\n\n```js\nimport { compose, mapProps, withState } from 'recompose'\n```\n\n### Debugging\n\nIt might be hard to trace how does `props` change between HOCs. A useful tip is you can create a debug HOC to print out the props it gets without modifying the base component. For example:\n\nmake\n\n```js\nconst debug = withProps(console.log)\n```\n\nthen use it between HOCs\n\n```js\nconst enhance = compose(\n  withState(/*...args*/),\n  debug, // print out the props here\n  mapProps(/*...args*/),\n  pure\n)\n```\n\n\n## Who uses Recompose\nIf your company or project uses Recompose, feel free to add it to [the official list of users](https://github.com/acdlite/recompose/wiki/Sites-Using-Recompose) by [editing](https://github.com/acdlite/recompose/wiki/Sites-Using-Recompose/_edit) the wiki page.\n\n## Recipes for Inspiration\nWe have a community-driven Recipes page. It's a place to share and see recompose patterns for inspiration. Please add to it! [Recipes](https://github.com/acdlite/recompose/wiki/Recipes).\n\n## Feedback wanted\n\nProject is still in the early stages. Please file an issue or submit a PR if you have suggestions! Or ping me (Andrew Clark) on [Twitter](https://twitter.com/acdlite).\n\n\n## Getting Help\n\n**For support or usage questions like “how do I do X with Recompose” and “my code doesn't work”, please search and ask on [StackOverflow with a Recompose tag](http://stackoverflow.com/questions/tagged/recompose?sort=votes&pageSize=50) first.**\n\nWe ask you to do this because StackOverflow has a much better job at keeping popular questions visible. Unfortunately good answers get lost and outdated on GitHub.\n\nSome questions take a long time to get an answer. **If your question gets closed or you don't get a reply on StackOverflow for longer than a few days,** we encourage you to post an issue linking to your question. We will close your issue but this will give people watching the repo an opportunity to see your question and reply to it on StackOverflow if they know the answer.\n\nPlease be considerate when doing this as this is not the primary purpose of the issue tracker.\n\n### Help Us Help You\n\nOn both websites, it is a good idea to structure your code and question in a way that is easy to read to entice people to answer it. For example, we encourage you to use syntax highlighting, indentation, and split text in paragraphs.\n\nPlease keep in mind that people spend their free time trying to help you. You can make it easier for them if you provide versions of the relevant libraries and a runnable small project reproducing your issue. You can put your code on [JSBin](http://jsbin.com) or, for bigger projects, on GitHub. Make sure all the necessary dependencies are declared in `package.json` so anyone can run `npm install && npm start` and reproduce your issue.\n"
  },
  {
    "path": "babel.config.js",
    "content": "module.exports = {\n  plugins: [['@babel/proposal-class-properties', { loose: true }]],\n  presets: [['@babel/env', { loose: true }], '@babel/react'],\n}\n\nif (process.env.NODE_ENV === 'cjs') {\n  module.exports.plugins.push('@babel/transform-runtime')\n}\n"
  },
  {
    "path": "docs/API.md",
    "content": "# API\n\nIn these API docs, a **higher-order component** (HOC) refers to a function that accepts a single React component and returns a new React component.\n\n```js\nconst EnhancedComponent = hoc(BaseComponent)\n```\n\nThis form makes HOCs (sometimes called **enhancers**) composable:\n\n```js\nconst composedHoc = compose(hoc1, hoc2, hoc3)\n\n// Same as\nconst composedHoc = BaseComponent => hoc1(hoc2(hoc3(BaseComponent)))\n```\n\nMost Recompose helpers are **functions that return higher-order components**:\n\n```js\nconst hoc = mapProps(ownerProps => childProps)\nconst EnhancedComponent = hoc(BaseComponent)\n\n// Same as\nconst EnhancedComponent = mapProps(ownerProps => childProps)(BaseComponent)\n```\n\nSome, like `pure`, are higher-order components themselves:\n\n```js\nconst PureComponent = pure(BaseComponent)\n```\n\n## TOC\n\n* [Higher-order components](#higher-order-components)\n  + [`mapProps()`](#mapprops)\n  + [`withProps()`](#withprops)\n  + [`withPropsOnChange()`](#withpropsonchange)\n  + [`withHandlers()`](#withhandlers)\n  + [`defaultProps()`](#defaultprops)\n  + [`renameProp()`](#renameprop)\n  + [`renameProps()`](#renameprops)\n  + [`flattenProp()`](#flattenprop)\n  + [`withState()`](#withstate)\n  + [`withStateHandlers()`](#withstatehandlers)\n  + [`withReducer()`](#withreducer)\n  + [`branch()`](#branch)\n  + [`renderComponent()`](#rendercomponent)\n  + [`renderNothing()`](#rendernothing)\n  + [`shouldUpdate()`](#shouldupdate)\n  + [`pure()`](#pure)\n  + [`onlyUpdateForKeys()`](#onlyupdateforkeys)\n  + [`onlyUpdateForPropTypes()`](#onlyupdateforproptypes)\n  + [`withContext()`](#withcontext)\n  + [`getContext()`](#getcontext)\n  + [`lifecycle()`](#lifecycle)\n  + [`toClass()`](#toclass)\n  + [`toRenderProps()`](#torenderprops)\n  + [`fromRenderProps()`](#fromrenderprops)\n* [Static property helpers](#static-property-helpers)\n  + [`setStatic()`](#setstatic)\n  + [`setPropTypes()`](#setproptypes)\n  + [`setDisplayName()`](#setdisplayname)\n* [Utilities](#utilities)\n  + [`compose()`](#compose)\n  + [`getDisplayName()`](#getdisplayname)\n  + [`wrapDisplayName()`](#wrapdisplayname)\n  + [`shallowEqual()`](#shallowequal)\n  + [`isClassComponent()`](#isclasscomponent)\n  + [`createSink()`](#createsink)\n  + [`componentFromProp()`](#componentfromprop)\n  + [`nest()`](#nest)\n  + [`hoistStatics()`](#hoiststatics)\n* [Observable utilities](#observable-utilities)\n  + [`componentFromStream()`](#componentfromstream)\n  + [`componentFromStreamWithConfig()`](#componentfromstreamwithconfig)\n  + [`mapPropsStream()`](#mappropsstream)\n  + [`mapPropsStreamWithConfig()`](#mappropsstreamwithconfig)\n  + [`createEventHandler()`](#createeventhandler)\n  + [`createEventHandlerWithConfig()`](#createeventhandlerwithconfig)\n  + [`setObservableConfig()`](#setobservableconfig)\n\n## Higher-order components\n\n### `mapProps()`\n\n```js\nmapProps(\n  propsMapper: (ownerProps: Object) => Object,\n): HigherOrderComponent\n```\n\nAccepts a function that maps owner props to a new collection of props that are passed to the base component.\n\n`mapProps()` pairs well with functional utility libraries like [lodash/fp](https://github.com/lodash/lodash/tree/npm/fp). For example, Recompose does not come with a `omitProps()` function, but you can easily build one using lodash-fp's `omit()`:\n\n```js\nconst omitProps = keys => mapProps(props => omit(keys, props))\n\n// Because of currying in lodash-fp, this is the same as\nconst omitProps = compose(mapProps, omit)\n```\n\n### `withProps()`\n\n```js\nwithProps(\n  createProps: (ownerProps: Object) => Object | Object\n): HigherOrderComponent\n```\n\nLike `mapProps()`, except the newly created props are merged with the owner props.\n\nInstead of a function, you can also pass a props object directly. In this form, it is similar to `defaultProps()`, except the provided props take precedence over props from the owner.\n\n\n### `withPropsOnChange()`\n\n```js\nwithPropsOnChange(\n  shouldMapOrKeys: Array<string> | (props: Object, nextProps: Object) => boolean,\n  createProps: (ownerProps: Object) => Object\n): HigherOrderComponent\n```\n\nLike `withProps()`, except the new props are only created when one of the owner props specified by `shouldMapOrKeys` changes. This helps ensure that expensive computations inside `createProps()` are only executed when necessary.\n\nInstead of an array of prop keys, the first parameter can also be a function that returns a boolean, given the current props and the next props. This allows you to customize when `createProps()` should be called.\n\n### `withHandlers()`\n\n```js\nwithHandlers(\n  handlerCreators: {\n    [handlerName: string]: (props: Object) => Function\n  } |\n  handlerCreatorsFactory: (initialProps) => {\n    [handlerName: string]: (props: Object) => Function\n  }\n): HigherOrderComponent\n```\n\nTakes an object map of handler creators or a factory function. These are higher-order functions that accept a set of props and return a function handler:\n\nThis allows the handler to access the current props via closure, without needing to change its signature.\n\nHandlers are passed to the base component as immutable props, whose identities are preserved across renders. This avoids a common pitfall where functional components create handlers inside the body of the function, which results in a new handler on every render and breaks downstream `shouldComponentUpdate()` optimizations that rely on prop equality. This is the main reason to use `withHandlers` to create handlers instead of using `mapProps` or `withProps`, which will create new handlers every time when it get updated.\n\nUsage example:\n\n```js\nconst enhance = compose(\n  withState('value', 'updateValue', ''),\n  withHandlers({\n    onChange: props => event => {\n      props.updateValue(event.target.value)\n    },\n    onSubmit: props => event => {\n      event.preventDefault()\n      submitForm(props.value)\n    }\n  })\n)\n\nconst Form = enhance(({ value, onChange, onSubmit }) =>\n  <form onSubmit={onSubmit}>\n    <label>Value\n      <input type=\"text\" value={value} onChange={onChange} />\n    </label>\n  </form>\n)\n```\n\n### `defaultProps()`\n\n```js\ndefaultProps(\n  props: Object\n): HigherOrderComponent\n```\n\nSpecifies props to be passed by default to the base component. Similar to `withProps()`, except the props from the owner take precedence over props provided to the HoC.\n\nAlthough it has a similar effect, using the `defaultProps()` HoC is *not* the same as setting the static `defaultProps` property directly on the component.\n\n\n### `renameProp()`\n\n```js\nrenameProp(\n  oldName: string,\n  newName: string\n): HigherOrderComponent\n```\n\nRenames a single prop.\n\nExample:\n\n```js\nconst enhance = compose(\n  withProps({ 'loadingDataFromApi': true, 'posts': [] }),\n  renameProp('loadingDataFromApi', 'isLoading'),\n  renameProp('posts', 'items'),\n);\n\nconst Posts = enhance(({ isLoading, items }) => (\n  <div>\n    <div>Loading: { isLoading ? 'yes' : 'no'}</div>\n    <ul>\n      {isLoading && items.map(({ id, title }) => (<li key={id}>{title}</li>))}\n    </ul>\n  </div>\n));\n```\n\n### `renameProps()`\n\n```js\nrenameProps(\n  nameMap: { [key: string]: string }\n): HigherOrderComponent\n```\n\nRenames multiple props, using a map of old prop names to new prop names.\n\nExample:\n\n```js\nconst enhance = compose(\n  withProps({ 'loadingDataFromApi': true, 'posts': [] }),\n  renameProps({ 'loadingDataFromApi': 'isLoading', 'posts': 'items' }),\n);\n\nconst Posts = enhance(({ isLoading, items }) => (\n  <div>\n    <div>Loading: { isLoading ? 'yes' : 'no'}</div>\n    <ul>\n      {isLoading && items.map(({ id, title }) => (<li key={id}>{title}</li>))}\n    </ul>\n  </div>\n));\n```\n\n### `flattenProp()`\n\n```js\nflattenProp(\n  propName: string\n): HigherOrderComponent\n```\n\nFlattens a prop so that its fields are spread out into the props object.\n\n```js\nconst enhance = compose(\n  withProps({\n    object: { a: 'a', b: 'b' },\n    c: 'c'\n  }),\n  flattenProp('object')\n)\nconst Abc = enhance(BaseComponent)\n\n// Base component receives props: { a: 'a', b: 'b', c: 'c', object: { a: 'a', b: 'b' } }\n```\n\nAn example use case for `flattenProp()` is when receiving fragment data from Relay. Relay fragments are passed as an object of props, which you often want flattened out into its constituent fields:\n\n```js\n// The `post` prop is an object with title, author, and content fields\nconst enhance = flattenProp('post')\nconst Post = enhance(({ title, content, author }) =>\n  <article>\n    <h1>{title}</h1>\n    <h2>By {author.name}</h2>\n    <div>{content}</div>\n  </article>\n)\n```\n\n### `withState()`\n\n```js\nwithState(\n  stateName: string,\n  stateUpdaterName: string,\n  initialState: any | (props: Object) => any\n): HigherOrderComponent\n```\n\nPasses two additional props to the base component: a state value, and a function to update that state value. The state updater has the following signature:\n\n```js\nstateUpdater<T>((prevValue: T) => T, ?callback: Function): void\nstateUpdater(newValue: any, ?callback: Function): void\n```\n\nThe first form accepts a function which maps the previous state value to a new state value. You'll likely want to use this state updater along with `withHandlers()` to create specific updater functions. For example, to create a HoC that adds basic counting functionality to a component:\n\n```js\nconst addCounting = compose(\n  withState('counter', 'setCounter', 0),\n  withHandlers({\n    increment: ({ setCounter }) => () => setCounter(n => n + 1),\n    decrement: ({ setCounter }) => () =>  setCounter(n => n - 1),\n    reset: ({ setCounter }) => () => setCounter(0)\n  })\n)\n```\n\nThe second form accepts a single value, which is used as the new state.\n\nBoth forms accept an optional second parameter, a callback function that will be executed once `setState()` is completed and the component is re-rendered.\n\nAn initial state value is required. It can be either the state value itself, or a function that returns an initial state given the initial props.\n\n### `withStateHandlers()`\n\n```js\nwithStateHandlers(\n  initialState: Object | (props: Object) => any,\n  stateUpdaters: {\n    [key: string]: (state:Object, props:Object) => (...payload: any[]) => Object\n  }\n)\n\n```\n\nPasses state object properties and immutable updater functions\nin a form of `(...payload: any[]) => Object` to the base component.\n\nEvery state updater function accepts state, props and payload and must return a new state or undefined. The new state is shallowly merged with the previous state.\nReturning undefined does not cause a component rerender.\n\nExample:\n\n```js\n  const Counter = withStateHandlers(\n    ({ initialCounter = 0 }) => ({\n      counter: initialCounter,\n    }),\n    {\n      incrementOn: ({ counter }) => (value) => ({\n        counter: counter + value,\n      }),\n      decrementOn: ({ counter }) => (value) => ({\n        counter: counter - value,\n      }),\n      resetCounter: (_, { initialCounter = 0 }) => () => ({\n        counter: initialCounter,\n      }),\n    }\n  )(\n    ({ counter, incrementOn, decrementOn, resetCounter }) =>\n      <div>\n        <Button onClick={() => incrementOn(2)}>Inc</Button>\n        <Button onClick={() => decrementOn(3)}>Dec</Button>\n        <Button onClick={resetCounter}>Reset</Button>\n      </div>\n  )\n```\n\n### `withReducer()`\n\n```js\nwithReducer<S, A>(\n  stateName: string,\n  dispatchName: string,\n  reducer: (state: S, action: A) => S,\n  initialState: S | (ownerProps: Object) => S\n): HigherOrderComponent\n```\n\nSimilar to `withState()`, but state updates are applied using a reducer function. A reducer is a function that receives a state and an action, and returns a new state.\n\nPasses two additional props to the base component: a state value, and a dispatch method. The dispatch method has the following signature:\n\n```js\ndispatch(action: Object, ?callback: Function): void\n```\n\nIt sends an action to the reducer, after which the new state is applied. It also accepts an optional second parameter, a callback function with the new state as its only argument.\n\n### `branch()`\n\n```js\nbranch(\n  test: (props: Object) => boolean,\n  left: HigherOrderComponent,\n  right: ?HigherOrderComponent\n): HigherOrderComponent\n```\n\nAccepts a test function and two higher-order components. The test function is passed the props from the owner. If it returns true, the `left` higher-order component is applied to `BaseComponent`; otherwise, the `right` higher-order component is applied. If the `right` is not supplied, it will by default render the wrapped component.\n\n### `renderComponent()`\n\n```js\nrenderComponent(\n  Component: ReactClass | ReactFunctionalComponent | string\n): HigherOrderComponent\n```\n\nTakes a component and returns a higher-order component version of that component.\n\nThis is useful in combination with another helper that expects a higher-order component, like `branch()`:\n\n```js\n// `isLoading()` is a function that returns whether or not the component\n// is in a loading state\nconst spinnerWhileLoading = isLoading =>\n  branch(\n    isLoading,\n    renderComponent(Spinner) // `Spinner` is a React component\n  )\n\n// Now use the `spinnerWhileLoading()` helper to add a loading spinner to any\n// base component\nconst enhance = spinnerWhileLoading(\n  props => !(props.title && props.author && props.content)\n)\nconst Post = enhance(({ title, author, content }) =>\n  <article>\n    <h1>{title}</h1>\n    <h2>By {author.name}</h2>\n    <div>{content}</div>\n  </article>\n)\n```\n\n### `renderNothing()`\n\n```js\nrenderNothing: HigherOrderComponent\n```\n\nA higher-order component that always renders `null`.\n\nThis is useful in combination with another helper that expects a higher-order component, like `branch()`:\n\n```js\n// `hasNoData()` is a function that returns true if the component has\n// no data\nconst hideIfNoData = hasNoData =>\n  branch(\n    hasNoData,\n    renderNothing\n  )\n\n// Now use the `hideIfNoData()` helper to hide any base component\nconst enhance = hideIfNoData(\n  props => !(props.title && props.author && props.content)\n)\nconst Post = enhance(({ title, author, content }) =>\n  <article>\n    <h1>{title}</h1>\n    <h2>By {author.name}</h2>\n    <div>{content}</div>\n  </article>\n)\n```\n\n### `shouldUpdate()`\n\n```js\nshouldUpdate(\n  test: (props: Object, nextProps: Object) => boolean\n): HigherOrderComponent\n```\n\nHigher-order component version of [`shouldComponentUpdate()`](https://facebook.github.io/react/docs/react-component.html#shouldcomponentupdate). The test function accepts both the current props and the next props.\n\n\n### `pure()`\n\n```js\npure: HigherOrderComponent\n```\n\nPrevents the component from updating unless a prop has changed. Uses `shallowEqual()` to test for changes.\n\n### `onlyUpdateForKeys()`\n\n```js\nonlyUpdateForKeys(\n  propKeys: Array<string>\n): HigherOrderComponent\n```\n\nPrevents the component from updating unless a prop corresponding to one of the given keys has updated. Uses `shallowEqual()` to test for changes.\n\nThis is a much better optimization than the popular approach of using PureRenderMixin, `shouldPureComponentUpdate()`, or Recompose's own `pure()` helper, because those tools compare *every* prop, whereas `onlyUpdateForKeys()` only cares about the props that you specify.\n\nExample:\n\n```js\n/**\n * If the owner passes unnecessary props (say, an array of comments), it will\n * not lead to wasted render cycles.\n *\n * Goes well with destructuring because it's clear which props the component\n * actually cares about.\n */\nconst enhance = onlyUpdateForKeys(['title', 'content', 'author'])\nconst Post = enhance(({ title, content, author }) =>\n  <article>\n    <h1>{title}</h1>\n    <h2>By {author.name}</h2>\n    <div>{content}</div>\n  </article>\n)\n```\n\n### `onlyUpdateForPropTypes()`\n\n```js\nonlyUpdateForPropTypes: HigherOrderComponent\n```\n\nWorks like `onlyUpdateForKeys()`, but prop keys are inferred from the `propTypes` of the base component. Useful in conjunction with `setPropTypes()`.\n\nIf the base component does not have any `propTypes`, the component will never receive any updates. This probably isn't the expected behavior, so a warning is printed to the console.\n\n```js\nimport PropTypes from 'prop-types'; // You need to import prop-types. See https://facebook.github.io/react/docs/typechecking-with-proptypes.html\n\nconst enhance = compose(\n  onlyUpdateForPropTypes,\n  setPropTypes({\n    title: PropTypes.string.isRequired,\n    content: PropTypes.string.isRequired,\n    author: PropTypes.object.isRequired\n  })\n)\n\nconst Post = enhance(({ title, content, author }) =>\n  <article>\n    <h1>{title}</h1>\n    <h2>By {author.name}</h2>\n    <div>{content}</div>\n  </article>\n)\n```\n\n### `withContext()`\n\n```js\nwithContext(\n  childContextTypes: Object,\n  getChildContext: (props: Object) => Object\n): HigherOrderComponent\n```\n\nProvides context to the component's children. `childContextTypes` is an object of React prop types. `getChildContext()` is a function that returns the child context. Use along with `getContext()`.\n\n### `getContext()`\n\n```js\ngetContext(\n  contextTypes: Object\n): HigherOrderComponent\n```\n\nGets values from context and passes them along as props. Use along with `withContext()`.\n\n### `lifecycle()`\n\n```js\nlifecycle(\n  spec: Object,\n): HigherOrderComponent\n```\n\nA higher-order component version of [`React.Component()`](https://facebook.github.io/react/docs/react-api.html#react.component). It supports the entire `Component` API, except the `render()` method, which is implemented by default (and overridden if specified; an error will be logged to the console). You should use this helper as an escape hatch, in case you need to access component lifecycle methods.\n\nAny state changes made in a lifecycle method, by using `setState`, will be propagated to the wrapped component as props.\n\nExample:\n```js\nconst PostsList = ({ posts }) => (\n  <ul>{posts.map(p => <li>{p.title}</li>)}</ul>\n)\n\nconst PostsListWithData = lifecycle({\n  componentDidMount() {\n    fetchPosts().then(posts => {\n      this.setState({ posts });\n    })\n  }\n})(PostsList);\n```\n\n### `toClass()`\n\n```js\ntoClass: HigherOrderComponent\n```\n\nTakes a function component and wraps it in a class. This can be used as a fallback for libraries that need to add a ref to a component, like Relay.\n\nIf the base component is already a class, it returns the given component.\n\n\n### `toRenderProps()`\n\n```js\ntoRenderProps(\n  hoc: HigherOrderComponent\n): ReactFunctionalComponent\n```\n\nCreates a component that accepts a function as a children with the high-order component applied to it. \n\nExample:\n```js\nconst enhance = withProps(({ foo }) => ({ fooPlusOne: foo + 1 }))\nconst Enhanced = toRenderProps(enhance)\n\n<Enhanced foo={1}>{({ fooPlusOne }) => <h1>{fooPlusOne}</h1>}</Enhanced>\n// renders <h1>2</h1>\n```\n\n### `fromRenderProps()`\n\n```js\nfromRenderProps(\n  RenderPropsComponent: ReactClass | ReactFunctionalComponent,\n  propsMapper: (...props: any[]) => Object,\n  renderPropName?: string\n): HigherOrderComponent\n```\n\nTakes a **render props** component and a function that maps props to a new collection of props that are passed to the base component.\n\nThe default value of third parameter (`renderPropName`) is `children`. You can use any prop (e.g., `render`) for render props component to work.\n\n> Check the official documents [Render Props](https://reactjs.org/docs/render-props.html#using-props-other-than-render) for more details.\n\n```js\nimport { fromRenderProps } from 'recompose';\nconst { Consumer: ThemeConsumer } = React.createContext({ theme: 'dark' });\nconst { Consumer: I18NConsumer } = React.createContext({ i18n: 'en' });\nconst RenderPropsComponent = ({ render, value }) => render({ value: 1 });\n\nconst EnhancedApp = compose(\n  // Context (Function as Child Components)\n  fromRenderProps(ThemeConsumer, ({ theme }) => ({ theme })),\n  fromRenderProps(I18NConsumer, ({ i18n }) => ({ locale: i18n })),\n  // Render props\n  fromRenderProps(RenderPropsComponent, ({ value }) => ({ value }), 'render'),\n)(App);\n\n// Same as\nconst EnhancedApp = () => (\n  <ThemeConsumer>\n    {({ theme }) => (\n      <I18NConsumer>\n        {({ i18n }) => (\n          <RenderPropsComponent\n            render={({ value }) => (\n              <App theme={theme} locale={i18n} value={value} />\n            )}\n          />\n        )}\n      </I18NConsumer>\n    )}\n  </ThemeConsumer>\n)\n```\n\n## Static property helpers\n\nThese functions look like higher-order component helpers — they are curried and component-last. However, rather than returning a new component, they mutate the base component by setting or overriding a static property.\n\n### `setStatic()`\n\n```js\nsetStatic(\n  key: string,\n  value: any\n): HigherOrderComponent\n```\n\nAssigns a value to a static property on the base component.\n\n### `setPropTypes()`\n\n```js\nsetPropTypes(\n  propTypes: Object\n): HigherOrderComponent\n```\n\nAssigns to the `propTypes` property on the base component.\n\n### `setDisplayName()`\n\n```js\nsetDisplayName(\n  displayName: string\n): HigherOrderComponent\n```\n\nAssigns to the `displayName` property on the base component.\n\n## Utilities\n\nRecompose also includes some additional helpers that aren't higher-order components, but are still useful.\n\n### `compose()`\n\n```js\ncompose(...functions: Array<Function>): Function\n```\n\nUse to compose multiple higher-order components into a single higher-order component. This works exactly like the function of the same name in Redux, or lodash's `flowRight()`.\n\n### `getDisplayName()`\n\n```js\ngetDisplayName(\n  component: ReactClass | ReactFunctionalComponent\n): string\n```\n\nReturns the display name of a React component. Falls back to `'Component'`.\n\n### `wrapDisplayName()`\n\n```js\nwrapDisplayName(\n  component: ReactClass | ReactFunctionalComponent,\n  wrapperName: string\n): string\n```\n\nReturns a wrapped version of a React component's display name. For instance, if the display name of `component` is `'Post'`, and `wrapperName` is `'mapProps'`, the return value is `'mapProps(Post)'`. Most Recompose higher-order components use `wrapDisplayName()`.\n\n### `shallowEqual()`\n\n```js\nshallowEqual(a: Object, b: Object): boolean\n```\n\nReturns true if objects are shallowly equal.\n\n### `isClassComponent()`\n\n```js\nisClassComponent(value: any): boolean\n```\n\nReturns true if the given value is a React component class.\n\n### `createSink()`\n\n```js\ncreateSink(callback: (props: Object) => void): ReactClass\n```\n\nCreates a component that renders nothing (null) but calls a callback when receiving new props.\n\n### `componentFromProp()`\n\n```js\ncomponentFromProp(propName: string): ReactFunctionalComponent\n```\n\nCreates a component that accepts a component as a prop and renders it with the remaining props.\n\nExample:\n\n```js\nconst enhance = defaultProps({ component: 'button' })\nconst Button = enhance(componentFromProp('component'))\n\n<Button foo=\"bar\" /> // renders <button foo=\"bar\" />\n<Button component=\"a\" foo=\"bar\" />  // renders <a foo=\"bar\" />\n<Button component={Link} foo=\"bar\" />  // renders <Link foo=\"bar\" />\n```\n\n### `nest()`\n\n```js\nnest(\n  ...Components: Array<ReactClass | ReactFunctionalComponent | string>\n): ReactClass\n```\n\nComposes components by nesting each one inside the previous. For example:\n\n```js\n// Given components A, B, and C\nconst ABC = nest(A, B, C)\n<ABC pass=\"through\">Child</ABC>\n\n// Effectively the same as\n<A pass=\"through\">\n  <B pass=\"through\">\n    <C pass=\"through\">\n      Child\n    </C>\n  </B>\n</A>\n```\n\n### `hoistStatics()`\n\n```js\nhoistStatics(\n  hoc: HigherOrderComponent,\n  blacklist: Object\n): HigherOrderComponent\n```\n\nAugments a higher-order component so that when used, it copies non-react static properties from the base component to the new component. This is helpful when using Recompose with libraries like Relay.\n\nNote that this only hoists _non-react_ statics. The following static properties will not be hoisted: `childContextTypes`, `contextTypes`, `defaultProps`, `displayName`, `getDefaultProps`, `mixins`, `propTypes`, and `type`. The following native static methods will also be ignored: `name`, `length`, `prototype`, `caller`, `arguments`, and `arity`.\n\nYou can exclude more static properties by passing them as `blacklist` object:\n\n```js\nhoistStatics(EnhancedComponent, { foo: true })(BaseComponent) // Exclude `foo`\n```\n\n## Observable utilities\n\nIt turns out that much of the React Component API can be expressed in terms of observables:\n\n- Instead of `setState()`, combine multiple streams together.\n- Instead of `getInitialState()`, use `startWith()` or `concat()`.\n- Instead of `shouldComponentUpdate()`, use `distinctUntilChanged()`, `debounce()`, etc.\n\nOther benefits include:\n\n- No distinction between state and props – everything is a stream.\n- No need to worry about unsubscribing from event listeners. Subscriptions are handled for you.\n- Sideways data loading is trivial – just combine the props stream with an external stream.\n- Access to an ecosystem of observable libraries, such as RxJS.\n\n\n**Recompose's observable utilities can be configured to work with any observable or stream-like library. See [`setObservableConfig()`](#setobservableconfig) below for details.**\n\n### `componentFromStream()`\n\n```js\ncomponentFromStream(\n  propsToReactNode: (props$: Observable<object>) => Observable<ReactNode>\n): ReactComponent\n```\n\nCreates a React component by mapping an observable stream of props to a stream of React nodes (vdom).\n\nYou can think of `propsToReactNode` as a function `f` such that\n\n```js\nconst vdom$ = f(props$)\n```\n\nwhere `props$` is a stream of props and `vdom$` is a stream of React nodes. This formulation similar to the popular notion of React views as a function, often communicated as\n\n```\nv = f(d)\n```\n\nExample:\n\n```js\nconst Counter = componentFromStream(props$ => {\n  const { handler: increment, stream: increment$ } = createEventHandler()\n  const { handler: decrement, stream: decrement$ } = createEventHandler()\n  const count$ = Observable.merge(\n      increment$.mapTo(1),\n      decrement$.mapTo(-1)\n    )\n    .startWith(0)\n    .scan((count, n) => count + n, 0)\n\n  return props$.combineLatest(\n    count$,\n    (props, count) =>\n      <div {...props}>\n        Count: {count}\n        <button onClick={increment}>+</button>\n        <button onClick={decrement}>-</button>\n      </div>\n  )\n})\n```\n\n### `componentFromStreamWithConfig()`\n\n```js\ncomponentFromStreamWithConfig<Stream>(\n  config: {\n    fromESObservable<T>: ?(observable: Observable<T>) => Stream<T>,\n    toESObservable<T>: ?(stream: Stream<T>) => Observable<T>,\n  }\n) => (\n  propsToReactNode: (props$: Stream<object>) => Stream<ReactNode>\n): ReactComponent\n```\n\nAlternative to `componentFromStream()` that accepts an observable config and returns a customized `componentFromStream()` which uses the specified observable library. This option is recommended if you want to avoid global state with `setObservableConfig()`.\n\n**Note: The following configuration modules are not included in the main export. You must import them individually, as shown in the examples.**\n\n#### RxJS\n\n```js\nimport rxjsConfig from 'recompose/rxjsObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(rxjsConfig)\n```\n\n#### RxJS 4 (legacy)\n\n```js\nimport rxjs4Config from 'recompose/rxjs4ObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(rxjs4Config)\n```\n\n#### most\n\n```js\nimport mostConfig from 'recompose/mostObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(mostConfig)\n```\n\n#### xstream\n\n```js\nimport xstreamConfig from 'recompose/xstreamObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(xstreamConfig)\n```\n\n#### Bacon\n\n```js\nimport baconConfig from 'recompose/baconObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(baconConfig)\n```\n\n#### Kefir\n\n```js\nimport kefirConfig from 'recompose/kefirObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(kefirConfig)\n```\n\n#### Flyd\n\n```js\nimport flydConfig from 'recompose/flydObservableConfig'\nconst componentFromStream = componentFromStreamWithConfig(flydConfig)\n```\n\n### `mapPropsStream()`\n\n```js\nmapPropsStream(\n  ownerPropsToChildProps: (props$: Observable<object>) => Observable<object>,\n  BaseComponent: ReactElementType\n): ReactComponent\n```\n\nA higher-order component version of `componentFromStream()` — accepts a function that maps an observable stream of owner props to a stream of child props, rather than directly to a stream of React nodes. The child props are then passed to a base component.\n\nYou may want to use this version to interoperate with other Recompose higher-order component helpers.\n\n### `mapPropsStreamWithConfig()`\n```js\nmapPropsStreamWithConfig<Stream>(\n  config: {\n    fromESObservable<T>: ?(observable: Observable<T>) => Stream<T>,\n    toESObservable<T>: ?(stream: Stream<T>) => Observable<T>,\n  },\n) => (\n  ownerPropsToChildProps: (props$: Stream<object>) => Stream<object>,\n  BaseComponent: ReactElementType\n): ReactComponent\n```\n\nAlternative to `mapPropsStream()` that accepts a observable config and returns a customized `mapPropsStream()` that uses the specified observable library. See `componentFromStreamWithConfig()` above.\n\n```js\nconst enhance = mapPropsStream(props$ => {\n  const timeElapsed$ = Observable.interval(1000)\n  return props$.combineLatest(timeElapsed$, (props, timeElapsed) => ({\n    ...props,\n    timeElapsed\n  }))\n})\n\nconst Timer = enhance(({ timeElapsed }) =>\n  <div>Time elapsed: {timeElapsed}</div>\n)\n```\n\n### `createEventHandler()`\n\n```js\ncreateEventHandler<T>(): {\n  handler: (value: T) => void,\n  stream: Observable<T>\n}\n```\n\nReturns an object with properties `handler` and `stream`. `stream` is an observable sequence, and `handler` is a function that pushes new values onto the sequence. Useful for creating event handlers like `onClick`.\n\n### `createEventHandlerWithConfig()`\n```js\ncreateEventHandlerWithConfig<T>(\n  config: {\n    fromESObservable<T>: ?(observable: Observable<T>) => Stream<T>,\n    toESObservable<T>: ?(stream: Stream<T>) => Observable<T>,\n  }\n) => (): {\n  handler: (value: T) => void,\n  stream: Observable<T>\n}\n```\n\nAlternative to `createEventHandler()` that accepts an observable config and returns a customized `createEventHandler()` that uses the specified observable library. See `componentFromStreamWithConfig()` above.\n\n### `setObservableConfig()`\n\n```js\nsetObservableConfig<Stream>({\n  fromESObservable<T>: ?(observable: Observable<T>) => Stream<T>,\n  toESObservable<T>: ?(stream: Stream<T>) => Observable<T>\n})\n```\n\n**Note: `setObservableConfig()` uses global state, and could break apps if used inside a package intended to be shared. See `componentFromStreamWithConfig()` and `mapPropsStreamWithConfig()` as alternatives for package authors.**\n\nObservables in Recompose are plain objects that conform to the [ES Observable proposal](https://github.com/zenparsing/es-observable). Usually, you'll want to use them alongside an observable library like RxJS so that you have access to its suite of operators. By default, this requires you to convert the observables provided by Recompose before applying any transforms:\n\n```js\nmapPropsStream(props$ => {\n  const rxjsProps$ = Rx.Observable.from(props$)\n  // ...now you can use map, filter, scan, etc.\n  return transformedProps$\n})\n```\n\nThis quickly becomes tedious. Rather than performing this transform for each stream individually, `setObservableConfig()` sets a global observable transform that is applied automatically.\n\n```js\nimport Rx from 'rxjs'\nimport { setObservableConfig } from 'recompose'\n\nsetObservableConfig({\n  // Converts a plain ES observable to an RxJS 5 observable\n  fromESObservable: Rx.Observable.from\n})\n```\n\nIn addition to `fromESObservable`, the config object also accepts `toESObservable`, which converts a stream back into an ES observable. Because RxJS 5 observables already conform to the ES observable spec, `toESObservable` is not necessary in the above example. However, it is required for libraries like RxJS 4 or xstream, whose streams do not conform to the ES observable spec.\n\nFortunately, you likely don't need to worry about how to configure Recompose for your favorite stream library, because Recompose provides drop-in configuration for you.\n\n**Note: The following configuration modules are not included in the main export. You must import them individually, as shown in the examples.**\n\n#### RxJS\n\n```js\nimport rxjsconfig from 'recompose/rxjsObservableConfig'\nsetObservableConfig(rxjsconfig)\n```\n\n#### RxJS 4 (legacy)\n\n```js\nimport rxjs4config from 'recompose/rxjs4ObservableConfig'\nsetObservableConfig(rxjs4config)\n```\n\n#### most\n\n```js\nimport mostConfig from 'recompose/mostObservableConfig'\nsetObservableConfig(mostConfig)\n```\n\n#### xstream\n\n```js\nimport xstreamConfig from 'recompose/xstreamObservableConfig'\nsetObservableConfig(xstreamConfig)\n```\n\n#### Bacon\n\n```js\nimport baconConfig from 'recompose/baconObservableConfig'\nsetObservableConfig(baconConfig)\n```\n\n#### Kefir\n\n```js\nimport kefirConfig from 'recompose/kefirObservableConfig'\nsetObservableConfig(kefirConfig)\n```\n\n#### Flyd\n\n```js\nimport flydConfig from 'recompose/flydObservableConfig'\nsetObservableConfig(flydConfig)\n```\n"
  },
  {
    "path": "docs/flow.md",
    "content": "# Flow support for recompose\n\n## How it works\n\nIn most cases all you need is to declare a props type of enhanced Component.\nFlow will infer all other types you need.\n\nExample:\n\n```javascript\nimport type { HOC } from 'recompose';\n\ntype EnhancedComponentProps = {\n  text?: string,\n};\n\nconst baseComponent = ({ text }) => <div>{text}</div>;\n\nconst enhance:HOC<*, EnhancedComponentProps> = compose(\n  defaultProps({\n    text: 'world',\n  }),\n  withProps(({ text }) => ({\n    text: `Hello ${text}`\n  }))\n);\n\nexport default enhance(baseComponent);\n\n```\n\nSee it in action.\n\n![recompose-flow](https://user-images.githubusercontent.com/5077042/28116959-0c96ae2c-6714-11e7-930e-b1454c629908.gif)\n\n## How to start\n\nThe easiest way is to start from example.\n\nLook at [this](http://grader-meets-16837.netlify.com/) app [source](../types/flow-example)\n\n\n## Support\n\nType definitions of recompose HOCs are splitted into 2 parts.\n\n### Part 1 - HOCs with good flow support\n\nIn most cases you can use them without big issues.\nType inference and errors detection works near well.\n\nThese HOCs are: *defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure, onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange, onlyUpdateForPropTypes, toClass, withContext, getContext, setStatic, setPropTypes, setDisplayName*\n\n#### Known issues for \"good\" HOCs\n\nsee `test_mapProps.js` - inference work but type errors are not detected in hocs\n\n### Part 2 - other HOCs\n\nTo use these HOCs - you need to provide type information (no automatic type inference).\nYou must be a good voodoo dancer.\n\nSee `test_voodoo.js` for the idea.\n\nSome recomendations:\n\n- *flattenProp,renameProp, renameProps* can easily be replaced with _withProps_\n- *withReducer, withState* -> use _withStateHandlers_ instead\n- _lifecycle_ -> you don't need recompose if you need a _lifecycle_, just use React class instead\n- _mapPropsStream_ -> see `test_mapPropsStream.js`\n\n#### Known issues for above HOCs\n\nSee `test_voodoo.js`, `test_mapPropsStream.js`\n\n### Utils\n\n*getDisplayName, wrapDisplayName, shallowEqual,isClassComponent, createSink, componentFromProp, nest, hoistStatics.*\n\n### Articles\n\n[Typing Higher-order Components in Recompose With Flow](https://medium.com/flow-type/flow-support-in-recompose-1b76f58f4cfc)\n\n### Faq\n\nWhy to use existential type with `HOC<*, Blbla>` isn't it possible to avoid this?\n\n*I tried to use type alias but haven't found how to make it work.*\n\n## Thanks\n\nBig thanks to [@gcanti](https://github.com/gcanti) for his work on PR [#241](https://github.com/acdlite/recompose/pull/241), it was nice and clear base for current definitions.\n"
  },
  {
    "path": "docs/performance.md",
    "content": "# Should I use this? Performance and other concerns\n\nIf function composition doesn't scare you, then yes, I think so. I believe using higher-order component helpers leads to smaller, more focused components, and provides a better programming model than using classes for operations—like `mapProps()` or `shouldUpdate()`—that aren't inherently class-y.\n\nThat being said, any abstraction over an existing API is going to come with trade-offs. There is a performance overhead when introducing a new component to the tree. I suspect this cost is negligible compared to the gains achieved by blocking subtrees from re-rendering using `shouldComponentUpdate()`—which Recompose makes easy with its `shouldUpdate()` and `onlyUpdateForKeys()` helpers. In the future, I'll work on some benchmarks so we know what we're dealing with.\n\nHowever, many of Recompose's higher-order component helpers are implemented using stateless function components rather than class components. Eventually, React will include optimizations for stateless components.\n"
  },
  {
    "path": "package.json",
    "content": "{\n  \"name\": \"recompose-build\",\n  \"private\": true,\n  \"author\": \"Andrew Clark <acdlite@me.com>\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"git://github.com/acdlite/recompose.git\"\n  },\n  \"license\": \"MIT\",\n  \"scripts\": {\n    \"lint\": \"eslint scripts src\",\n    \"build:recompose\": \"cross-env PACKAGE_NAME=recompose rollup --config scripts/rollup.config.js\",\n    \"test\": \"jest && flow check && cross-env SNAPSHOT=match npm run build:recompose\",\n    \"test:watch\": \"cross-env BABEL_ENV=cjs jest --watch\",\n    \"release\": \"node scripts/release.js\",\n    \"postinstall\": \"node scripts/installNestedPackageDeps.js\",\n    \"format\": \"prettier --semi false --trailing-comma es5 --single-quote --write 'scripts/*.js' 'src/packages/*/*.js' 'src/packages/*/!(node_modules)/**/*.js'\",\n    \"precommit\": \"lint-staged\",\n    \"prepush\": \"yarn test\"\n  },\n  \"jest\": {\n    \"testMatch\": [\n      \"<rootDir>/src/**/__tests__/**/*-test.js\"\n    ],\n    \"coverageReporters\": [\n      \"text-summary\",\n      \"lcov\"\n    ],\n    \"setupTestFrameworkScriptFile\": \"<rootDir>/scripts/jest.setup.js\"\n  },\n  \"lint-staged\": {\n    \"*.js\": [\n      \"prettier --semi false --trailing-comma es5 --single-quote --write\",\n      \"eslint --fix\",\n      \"git add\"\n    ]\n  },\n  \"devDependencies\": {\n    \"@babel/cli\": \"^7.0.0\",\n    \"@babel/core\": \"^7.0.0\",\n    \"@babel/plugin-proposal-class-properties\": \"^7.0.0\",\n    \"@babel/plugin-transform-runtime\": \"^7.0.0\",\n    \"@babel/preset-env\": \"^7.0.0\",\n    \"@babel/preset-react\": \"^7.0.0\",\n    \"@babel/runtime\": \"^7.0.0\",\n    \"babel-core\": \"^7.0.0-bridge.0\",\n    \"babel-eslint\": \"^9.0.0\",\n    \"babel-jest\": \"^22.4.3\",\n    \"baconjs\": \"^0.7.84\",\n    \"chalk\": \"^1.1.1\",\n    \"change-case\": \"^2.3.1\",\n    \"codecov\": \"^1.0.1\",\n    \"create-react-class\": \"^15.5.0\",\n    \"cross-env\": \"^4.0.0\",\n    \"enzyme\": \"^3.3.0\",\n    \"eslint\": \"^5.3.0\",\n    \"eslint-config-airbnb\": \"^17.0.0\",\n    \"eslint-config-prettier\": \"^2.9.0\",\n    \"eslint-plugin-import\": \"^2.13.0\",\n    \"eslint-plugin-jsx-a11y\": \"^6.1.1\",\n    \"eslint-plugin-prettier\": \"^2.0.1\",\n    \"eslint-plugin-react\": \"^7.10.0\",\n    \"flow-bin\": \"^0.72.0\",\n    \"flyd\": \"^0.2.4\",\n    \"husky\": \"^0.13.3\",\n    \"jest\": \"^22.4.3\",\n    \"kefir\": \"^3.2.3\",\n    \"lint-staged\": \"^3.4.0\",\n    \"most\": \"^1.0.2\",\n    \"prettier\": \"^1.2.2\",\n    \"prop-types\": \"^15.6.1\",\n    \"react\": \"^16.3.1\",\n    \"react-dom\": \"^16.3.1\",\n    \"readline-sync\": \"^1.2.21\",\n    \"rollup\": \"^0.65.0\",\n    \"rollup-plugin-babel\": \"^4.0.1\",\n    \"rollup-plugin-commonjs\": \"^9.1.6\",\n    \"rollup-plugin-node-resolve\": \"^3.3.0\",\n    \"rollup-plugin-replace\": \"^2.0.0\",\n    \"rollup-plugin-size-snapshot\": \"^0.6.1\",\n    \"rollup-plugin-uglify\": \"^4.0.0\",\n    \"rx\": \"^4.1.0\",\n    \"rxjs\": \"^5.0.0\",\n    \"shelljs\": \"^0.6.0\",\n    \"sinon\": \"^1.17.1\",\n    \"webpack\": \"^2.4.1\",\n    \"xstream\": \"^5.0.5\"\n  },\n  \"devEngines\": {\n    \"node\": \"5.x\",\n    \"npm\": \"3.x\"\n  },\n  \"dependencies\": {\n    \"enzyme-adapter-react-16\": \"^1.1.1\"\n  }\n}\n"
  },
  {
    "path": "scripts/getPackageNames.js",
    "content": "const fs = require('fs')\nconst path = require('path')\n\nexports.PACKAGES_SRC_DIR = './src/packages'\nexports.PACKAGES_OUT_DIR = './lib/packages'\n\nlet names\n\nexports.getPackageNames = () => {\n  if (!names) {\n    names = fs.readdirSync(exports.PACKAGES_SRC_DIR).filter(file => {\n      try {\n        const packageJsonPath = path.resolve(\n          exports.PACKAGES_SRC_DIR,\n          file,\n          'package.json'\n        )\n        return fs.statSync(packageJsonPath).isFile()\n      } catch (error) {\n        return false\n      }\n    })\n  }\n  return names\n}\n"
  },
  {
    "path": "scripts/installNestedPackageDeps.js",
    "content": "const path = require('path')\nconst { exec } = require('shelljs')\nconst { getPackageNames, PACKAGES_SRC_DIR } = require('./getPackageNames.js')\n\nconst packageNames = getPackageNames()\n\npackageNames.forEach(packageName => {\n  const sourceDir = path.resolve(PACKAGES_SRC_DIR, packageName)\n  exec(`cd ${sourceDir} && yarn`, { async: true })\n})\n"
  },
  {
    "path": "scripts/jest.setup.js",
    "content": "/* eslint-disable */\njasmine.DEFAULT_TIMEOUT_INTERVAL = 20000\n\nimport Enzyme from 'enzyme'\nimport Adapter from 'enzyme-adapter-react-16'\n\nEnzyme.configure({ adapter: new Adapter() })\n"
  },
  {
    "path": "scripts/release.js",
    "content": "/* eslint global-require: 0 */\n/* eslint-disable import/no-dynamic-require, no-console */\nconst fs = require('fs')\nconst path = require('path')\nconst { exec, exit, rm, cp, test } = require('shelljs')\nconst chalk = require('chalk')\nconst { flowRight: compose } = require('lodash')\nconst readline = require('readline-sync')\nconst semver = require('semver')\nconst { pascalCase } = require('change-case')\n\nconst BIN = './node_modules/.bin'\n\nconst {\n  PACKAGES_SRC_DIR,\n  PACKAGES_OUT_DIR,\n  getPackageNames,\n} = require('./getPackageNames')\n\nconst BASE_PACKAGE_LOC = '../src/basePackage.json'\n\nconst consoleLog = console.log.bind(console)\nconst log = compose(consoleLog, chalk.bold)\nconst logSuccess = compose(consoleLog, chalk.green.bold)\nconst logError = compose(consoleLog, chalk.red.bold)\n\nconst writeFile = (filepath, string) =>\n  fs.writeFileSync(filepath, string, 'utf8')\n\ntry {\n  if (exec('git diff-files --quiet').code !== 0) {\n    logError(\n      'You have unsaved changes in the working tree. ' +\n        'Commit or stash changes before releasing.'\n    )\n    exit(1)\n  }\n\n  const packageNames = getPackageNames()\n\n  let packageName = readline.question('Name of package to release: ')\n\n  while (!packageNames.includes(packageName)) {\n    packageName = readline.question(\n      `The package \"${packageName}\" does not exist in this project. ` +\n        'Choose again: '\n    )\n  }\n\n  const libraryName = pascalCase(packageName)\n\n  const versionLoc = path.resolve(PACKAGES_SRC_DIR, packageName, 'VERSION')\n  const version = fs.readFileSync(versionLoc, 'utf8').trim()\n\n  let nextVersion = readline.question(\n    `Next version of ${packageName} (current version is ${version}): `\n  )\n\n  while (\n    !(\n      !nextVersion ||\n      (semver.valid(nextVersion) && semver.gt(nextVersion, version))\n    )\n  ) {\n    nextVersion = readline.question(\n      `Must provide a valid version that is greater than ${version}, ` +\n        'or leave blank to skip: '\n    )\n  }\n\n  log('Running tests...')\n\n  if (exec('yarn run lint && yarn test').code !== 0) {\n    logError('The test command did not exit cleanly. Aborting release.')\n    exit(1)\n  }\n\n  logSuccess('Tests were successful.')\n\n  const sourceDir = path.resolve(PACKAGES_SRC_DIR, packageName)\n  const outDir = path.resolve(PACKAGES_OUT_DIR, packageName)\n\n  log('Cleaning destination directory...')\n  rm('-rf', outDir)\n\n  log('Compiling source files...')\n\n  exec(\n    'cross-env NODE_ENV=cjs ' +\n      `${path.resolve(BIN)}/babel ${sourceDir} ` +\n      `--out-dir ${path.resolve(\n        outDir\n      )} --ignore=\"**/__tests__/**,**/node_modules/**\"`\n  )\n\n  log('Copying additional project files...')\n  const additionalProjectFiles = ['README.md', '.npmignore']\n  additionalProjectFiles.forEach(filename => {\n    const src = path.resolve(sourceDir, filename)\n\n    if (!test('-e', src)) return\n\n    cp('-Rf', src, outDir)\n  })\n\n  log('Generating package.json...')\n  const packageConfig = Object.assign(\n    { name: packageName, version: nextVersion },\n    require(BASE_PACKAGE_LOC),\n    require(path.resolve(sourceDir, 'package.json'))\n  )\n\n  writeFile(\n    path.resolve(outDir, 'package.json'),\n    JSON.stringify(packageConfig, null, 2)\n  )\n\n  log('Copying license...')\n  cp('-f', 'LICENSE.md', outDir)\n\n  log(`Building ${packageName}...`)\n  const runRollup = () => `yarn build:${packageName}`\n  if (exec(runRollup()).code !== 0) {\n    exit(1)\n  }\n\n  log(`Preparing ${libraryName}.cjs.js.flow...`)\n  cp(\n    '-f',\n    path.resolve(sourceDir, 'index.js.flow'),\n    path.resolve(outDir, 'dist', `${libraryName}.cjs.js.flow`)\n  )\n\n  log(`About to publish ${packageName}@${nextVersion} to npm.`)\n  if (!readline.keyInYN('Sound good? ')) {\n    log('OK. Stopping release.')\n    exit(0)\n  }\n\n  log('Publishing...')\n  if (exec(`cd ${outDir} && npm publish`).code !== 0) {\n    logError('Publish failed. Aborting release.')\n    exit(1)\n  }\n\n  logSuccess(`${packageName}@${nextVersion} was successfully published.`)\n\n  log('Updating VERSION file...')\n  writeFile(versionLoc, `${nextVersion}\\n`)\n\n  log('Committing changes...')\n  const newTagName = `v${nextVersion}`\n  exec(`git add ${versionLoc}`)\n  exec(`git commit -m \"${packageName} ${newTagName}\"`)\n\n  if (packageName === 'recompose') {\n    log(`Tagging release... (${newTagName})`)\n    exec(`git tag ${newTagName}`)\n  }\n\n  log('Pushing to GitHub...')\n  exec('git push')\n  exec('git push --tags')\n\n  logSuccess('Done.')\n} catch (error) {\n  logError('Release failed due to an error', error)\n}\n"
  },
  {
    "path": "scripts/rollup.config.js",
    "content": "import path from 'path'\nimport nodeResolve from 'rollup-plugin-node-resolve'\nimport babel from 'rollup-plugin-babel'\nimport replace from 'rollup-plugin-replace'\nimport commonjs from 'rollup-plugin-commonjs'\nimport { uglify } from 'rollup-plugin-uglify'\nimport { sizeSnapshot } from 'rollup-plugin-size-snapshot'\nimport { pascalCase } from 'change-case'\n\nconst { PACKAGES_SRC_DIR, PACKAGES_OUT_DIR } = require('./getPackageNames')\n\nconst packageName = process.env.PACKAGE_NAME\n\nconst libraryName = pascalCase(packageName)\n\nconst input = `./${path.join(PACKAGES_SRC_DIR, packageName, 'index.js')}`\n\nconst outDir = path.join(PACKAGES_OUT_DIR, packageName, 'dist')\n\nconst isExternal = id => !id.startsWith('.') && !id.startsWith('/')\n\nconst getBabelOptions = ({ useESModules }) => ({\n  exclude: '**/node_modules/**',\n  runtimeHelpers: true,\n  plugins: [['@babel/transform-runtime', { useESModules }]],\n})\n\nconst matchSnapshot = process.env.SNAPSHOT === 'match'\n\nexport default [\n  {\n    input,\n    output: {\n      file: `${outDir}/${libraryName}.umd.js`,\n      format: 'umd',\n      name: libraryName,\n      globals: {\n        react: 'React',\n      },\n    },\n    external: ['react'],\n    plugins: [\n      nodeResolve(),\n      babel(getBabelOptions({ useESModules: true })),\n      commonjs(),\n      replace({ 'process.env.NODE_ENV': JSON.stringify('development') }),\n      sizeSnapshot({ matchSnapshot }),\n    ],\n  },\n\n  {\n    input,\n    output: {\n      file: `${outDir}/${libraryName}.min.js`,\n      format: 'umd',\n      name: libraryName,\n      globals: {\n        react: 'React',\n      },\n    },\n    external: ['react'],\n    plugins: [\n      nodeResolve(),\n      babel(getBabelOptions({ useESModules: true })),\n      commonjs(),\n      replace({ 'process.env.NODE_ENV': JSON.stringify('production') }),\n      sizeSnapshot({ matchSnapshot }),\n      uglify(),\n    ],\n  },\n\n  {\n    input,\n    output: {\n      file: `${outDir}/${libraryName}.cjs.js`,\n      format: 'cjs',\n    },\n    external: isExternal,\n    plugins: [babel(getBabelOptions({ useESModules: false }))],\n  },\n\n  {\n    input,\n    output: {\n      file: `${outDir}/${libraryName}.esm.js`,\n      format: 'es',\n    },\n    external: isExternal,\n    plugins: [\n      babel(getBabelOptions({ useESModules: true })),\n      sizeSnapshot({ matchSnapshot }),\n    ],\n  },\n]\n"
  },
  {
    "path": "src/basePackage.json",
    "content": "{\n  \"author\": \"Andrew Clark <acdlite@me.com>\",\n  \"repository\": {\n    \"type\": \"git\",\n    \"url\": \"https://github.com/acdlite/recompose.git\"\n  },\n  \"license\": \"MIT\",\n  \"bugs\": {\n    \"url\": \"https://github.com/acdlite/recompose/issues\"\n  },\n  \"homepage\": \"https://github.com/acdlite/recompose\"\n}\n"
  },
  {
    "path": "src/packages/recompose/.npmignore",
    "content": "/**/__tests__\n"
  },
  {
    "path": "src/packages/recompose/README.md",
    "content": "recompose\n=========\n\n[![npm version](https://img.shields.io/npm/v/recompose.svg?style=flat-square)](https://www.npmjs.com/package/recompose)\n\nRecompose is a React utility belt for function components and higher-order components. See the [GitHub project page](https://github.com/acdlite/recompose) for more information.\n"
  },
  {
    "path": "src/packages/recompose/VERSION",
    "content": "0.30.0\n"
  },
  {
    "path": "src/packages/recompose/__tests__/branch-test.js",
    "content": "import sinon from 'sinon'\nimport React from 'react'\nimport { mount } from 'enzyme'\nimport { branch, compose, withState, withProps } from '../'\n\ntest('branch tests props and applies one of two HoCs, for true and false', () => {\n  const SayMyName = compose(\n    withState('isBad', 'updateIsBad', false),\n    branch(\n      props => props.isBad,\n      withProps({ name: 'Heisenberg' }),\n      withProps({ name: 'Walter' })\n    )\n  )(({ isBad, name, updateIsBad }) =>\n    <div>\n      <div className=\"isBad\">\n        {isBad ? 'true' : 'false'}\n      </div>\n      <div className=\"name\">\n        {name}\n      </div>\n      <button onClick={() => updateIsBad(b => !b)}>Toggle</button>\n    </div>\n  )\n\n  expect(SayMyName.displayName).toBe('withState(branch(Component))')\n\n  const wrapper = mount(<SayMyName />)\n  const getIsBad = () => wrapper.find('.isBad').text()\n  const getName = () => wrapper.find('.name').text()\n  const toggle = wrapper.find('button')\n\n  expect(getIsBad()).toBe('false')\n  expect(getName()).toBe('Walter')\n\n  toggle.simulate('click')\n\n  expect(getIsBad()).toBe('true')\n  expect(getName()).toBe('Heisenberg')\n})\n\ntest('branch defaults third argument to identity function', () => {\n  const Left = () => <div className=\"left\">Left</div>\n  const Right = () => <div className=\"right\">Right</div>\n\n  const BranchedComponent = branch(\n    () => false,\n    () => props => <Left {...props} />\n  )(Right)\n\n  const wrapper = mount(<BranchedComponent />)\n  const right = wrapper.find('.right').text()\n\n  expect(right).toBe('Right')\n})\n\ntest('branch third argument should not cause console error', () => {\n  const error = sinon.stub(console, 'error')\n  const Component = () => <div className=\"right\">Component</div>\n\n  const BranchedComponent = branch(() => false, v => v, v => v)(Component)\n\n  mount(<BranchedComponent />)\n\n  expect(error.called).toBe(false)\n\n  /* eslint-disable */\n  error.restore()\n  /* eslint-enable */\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/componentFromProp-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { componentFromProp } from '../'\n\ntest('componentFromProp creates a component that takes a component as a prop and renders it with the rest of the props', () => {\n  const Container = componentFromProp('component')\n  expect(Container.displayName).toBe('componentFromProp(component)')\n\n  const Component = ({ pass }) =>\n    <div>\n      Pass: {pass}\n    </div>\n\n  const wrapper = mount(<Container component={Component} pass=\"through\" />)\n  const div = wrapper.find('div')\n  expect(div.text()).toBe('Pass: through')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/componentFromStream-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { Observable, Subject } from 'rxjs'\nimport sinon from 'sinon'\nimport rxjsConfig from '../rxjsObservableConfig'\nimport { componentFromStreamWithConfig } from '../componentFromStream'\n\nconst componentFromStream = componentFromStreamWithConfig(rxjsConfig)\n\ntest('componentFromStream creates a component from a prop stream transformation', () => {\n  const Double = componentFromStream(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n  const wrapper = mount(<Double n={112} />)\n  const div = wrapper.find('div')\n  expect(div.text()).toBe('224')\n  wrapper.setProps({ n: 358 })\n  expect(div.text()).toBe('716')\n})\n\ntest('componentFromStream unsubscribes from stream before unmounting', () => {\n  let subscriptions = 0\n  const vdom$ = new Observable(observer => {\n    subscriptions += 1\n    observer.next(<div />)\n    return {\n      unsubscribe() {\n        subscriptions -= 1\n      },\n    }\n  })\n  const Div = componentFromStream(() => vdom$)\n  const wrapper = mount(<Div />)\n  expect(subscriptions).toBe(1)\n  wrapper.unmount()\n  expect(subscriptions).toBe(0)\n})\n\ntest('componentFromStream renders nothing until the stream emits a value', () => {\n  const vdom$ = new Subject()\n  const Div = componentFromStream(() => vdom$.mapTo(<div />))\n  const wrapper = mount(<Div />)\n  expect(wrapper.find('div').length).toBe(0)\n  vdom$.next()\n  wrapper.update()\n  expect(wrapper.find('div').length).toBe(1)\n})\n\ntest('handler multiple observers of props stream', () => {\n  const Other = () => <div />\n  const Div = componentFromStream(props$ =>\n    // Adds three observers to props stream\n    props$.combineLatest(props$, props$, props1 => <Other {...props1} />)\n  )\n\n  const wrapper = mount(<Div data-value={1} />)\n  const div = wrapper.find(Other)\n\n  expect(div.prop('data-value')).toBe(1)\n  wrapper.setProps({ 'data-value': 2 })\n  wrapper.update()\n  const div2 = wrapper.find(Other)\n  expect(div2.prop('data-value')).toBe(2)\n})\n\ntest('complete props stream before unmounting', () => {\n  let counter = 0\n\n  const Div = componentFromStream(props$ => {\n    const first$ = props$.first().do(() => {\n      counter += 1\n    })\n\n    const last$ = props$\n      .last()\n      .do(() => {\n        counter -= 1\n      })\n      .startWith(null)\n\n    return props$.combineLatest(first$, last$, props1 => <div {...props1} />)\n  })\n\n  const wrapper = mount(<Div />)\n\n  expect(counter).toBe(1)\n  expect(wrapper.find('div').length).toBe(1)\n\n  wrapper.unmount()\n  expect(counter).toBe(0)\n})\n\ntest('completed props stream should throw an exception', () => {\n  const Div = componentFromStream(props$ => {\n    const first$ = props$.filter(() => false).first().startWith(null)\n\n    return props$.combineLatest(first$, props1 => <div {...props1} />)\n  })\n\n  const wrapper = mount(<Div />)\n\n  expect(wrapper.find('div').length).toBe(1)\n\n  const error = sinon.stub(console, 'error')\n\n  expect(() => wrapper.unmount()).toThrowError(/no elements in sequence/)\n  expect(error.called).toBe(true)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/componentFromStreamWithConfig-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { Observable } from 'rxjs'\nimport { Stream as MostStream } from 'most'\nimport mostConfig from '../mostObservableConfig'\nimport rxjsConfig from '../rxjsObservableConfig'\nimport { componentFromStreamWithConfig } from '../componentFromStream'\n\ntest('componentFromStreamWithConfig creates a stream with the correct stream type.', () => {\n  const MostComponent = componentFromStreamWithConfig(mostConfig)(props$ => {\n    expect(props$ instanceof MostStream).toBe(true)\n    return props$.map(v =>\n      <div>\n        {String(v)}\n      </div>\n    )\n  })\n\n  mount(<MostComponent />)\n\n  const RXJSComponent = componentFromStreamWithConfig(rxjsConfig)(props$ => {\n    expect(props$ instanceof Observable).toBe(true)\n    return props$.map(v =>\n      <div>\n        {String(v)}\n      </div>\n    )\n  })\n\n  mount(<RXJSComponent />)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/compose-test.js",
    "content": "import { compose } from '../'\n\ntest('compose composes from right to left', () => {\n  const double = x => x * 2\n  const square = x => x * x\n  expect(compose(square)(5)).toBe(25)\n  expect(compose(square, double)(5)).toBe(100)\n  expect(compose(double, square, double)(5)).toBe(200)\n})\n\ntest('compose can be seeded with multiple arguments', () => {\n  const square = x => x * x\n  const add = (x, y) => x + y\n  expect(compose(square, add)(1, 2)).toBe(9)\n})\n\ntest('compose returns the identity function if given no arguments', () => {\n  expect(compose()(1, 2)).toBe(1)\n  expect(compose()(3)).toBe(3)\n  expect(compose()()).toBe(undefined)\n})\n\ntest('compose returns the first function if given only one', () => {\n  const fn = x => x * x\n  expect(compose(fn)(3)).toBe(fn(3))\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/createEventHandler-test.js",
    "content": "import { createEventHandler } from '../'\n\ntest('createEventHandler creates an event handler and a corresponding stream', () => {\n  const result = []\n  const { stream, handler } = createEventHandler()\n  const subscription = stream.subscribe({ next: v => result.push(v) })\n\n  handler(1)\n  handler(2)\n  handler(3)\n\n  subscription.unsubscribe()\n  expect(result).toEqual([1, 2, 3])\n})\n\ntest('handles multiple subscribers', () => {\n  const result1 = []\n  const result2 = []\n  const { handler, stream } = createEventHandler()\n  const subscription1 = stream.subscribe({ next: v => result1.push(v) })\n  const subscription2 = stream.subscribe({ next: v => result2.push(v) })\n\n  handler(1)\n  handler(2)\n  handler(3)\n\n  subscription1.unsubscribe()\n  subscription2.unsubscribe()\n\n  expect(result1).toEqual([1, 2, 3])\n  expect(result2).toEqual([1, 2, 3])\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/createSink-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { createSink, compose, withState, mapProps } from '../'\n\ntest('createSink creates a React component that fires a callback when receiving new props', () => {\n  const spy = sinon.spy()\n  const Sink = createSink(spy)\n  const Counter = compose(\n    withState('counter', 'updateCounter', 0),\n    mapProps(({ updateCounter, ...rest }) => ({\n      increment: () => updateCounter(n => n + 1),\n      ...rest,\n    }))\n  )(Sink)\n\n  mount(\n    <div>\n      <Counter />\n    </div>\n  )\n\n  const { increment } = spy.lastCall.args[0]\n  const getCounter = () => spy.lastCall.args[0].counter\n  expect(getCounter()).toBe(0)\n  increment()\n  expect(getCounter()).toBe(1)\n  increment()\n  expect(getCounter()).toBe(2)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/defaultProps-test.js",
    "content": "import React from 'react'\nimport { shallow } from 'enzyme'\nimport { defaultProps } from '../'\n\ntest('defaultProps passes additional props to base component', () => {\n  const DoReMi = defaultProps({ 'data-so': 'do', 'data-la': 'fa' })('div')\n  expect(DoReMi.displayName).toBe('defaultProps(div)')\n\n  const div = shallow(<DoReMi />).find('div')\n  expect(div.equals(<div data-so=\"do\" data-la=\"fa\" />)).toBe(true)\n})\n\ntest('defaultProps has lower precendence than props from owner', () => {\n  const DoReMi = defaultProps({ 'data-so': 'do', 'data-la': 'fa' })('div')\n  expect(DoReMi.displayName).toBe('defaultProps(div)')\n\n  const div = shallow(<DoReMi data-la=\"ti\" />).find('div')\n  expect(div.equals(<div data-so=\"do\" data-la=\"ti\" />)).toBe(true)\n})\n\ntest('defaultProps overrides undefined owner props', () => {\n  const DoReMi = defaultProps({ 'data-so': 'do', 'data-la': 'fa' })('div')\n  expect(DoReMi.displayName).toBe('defaultProps(div)')\n\n  const div = shallow(<DoReMi data-la={undefined} />).find('div')\n  expect(div.equals(<div data-so=\"do\" data-la=\"fa\" />)).toBe(true)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/fixtures/treeshake-entry.js",
    "content": "import '../../../../../lib/packages/recompose/es/Recompose.js'\n"
  },
  {
    "path": "src/packages/recompose/__tests__/flattenProp-test.js",
    "content": "import React from 'react'\nimport { shallow } from 'enzyme'\nimport { flattenProp } from '../'\n\ntest('flattenProps flattens an object prop and spreads it into the top-level props object', () => {\n  const Counter = flattenProp('data-state')('div')\n  expect(Counter.displayName).toBe('flattenProp(div)')\n\n  const wrapper = shallow(\n    <Counter data-pass=\"through\" data-state={{ 'data-counter': 1 }} />\n  )\n\n  expect(\n    wrapper.equals(\n      <div\n        data-pass=\"through\"\n        data-state={{ 'data-counter': 1 }}\n        data-counter={1}\n      />\n    )\n  ).toBe(true)\n\n  wrapper.setProps({\n    'data-pass': 'through',\n    'data-state': { 'data-state': 1 },\n  })\n  expect(wrapper.equals(<div data-pass=\"through\" data-state={1} />)).toBe(true)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/fromRenderProps-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { fromRenderProps, compose, toRenderProps, defaultProps } from '../'\n\ntest('fromRenderProps passes additional props to base component', () => {\n  const RenderPropsComponent = ({ children }) => children({ i18n: 'zh-TW' })\n  const EnhancedComponent = fromRenderProps(\n    RenderPropsComponent,\n    ({ i18n }) => ({\n      i18n,\n    })\n  )('div')\n  expect(EnhancedComponent.displayName).toBe('fromRenderProps(div)')\n\n  const div = mount(<EnhancedComponent />)\n  expect(div.html()).toBe(`<div i18n=\"zh-TW\"></div>`)\n})\n\ntest('fromRenderProps passes additional props to base component with custom renderPropName', () => {\n  const RenderPropsComponent = ({ render }) => render({ i18n: 'zh-TW' })\n  const EnhancedComponent = fromRenderProps(\n    RenderPropsComponent,\n    ({ i18n }) => ({\n      i18n,\n    }),\n    'render'\n  )('div')\n  expect(EnhancedComponent.displayName).toBe('fromRenderProps(div)')\n\n  const div = mount(<EnhancedComponent />)\n  expect(div.html()).toBe(`<div i18n=\"zh-TW\"></div>`)\n})\n\ntest('fromRenderProps passes additional props to base component with 2 RenderPropsComponents', () => {\n  const RenderPropsComponent1 = ({ children }) => children({ theme: 'dark' })\n  const RenderPropsComponent2 = ({ render }) => render({ i18n: 'zh-TW' })\n  const EnhancedComponent = compose(\n    fromRenderProps(\n      RenderPropsComponent1,\n      ({ theme }) => ({ theme }),\n      'children'\n    ),\n    fromRenderProps(\n      RenderPropsComponent2,\n      ({ i18n }) => ({ locale: i18n }),\n      'render'\n    )\n  )('div')\n  expect(EnhancedComponent.displayName).toBe(\n    'fromRenderProps(fromRenderProps(div))'\n  )\n\n  const div = mount(<EnhancedComponent />)\n  expect(div.html()).toBe(`<div theme=\"dark\" locale=\"zh-TW\"></div>`)\n})\n\ntest('fromRenderProps meet toRenderProps', () => {\n  const RenderPropsComponent = toRenderProps(\n    defaultProps({ foo1: 'bar1', foo2: 'bar2' })\n  )\n\n  const EnhancedComponent = fromRenderProps(\n    RenderPropsComponent,\n    ({ foo1 }) => ({\n      foo: foo1,\n    })\n  )('div')\n  expect(EnhancedComponent.displayName).toBe('fromRenderProps(div)')\n\n  const div = mount(<EnhancedComponent />)\n  expect(div.html()).toBe(`<div foo=\"bar1\"></div>`)\n})\n\ntest('fromRenderProps with multiple arguments #693', () => {\n  const RenderPropsComponent = ({ children }) =>\n    children({ theme: 'dark' }, { data: 'data' })\n  const EnhancedComponent = compose(\n    fromRenderProps(\n      RenderPropsComponent,\n      ({ theme }, { data }) => ({ theme, data }),\n      'children'\n    )\n  )('div')\n  expect(EnhancedComponent.displayName).toBe('fromRenderProps(div)')\n\n  const div = mount(<EnhancedComponent />)\n  expect(div.html()).toBe(`<div theme=\"dark\" data=\"data\"></div>`)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/getContext-test.js",
    "content": "// Tests for getContext() are covered by withContext-test.js\n// This is just a dummy test so Ava doesn't complain\ntest('getContext works', () => expect(true).toBe(true))\n"
  },
  {
    "path": "src/packages/recompose/__tests__/getDisplayName-test.js",
    "content": "import React from 'react'\nimport { getDisplayName } from '../'\n\ntest('getDisplayName gets the display name of a React component', () => {\n  class SomeComponent extends React.Component {\n    render() {\n      return <div />\n    }\n  }\n\n  class SomeOtherComponent extends React.Component {\n    static displayName = 'CustomDisplayName'\n    render() {\n      return <div />\n    }\n  }\n\n  function YetAnotherComponent() {\n    return <div />\n  }\n\n  expect(getDisplayName(SomeComponent)).toBe('SomeComponent')\n  expect(getDisplayName(SomeOtherComponent)).toBe('CustomDisplayName')\n  expect(getDisplayName(YetAnotherComponent)).toBe('YetAnotherComponent')\n  expect(getDisplayName(() => <div />)).toBe('Component')\n  expect(getDisplayName('div')).toBe('div')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/hoistStatics-test.js",
    "content": "import React, { createFactory } from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { hoistStatics, mapProps } from '../'\n\ntest('copies non-React static properties from base component to new component', () => {\n  const BaseComponent = sinon.spy(() => null)\n  BaseComponent.foo = () => {}\n\n  const EnhancedComponent = hoistStatics(\n    mapProps(props => ({ n: props.n * 5 }))\n  )(BaseComponent)\n\n  expect(EnhancedComponent.foo).toBe(BaseComponent.foo)\n\n  mount(<EnhancedComponent n={3} />)\n  expect(BaseComponent.firstCall.args[0].n).toBe(15)\n})\n\ntest('does not copy blacklisted static properties to new component ', () => {\n  const BaseComponent = sinon.spy(() => null)\n  BaseComponent.foo = () => {}\n  BaseComponent.bar = () => {}\n\n  const EnhancedComponent = hoistStatics(\n    comp => createFactory(comp),\n    { bar: true } // Blacklist\n  )(BaseComponent)\n\n  expect(EnhancedComponent.foo).toBe(BaseComponent.foo)\n  expect(EnhancedComponent.bar).toBe(undefined)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/isClassComponent-test.js",
    "content": "import React, { Component } from 'react'\nimport createReactClass from 'create-react-class'\nimport isClassComponent from '../isClassComponent'\n\ntest('isClassComponent returns false for functions', () => {\n  const Foo = () => <div />\n\n  expect(isClassComponent(Foo)).toBe(false)\n})\n\ntest('isClassComponent returns true for React component classes', () => {\n  class Foo extends Component {\n    render() {\n      return <div />\n    }\n  }\n\n  /* eslint-disable react/prefer-es6-class */\n  const Bar = createReactClass({\n    render() {\n      return <div />\n    },\n  })\n  /* eslint-enable react/prefer-es6-class */\n\n  expect(isClassComponent(Foo)).toBe(true)\n  expect(isClassComponent(Bar)).toBe(true)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/lifecycle-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { lifecycle } from '../'\n\ntest('lifecycle is a higher-order component version of React.Component', () => {\n  const enhance = lifecycle({\n    componentWillMount() {\n      this.setState({ 'data-bar': 'baz' })\n    },\n  })\n  const Div = enhance('div')\n  expect(Div.displayName).toBe('lifecycle(div)')\n\n  const div = mount(<Div data-foo=\"bar\" />).find('div')\n  expect(div.prop('data-foo')).toBe('bar')\n  expect(div.prop('data-bar')).toBe('baz')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/mapProps-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { mapProps, withState, compose } from '../'\n\ntest('mapProps maps owner props to child props', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const StringConcat = compose(\n    withState('strings', 'updateStrings', ['do', 're', 'mi']),\n    mapProps(({ strings, ...rest }) => ({\n      ...rest,\n      string: strings.join(''),\n    }))\n  )(component)\n\n  expect(StringConcat.displayName).toBe('withState(mapProps(component))')\n\n  mount(<StringConcat />)\n  const { updateStrings } = component.firstCall.args[0]\n  updateStrings(strings => [...strings, 'fa'])\n\n  expect(component.firstCall.args[0].string).toBe('doremi')\n  expect(component.secondCall.args[0].string).toBe('doremifa')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/mapPropsStream-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport setObservableConfig from '../setObservableConfig'\nimport rxjs4Config from '../rxjs4ObservableConfig'\nimport { mapPropsStream } from '../'\n\nsetObservableConfig(rxjs4Config)\n\n// Most of mapPropsStream's functionality is covered by componentFromStream\ntest('mapPropsStream creates a higher-order component from a stream', () => {\n  const Double = mapPropsStream(props$ =>\n    props$.map(({ n }) => ({ children: n * 2 }))\n  )('div')\n  const wrapper = mount(<Double n={112} />)\n  const div = wrapper.find('div')\n  expect(div.text()).toBe('224')\n  wrapper.setProps({ n: 358 })\n  expect(div.text()).toBe('716')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/mapPropsStreamWithConfig-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { Stream as MostStream } from 'most'\nimport { Observable } from 'rxjs'\nimport { mapPropsStreamWithConfig } from '../'\nimport rxConfig from '../rxjsObservableConfig'\nimport mostConfig from '../mostObservableConfig'\n\n// Most of mapPropsStreamConfig's functionality is covered by componentFromStream\ntest('mapPropsStreamWithConfig creates a higher-order component from a stream and a observable config', () => {\n  const Double = mapPropsStreamWithConfig(rxConfig)(props$ =>\n    props$.map(({ n }) => ({ children: n * 2 }))\n  )('div')\n  const wrapper = mount(<Double n={112} />)\n  const div = wrapper.find('div')\n  expect(div.text()).toBe('224')\n  wrapper.setProps({ n: 358 })\n  expect(div.text()).toBe('716')\n})\n\ntest('mapPropsStreamWithConfig creates a stream with the correct config', () => {\n  const MostComponent = mapPropsStreamWithConfig(mostConfig)(props$ => {\n    expect(props$ instanceof MostStream).toBe(true)\n    return props$.map(v => v)\n  })('div')\n\n  mount(<MostComponent />)\n\n  const RXJSComponent = mapPropsStreamWithConfig(rxConfig)(props$ => {\n    expect(props$ instanceof Observable).toBe(true)\n    return props$.map(v => v)\n  })('div')\n\n  mount(<RXJSComponent />)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/nest-test.js",
    "content": "import React from 'react'\nimport { shallow } from 'enzyme'\nimport { nest, setDisplayName, toClass } from '../'\n\ntest('nest nests components from outer to inner', () => {\n  const A = setDisplayName('A')(toClass('div'))\n  const B = setDisplayName('B')(toClass('div'))\n  const C = setDisplayName('C')(toClass('div'))\n\n  const Nest = nest(A, B, C)\n\n  expect(Nest.displayName).toBe('nest(A, B, C)')\n\n  const wrapper = shallow(<Nest pass=\"through\">Child</Nest>)\n\n  expect(\n    wrapper.equals(\n      <A pass=\"through\">\n        <B pass=\"through\">\n          <C pass=\"through\">Child</C>\n        </B>\n      </A>\n    )\n  ).toBe(true)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/onlyUpdateForKeys-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { onlyUpdateForKeys, compose, withState } from '../'\n\ntest('onlyUpdateForKeys implements shouldComponentUpdate()', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = compose(\n    withState('counter', 'updateCounter', 0),\n    withState('foobar', 'updateFoobar', 'foobar'),\n    onlyUpdateForKeys(['counter'])\n  )(component)\n\n  expect(Counter.displayName).toBe(\n    'withState(withState(onlyUpdateForKeys(component)))'\n  )\n\n  mount(<Counter />)\n  const { updateCounter, updateFoobar } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n  expect(component.lastCall.args[0].foobar).toBe('foobar')\n\n  // Does not update\n  updateFoobar('barbaz')\n  expect(component.calledOnce).toBe(true)\n\n  updateCounter(42)\n  expect(component.calledTwice).toBe(true)\n  expect(component.lastCall.args[0].counter).toBe(42)\n  expect(component.lastCall.args[0].foobar).toBe('barbaz')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/onlyUpdateForPropTypes-test.js",
    "content": "import React from 'react'\nimport PropTypes from 'prop-types'\nimport sinon from 'sinon'\nimport { mount, shallow } from 'enzyme'\nimport { onlyUpdateForPropTypes, compose, withState, setPropTypes } from '../'\n\ntest('onlyUpdateForPropTypes only updates for props specified in propTypes', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = compose(\n    withState('counter', 'updateCounter', 0),\n    withState('foobar', 'updateFoobar', 'foobar'),\n    onlyUpdateForPropTypes,\n    setPropTypes({ counter: PropTypes.number })\n  )(component)\n\n  expect(Counter.displayName).toBe(\n    'withState(withState(onlyUpdateForPropTypes(component)))'\n  )\n\n  mount(<Counter />)\n  const { updateCounter, updateFoobar } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n  expect(component.lastCall.args[0].foobar).toBe('foobar')\n\n  // Does not update\n  updateFoobar('barbaz')\n  expect(component.calledOnce).toBe(true)\n\n  updateCounter(42)\n  expect(component.calledTwice).toBe(true)\n  expect(component.lastCall.args[0].counter).toBe(42)\n  expect(component.lastCall.args[0].foobar).toBe('barbaz')\n})\n\ntest('onlyUpdateForPropTypes warns if BaseComponent does not have any propTypes', () => {\n  const error = sinon.stub(console, 'error')\n  const ShouldWarn = onlyUpdateForPropTypes('div')\n\n  shallow(<ShouldWarn />)\n\n  expect(error.firstCall.args[0]).toBe(\n    'A component without any `propTypes` was passed to ' +\n      '`onlyUpdateForPropTypes()`. Check the implementation of the component ' +\n      'with display name \"div\".'\n  )\n\n  /* eslint-disable */\n  console.error.restore()\n  /* eslint-enable */\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/pure-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { pure, compose, withState } from '../'\nimport { countRenders } from './utils'\n\ntest('pure implements shouldComponentUpdate() using shallowEqual()', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const initialTodos = ['eat', 'drink', 'sleep']\n  const Todos = compose(\n    withState('todos', 'updateTodos', initialTodos),\n    pure,\n    countRenders\n  )(component)\n\n  expect(Todos.displayName).toBe('withState(pure(countRenders(component)))')\n\n  mount(<Todos />)\n  const { updateTodos } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].todos).toBe(initialTodos)\n  expect(component.lastCall.args[0].renderCount).toBe(1)\n\n  // Does not re-render\n  updateTodos(initialTodos)\n  expect(component.calledOnce).toBe(true)\n\n  updateTodos(todos => todos.slice(0, -1))\n  expect(component.calledTwice).toBe(true)\n  expect(component.lastCall.args[0].todos).toEqual(['eat', 'drink'])\n  expect(component.lastCall.args[0].renderCount).toBe(2)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/renameProp-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { withProps, renameProp, compose } from '../'\n\ntest('renameProp renames a single prop', () => {\n  const StringConcat = compose(\n    withProps({ 'data-so': 123, 'data-la': 456 }),\n    renameProp('data-so', 'data-do')\n  )('div')\n\n  expect(StringConcat.displayName).toBe('withProps(renameProp(div))')\n\n  const div = mount(<StringConcat />).find('div')\n  expect(div.props()).toEqual({ 'data-do': 123, 'data-la': 456 })\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/renameProps-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { withProps, renameProps, compose } from '../'\n\ntest('renameProps renames props', () => {\n  const StringConcat = compose(\n    withProps({ 'data-so': 123, 'data-la': 456 }),\n    renameProps({ 'data-so': 'data-do', 'data-la': 'data-fa' })\n  )('div')\n\n  expect(StringConcat.displayName).toBe('withProps(renameProps(div))')\n\n  const div = mount(<StringConcat />).find('div')\n\n  expect(div.prop('data-do')).toBe(123)\n  expect(div.prop('data-fa')).toBe(456)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/renderComponent-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { renderComponent, withState, compose, branch } from '../'\n\ntest('renderComponent always renders the given component', () => {\n  const componentA = sinon.spy(() => null)\n  const componentB = sinon.spy(() => null)\n\n  const Foobar = compose(\n    withState('flip', 'updateFlip', false),\n    branch(\n      props => props.flip,\n      renderComponent(componentA),\n      renderComponent(componentB)\n    )\n  )(null)\n\n  mount(<Foobar />)\n  const { updateFlip } = componentB.firstCall.args[0]\n\n  expect(componentB.calledOnce).toBe(true)\n  expect(componentA.notCalled).toBe(true)\n\n  updateFlip(true)\n  expect(componentB.calledOnce).toBe(true)\n  expect(componentA.calledOnce).toBe(true)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/renderNothing-test.js",
    "content": "import React from 'react'\nimport { shallow } from 'enzyme'\nimport { renderNothing } from '../'\n\ntest('renderNothing returns a component that renders null', () => {\n  const Nothing = renderNothing('div')\n  const wrapper = shallow(<Nothing />)\n\n  const Parent = () => <Nothing />\n  const parentWrapper = shallow(<Parent />)\n\n  expect(wrapper.type()).toBe(null)\n  expect(parentWrapper.text()).toBe('<Nothing />')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/setDisplayName-test.js",
    "content": "import React from 'react'\nimport { setDisplayName } from '../'\n\ntest('setDisplayName sets a static property on the base component', () => {\n  const BaseComponent = () => <div />\n  const NewComponent = setDisplayName('Foo')(BaseComponent)\n  expect(NewComponent.displayName).toBe('Foo')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/setObservableConfig-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport rxjs5Config from '../rxjsObservableConfig'\nimport rxjs4Config from '../rxjs4ObservableConfig'\nimport mostConfig from '../mostObservableConfig'\nimport xstreamConfig from '../xstreamObservableConfig'\nimport baconConfig from '../baconObservableConfig'\nimport kefirConfig from '../kefirObservableConfig'\nimport flydConfig from '../flydObservableConfig'\nimport setObservableConfig from '../setObservableConfig'\nimport componentFromStream from '../componentFromStream'\n\nconst testTransform = transform => {\n  const Double = componentFromStream(transform)\n  const wrapper = mount(<Double n={112} />)\n  const div = wrapper.find('div')\n  expect(div.text()).toBe('224')\n  wrapper.setProps({ n: 358 })\n  expect(div.text()).toBe('716')\n}\n\ntest('works with RxJS 5', () => {\n  setObservableConfig(rxjs5Config)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n\ntest('works with RxJS 4', () => {\n  setObservableConfig(rxjs4Config)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n\ntest('works with most', () => {\n  setObservableConfig(mostConfig)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n\ntest('works with xstream', () => {\n  setObservableConfig(xstreamConfig)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n\ntest('works with bacon', () => {\n  setObservableConfig(baconConfig)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n\ntest('works with kefir', () => {\n  setObservableConfig(kefirConfig)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n\ntest('works with flyd', () => {\n  setObservableConfig(flydConfig)\n  testTransform(props$ =>\n    props$.map(({ n }) =>\n      <div>\n        {n * 2}\n      </div>\n    )\n  )\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/setPropTypes-test.js",
    "content": "import React from 'react'\nimport PropTypes from 'prop-types'\nimport { setPropTypes } from '../'\n\ntest('setPropTypes sets a static property on the base component', () => {\n  const BaseComponent = () => <div />\n  const NewComponent = setPropTypes({ foo: PropTypes.object })(BaseComponent)\n\n  expect(NewComponent.propTypes).toEqual({\n    foo: PropTypes.object,\n  })\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/setStatic-test.js",
    "content": "import React from 'react'\nimport PropTypes from 'prop-types'\nimport { setStatic } from '../'\n\ntest('setStatic sets a static property on the base component', () => {\n  const BaseComponent = () => <div />\n  const NewComponent = setStatic('propTypes', { foo: PropTypes.object })(\n    BaseComponent\n  )\n\n  expect(NewComponent.propTypes).toEqual({\n    foo: PropTypes.object,\n  })\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/shallowEqual-test.js",
    "content": "import { shallowEqual } from '../'\n\n// Adapted from https://github.com/rackt/react-redux/blob/master/test/utils/shallowEqual.spec.js\ntest('shallowEqual returns true if arguments are equal, without comparing properties', () => {\n  const throwOnAccess = {\n    get foo() {\n      throw new Error('Property was accessed')\n    },\n  }\n  expect(shallowEqual(throwOnAccess, throwOnAccess)).toBe(true)\n})\n\ntest('shallowEqual returns true if arguments fields are equal', () => {\n  expect(\n    shallowEqual({ a: 1, b: 2, c: undefined }, { a: 1, b: 2, c: undefined })\n  ).toBe(true)\n\n  expect(shallowEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2, c: 3 })).toBe(true)\n\n  const o = {}\n  expect(shallowEqual({ a: 1, b: 2, c: o }, { a: 1, b: 2, c: o })).toBe(true)\n})\n\ntest('shallowEqual returns false if either argument is null or undefined', () => {\n  expect(shallowEqual(null, { a: 1, b: 2 })).toBe(false)\n  expect(shallowEqual({ a: 1, b: 2 }, null)).toBe(false)\n})\n\ntest('shallowEqual returns false if first argument has too many keys', () => {\n  expect(shallowEqual({ a: 1, b: 2, c: 3 }, { a: 1, b: 2 })).toBe(false)\n})\n\ntest('shallowEqual returns false if second argument has too many keys', () => {\n  expect(shallowEqual({ a: 1, b: 2 }, { a: 1, b: 2, c: 3 })).toBe(false)\n})\n\ntest('shallowEqual returns false if arguments have different keys', () => {\n  expect(\n    shallowEqual({ a: 1, b: 2, c: undefined }, { a: 1, bb: 2, c: undefined })\n  ).toBe(false)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/shouldUpdate-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { shouldUpdate, compose, withState } from '../'\nimport { countRenders } from './utils'\n\ntest('shouldUpdate implements shouldComponentUpdate', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const initialTodos = ['eat', 'drink', 'sleep']\n  const Todos = compose(\n    withState('todos', 'updateTodos', initialTodos),\n    shouldUpdate((props, nextProps) => props.todos !== nextProps.todos),\n    countRenders\n  )(component)\n\n  expect(Todos.displayName).toBe(\n    'withState(shouldUpdate(countRenders(component)))'\n  )\n\n  mount(<Todos />)\n  const { updateTodos } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].todos).toBe(initialTodos)\n  expect(component.lastCall.args[0].renderCount).toBe(1)\n\n  // Does not re-render\n  updateTodos(initialTodos)\n  expect(component.calledOnce).toBe(true)\n\n  updateTodos(todos => todos.slice(0, -1))\n  expect(component.calledTwice).toBe(true)\n  expect(component.lastCall.args[0].todos).toEqual(['eat', 'drink'])\n  expect(component.lastCall.args[0].renderCount).toBe(2)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/toClass-test.js",
    "content": "import React from 'react'\nimport PropTypes from 'prop-types'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { toClass, withContext, compose } from '../'\n\ntest('toClass returns the base component if it is already a class', () => {\n  class BaseComponent extends React.Component {\n    render() {\n      return <div />\n    }\n  }\n\n  const TestComponent = toClass(BaseComponent)\n  expect(TestComponent).toBe(BaseComponent)\n})\n\ntest('toClass copies propTypes, displayName, contextTypes and defaultProps from base component', () => {\n  const StatelessComponent = () => <div />\n\n  StatelessComponent.displayName = 'Stateless'\n  StatelessComponent.propTypes = { foo: PropTypes.string }\n  StatelessComponent.contextTypes = { bar: PropTypes.object }\n  StatelessComponent.defaultProps = { foo: 'bar', fizz: 'buzz' }\n\n  const TestComponent = toClass(StatelessComponent)\n\n  expect(TestComponent.displayName).toBe('Stateless')\n  expect(TestComponent.propTypes).toEqual({ foo: PropTypes.string })\n  expect(TestComponent.contextTypes).toEqual({ bar: PropTypes.object })\n  expect(TestComponent.defaultProps).toEqual({ foo: 'bar', fizz: 'buzz' })\n})\n\ntest('toClass passes defaultProps correctly', () => {\n  const StatelessComponent = sinon.spy(() => null)\n\n  StatelessComponent.displayName = 'Stateless'\n  StatelessComponent.propTypes = { foo: PropTypes.string }\n  StatelessComponent.contextTypes = { bar: PropTypes.object }\n  StatelessComponent.defaultProps = { foo: 'bar', fizz: 'buzz' }\n\n  const TestComponent = toClass(StatelessComponent)\n\n  mount(<TestComponent />)\n  expect(StatelessComponent.lastCall.args[0].foo).toBe('bar')\n  expect(StatelessComponent.lastCall.args[0].fizz).toBe('buzz')\n})\n\ntest('toClass passes context and props correctly', () => {\n  const store = {}\n\n  class Provider extends React.Component {\n    static propTypes = {\n      children: PropTypes.node,\n    }\n\n    render() {\n      return this.props.children\n    }\n  }\n\n  Provider = compose(\n    withContext({ store: PropTypes.object }, props => ({ store: props.store }))\n  )(Provider)\n\n  const StatelessComponent = (props, context) =>\n    <div data-props={props} data-context={context} />\n\n  StatelessComponent.contextTypes = { store: PropTypes.object }\n\n  const TestComponent = toClass(StatelessComponent)\n\n  const div = mount(\n    <Provider store={store}>\n      <TestComponent fizz=\"fizzbuzz\" />\n    </Provider>\n  ).find('div')\n\n  expect(div.prop('data-props').fizz).toBe('fizzbuzz')\n  expect(div.prop('data-context').store).toBe(store)\n})\n\ntest('toClass works with strings (DOM components)', () => {\n  const Div = toClass('div')\n  const div = mount(<Div>Hello</Div>)\n  expect(div.html()).toBe('<div>Hello</div>')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/toRenderProps-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport { toRenderProps, defaultProps } from '../'\n\ntest('toRenderProps creates a component from defaultProps HOC', () => {\n  const enhance = defaultProps({ foo: 'bar' })\n  const Enhanced = toRenderProps(enhance)\n\n  expect(Enhanced.displayName).toBe('defaultProps(RenderPropsComponent)')\n\n  const h1 = mount(\n    <Enhanced>\n      {({ foo }) =>\n        <h1>\n          {foo}\n        </h1>}\n    </Enhanced>\n  ).find('h1')\n\n  expect(h1.html()).toBe(`<h1>bar</h1>`)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_branch.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport {\n  compose,\n  withProps,\n  branch,\n  renderNothing,\n  renderComponent,\n  onlyUpdateForKeys,\n} from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  branch(({ eA }) => eA === 1, renderNothing),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst enhacerLoading: HOC<*, EnhancedCompProps> = compose(\n  branch(({ eA }) => eA === 1, renderComponent(p => <div>Loading</div>)),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  }))\n)\n\n// can work with onlyUpdateForKeys\nconst enhacerUpdating: HOC<*, EnhancedCompProps> = compose(\n  branch(({ eA }) => eA === 1, onlyUpdateForKeys(['eA'])),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  }))\n)\n\n// can infer withProps type\nconst enhacerWithProps: HOC<*, EnhancedCompProps> = compose(\n  branch(({ eA }) => eA === 1, withProps(props => ({ x: 1 }))),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  }))\n)\n\n// can infer compose types\nconst enhacerWithCompose: HOC<*, EnhancedCompProps> = compose(\n  branch(\n    ({ eA }) => eA === 1,\n    compose(\n      withProps(props => {\n        // $ExpectError eA nor any nor string\n        ;(props.eA: string)\n\n        return { x: 1 }\n      }),\n      withProps(props => ({ y: 2 }))\n    )\n  ),\n  withProps(props => ({\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n    // $ExpectError x nor any nor string\n    xErr: (props.x: string),\n    // $ExpectError y nor any nor string\n    yErr: (props.y: string),\n  }))\n)\n\nconst enhacerLeftRight: HOC<*, EnhancedCompProps> = compose(\n  branch(\n    ({ eA }) => eA === 1,\n    renderComponent(p => <div>A</div>),\n    renderComponent(p => <div>B</div>)\n  ),\n  withProps(props => ({\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n    // $ExpectError x nor any nor string\n    xErr: (props.x: string),\n    // $ExpectError y nor any nor string\n    yErr: (props.y: string),\n  }))\n)\n\n/*\nWrong types of left right, this will cause an infinite recursion\n\nconst enhacerLeftRight2: HOC<*, EnhancedCompProps> = compose(\n  branch(\n    ({ eA }) => eA === 1,\n    renderComponent(p => <div>A</div>),\n    withProps(props => ({ y: 2 }))\n  )\n);\n*/\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_classBasedEnhancer.js",
    "content": "/* @flow */\nimport * as React from 'react'\nimport { compose, withProps } from '../..'\nimport type { HOC } from '../..'\n\n// Example of very dirty written fetcher enhancer\nfunction fetcher<Response: {}, Base: {}>(\n  dest: string,\n  nullRespType: ?Response\n): HOC<{ ...$Exact<Base>, data?: Response }, Base> {\n  return BaseComponent =>\n    class Fetcher extends React.Component<Base, { data?: Response }> {\n      state = { data: undefined }\n      componentDidMount() {\n        fetch(dest)\n          .then(r => r.json())\n          .then((data: Response) => this.setState({ data }))\n      }\n      render() {\n        return <BaseComponent {...this.props} {...this.state} />\n      }\n    }\n}\n// Enhanced Component props type\ntype EnhancedCompProps = { b: number }\n// response type\ntype FetchResponseType = { hello: string, world: number }\n\n// Now you can use it, let's check\nconst enhancer: HOC<*, EnhancedCompProps> = compose(\n  // pass response type via typed null\n  fetcher('http://endpoint.ep', (null: ?FetchResponseType)),\n  // see here fully typed data\n  withProps(({ data }) => {\n    if (data !== undefined) {\n      return {\n        h: (data.hello: string),\n        // $ExpectError\n        hE: (data.hello: number),\n      }\n    }\n\n    return {}\n  })\n)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_componentFromStream.js",
    "content": "// @flow\nimport React from 'react'\nimport { componentFromStream } from '../..'\n\n// $ExpectError\ncomponentFromStream(1)\n\n// $ExpectError\nconst result1: number = componentFromStream(() => React.createElement('div'))\n\ncomponentFromStream(a => a)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_createEventHandler.js",
    "content": "// @flow\nimport React from 'react'\nimport { createEventHandler } from '../..'\n\n// $ExpectError\ncreateEventHandler(1)\n\n// $ExpectError\nconst result1: number = createEventHandler()\n\n// $ExpectError\nconst { stream1, handler1 } = createEventHandler()\n\nconst { stream, handler } = createEventHandler()\n\nhandler()\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_defaultProps.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, defaultProps } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ hello, eA }) =>\n  <div>\n    {(hello: string)}\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n    {\n      // $ExpectError hello nor any nor number\n      (hello: number)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  defaultProps({\n    hello: 'world',\n  }),\n  withProps(props => ({\n    hello: (props.hello: string),\n    eA: (props.eA: number),\n    // $ExpectError hello nor any nor number\n    helloErr: (props.hello: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_fromRenderProps.js",
    "content": "/* @flow */\nimport React from 'react'\nimport { compose, fromRenderProps } from '../..'\n\nimport type { HOC } from '../..'\n\nconst RenderPropsComponent1 = ({ children }) => children({ theme: 'dark' })\nconst RenderPropsComponent2 = ({ render }) => render({ i18n: 'zh-TW' })\nconst RenderPropsComponent3 = ({ children }) =>\n  children({ theme: 'dark' }, { data: 'data' })\n\ntype EnhancedCompProps = {||}\n\nconst Comp = ({ i18n, theme, data }) =>\n  <div>\n    {i18n}\n    {theme}\n    {data}\n    {\n      // $ExpectError\n      (i18n: number)\n    }\n    {\n      // $ExpectError\n      (theme: number)\n    }\n    {\n      // $ExpectError\n      (data: number)\n    }\n  </div>\n\nconst enhancer: HOC<*, EnhancedCompProps> = compose(\n  fromRenderProps(RenderPropsComponent1, props => ({\n    theme: props.theme,\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  })),\n  fromRenderProps(\n    RenderPropsComponent2,\n    props => ({\n      i18n: props.i18n,\n      // $ExpectError property not found\n      err: props.iMNotExists,\n    }),\n    'render'\n  ),\n  fromRenderProps(RenderPropsComponent3, (props, data) => ({\n    theme: props.theme,\n    data: data.data,\n    // $ExpectError property not found\n    err: data.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhancer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_functionalEnhancer.js",
    "content": "/* @flow */\n\nimport * as React from 'react'\nimport { compose, withProps } from '../..'\nimport type { HOC } from '../..'\n\nfunction mapProps<BaseProps: {}, EnhancedProps>(\n  mapperFn: EnhancedProps => BaseProps\n): (React.ComponentType<BaseProps>) => React.ComponentType<EnhancedProps> {\n  return Component => props => <Component {...mapperFn(props)} />\n}\n\ntype EnhancedProps = { hello: string }\n\nconst baseComponent = ({ hello, len }) =>\n  <div>\n    {(hello: string)}\n\n    {\n      // $ExpectError\n      (hello: number)\n    }\n\n    {(len: number)}\n\n    {\n      // $ExpectError\n      (len: string)\n    }\n  </div>\n\nconst enhancer: HOC<*, EnhancedProps> = compose(\n  mapProps(({ hello }) => ({\n    hello: `${hello} world`,\n    len: hello.length,\n  })),\n  withProps(props => ({\n    helloAndLen: `${props.hello} ${props.len}`,\n    // $ExpectError\n    lE: (props.len: string),\n  }))\n)\n\nenhancer(baseComponent)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_getContext.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, getContext } from '../..'\n// import PropTypes from 'prop-types'\nimport type { HOC } from '../..'\n\nconst PropTypes = {\n  number: () => {},\n  string: () => {},\n}\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  getContext({\n    // as an idea is to use a hack like this\n    // so we can test all such types\n    color: ((PropTypes.string: any): string),\n    num: ((PropTypes.number: any): number),\n  }),\n  withProps(props => ({\n    eA: (props.eA: number),\n    color: (props.color: string),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n    // $ExpectError color nor any nor number\n    colorErr: (props.color: number),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_mapProps.js",
    "content": "/* globals */\n/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport { compose, mapProps, withProps } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ a }) =>\n  <div>\n    {(a: string)}\n    {\n      // $ExpectError\n      (a: number)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  mapProps(p => ({\n    a: '1',\n  })),\n  // If you need to to detect erros after a mapProps HOC\n  // you need to explicitly set Types for all HOCs below\n  // seems like this https://github.com/facebook/flow/issues/4342 issue\n  withProps(props => ({\n    a: (props.a: string),\n    // $ExpectError but not\n    e: Math.round(props.a),\n  }))\n)\n\nenhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_mapPropsStream.js",
    "content": "/* globals */\n/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\n// import { Observable } from 'rxjs'\nimport { compose, mapProps, withProps, mapPropsStream } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Observable = {\n  of: (a: Object) => Object,\n}\n\nconst Comp = ({ a }) =>\n  <div>\n    {(a: string)}\n    {\n      // $ExpectError\n      (a: number)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  (mapPropsStream((props$: Observable<EnhancedCompProps>) =>\n    Observable.of({ a: 1, b: '1' })\n  ): HOC<{ a: string, b: string }, *>),\n  // If you need to to detect erros after a mapPropsStream HOC (the same for mapProps and some others)\n  // you need to explicitly set Types for all HOCs below\n  // but because of this https://github.com/facebook/flow/issues/4342\n  withProps(props => ({\n    a: (props.a: string),\n    // $ExpectError but not\n    e: Math.round(props.a),\n  }))\n)\n\nenhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_onlyUpdateForKeys.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, onlyUpdateForKeys } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  onlyUpdateForKeys(['eA']),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst enhacerErr: HOC<*, EnhancedCompProps> = compose(\n  // $ExpectError property not found\n  onlyUpdateForKeys(['eB'])\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_onlyUpdateForPropTypes.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, onlyUpdateForPropTypes } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  onlyUpdateForPropTypes,\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_pure.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, pure } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  pure,\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_shouldUpdate.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, shouldUpdate } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  shouldUpdate((props, nextProps) => {\n    // $ExpectError eA nor any nor string\n    ;(props.eA: string)\n    // $ExpectError eA nor any nor string\n    ;(nextProps.eA: string)\n\n    return props.eA === nextProps.eA\n  }),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst enhacerErr: HOC<*, EnhancedCompProps> = compose(\n  shouldUpdate(() => {\n    // $ExpectError must be boolean\n    return 1\n  })\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_statics.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport {\n  compose,\n  withProps,\n  setStatic,\n  setPropTypes,\n  setDisplayName,\n} from '../..'\n// import PropTypes from 'prop-types'\nimport type { HOC } from '../..'\n\nconst PropTypes = {\n  string: () => {},\n}\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  setStatic('hello', 'world'),\n  setPropTypes({\n    a: PropTypes.string,\n  }),\n  setDisplayName('hello'),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\n// $ExpectError name is string\nsetDisplayName(1)\n\n// $ExpectError propTypes is object\nsetPropTypes(1)\n\n// $ExpectError name is string\nsetStatic(1, 'world')\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_toClass.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, toClass } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  toClass,\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_toRenderProps.js",
    "content": "/* @flow */\n\nimport * as React from 'react'\nimport { compose, withProps, toRenderProps, withHandlers } from '../..'\nimport type { HOC } from '../..'\n\nconst enhance: HOC<*, {| +x: number |}> = compose(\n  withProps(props => ({\n    y: props.x + 1,\n  })),\n  withHandlers({\n    sayHello: ({ y }) => () => {\n      console.log('Hello', y)\n    },\n  })\n)\n\nconst WithProps = toRenderProps(enhance)\n\nconst Comp = () =>\n  <WithProps x={1}>\n    {({ y, sayHello }) =>\n      <div onClick={() => sayHello()}>\n        {y}\n      </div>}\n  </WithProps>\n\nconst Comp2 = () =>\n  // $ExpectError\n  <WithProps x={'1'}>\n    {({ y, sayHello }) =>\n      <div onClick={() => sayHello()}>\n        {y}\n      </div>}\n  </WithProps>\n\n// $ExpectError cannot create `WithProps` element because property `children` is missing in props\nconst Comp3 = () => <WithProps x={1} />\n\nconst Comp4 = () =>\n  <WithProps x={1}>\n    {({ y, sayHello }) =>\n      <div\n        onClick={() => {\n          ;(sayHello: () => void)\n\n          // $ExpectError\n          ;(sayHello: number)\n          sayHello()\n        }}\n      >\n        {(y: number)}\n        {\n          // $ExpectError\n          (y: string)\n        }\n      </div>}\n  </WithProps>\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_utils.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\n\nimport React from 'react'\nimport { compose, withProps, hoistStatics } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { a: number }\n\nconst A = ({ a, b }) =>\n  <div>\n    {a}\n    {(b: string)}\n    {\n      // $ExpectError\n      (a: string)\n    }\n    {\n      // $ExpectError\n      (b: number)\n    }\n  </div>\n\nA.displayName = 'HELLO WORLD'\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  withProps(({ a }) => ({\n    hello: a,\n    b: `${a}`,\n  }))\n)\n\nhoistStatics(enhacer)(A)\n\n// I see no reason to test other utils, please add if you think otherwise\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_voodoo.js",
    "content": "/* globals $Exact, $PropertyType */\n/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport {\n  compose,\n  withProps,\n  flattenProp,\n  renameProp,\n  renameProps,\n  withState,\n} from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = {\n  eA: number,\n  obj: { objPropA: string, objPropB: number },\n}\n\nconst Comp = ({ eA, objPropA }) =>\n  <div>\n    {(eA: number)}\n    {(objPropA: string)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n    {\n      // $ExpectError eA nor any nor string\n      (objPropA: number)\n    }\n  </div>\n\nconst Comp2 = ({ eA, objPropA }) =>\n  <div>\n    {/* hack to preview types */}\n    {/* :: eA, objPropA */}\n  </div>\n\nconst flattenEnhacer: HOC<*, EnhancedCompProps> = compose(\n  (flattenProp('obj'): HOC<\n    {\n      ...$Exact<EnhancedCompProps>,\n      ...$Exact<$PropertyType<EnhancedCompProps, 'obj'>>,\n    },\n    EnhancedCompProps\n  >),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError\n    eB: (props.eA: string),\n  }))\n)\n\nconst EnhancedComponent = flattenEnhacer(Comp)\nconst EnhancedComponent2 = flattenEnhacer(Comp2)\n\n// renameEnhacer voodoo (you don't need it, use withProps instead)\nconst RenameComp = ({ eA, objNew, obj }) =>\n  <div>\n    {(eA: number)}\n\n    {\n      // objNew has a type we need\n      (objNew.objPropA: string)\n    }\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n    {\n      // $ExpectError eA nor any nor string\n      (objNew.objPropA: number)\n    }\n    {\n      // obj is null\n      (obj: null)\n    }\n    {\n      // $ExpectError eA nor any nor string\n      (obj: string)\n    }\n  </div>\n\nconst renameEnhacer: HOC<*, EnhancedCompProps> = compose(\n  (renameProp('obj', 'objNew'): HOC<\n    {\n      ...$Exact<EnhancedCompProps>,\n      ...$Exact<{ obj: null }>,\n      // $PropertyType does not work here\n      ...$Exact<{ objNew: { objPropA: string, objPropB: number } }>,\n    },\n    EnhancedCompProps\n  >),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError\n    eB: (props.eA: string),\n  }))\n)\n\nrenameEnhacer(RenameComp)\n\nconst renamePropsEnhacer: HOC<*, EnhancedCompProps> = compose(\n  (renameProps({ obj: 'objNew' }): HOC<\n    {\n      ...$Exact<EnhancedCompProps>,\n      // --- repeat for every key ---\n      ...$Exact<{ obj: null }>,\n      // $PropertyType does not work here\n      ...$Exact<{ objNew: { objPropA: string, objPropB: number } }>,\n    },\n    EnhancedCompProps\n  >),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError\n    eB: (props.eA: string),\n  }))\n)\n\n// use withStateHandlers instead\nconst withStateEnhancer: HOC<*, EnhancedCompProps> = compose(\n  (withState('a', 'setA', { hello: 'world' }): HOC<\n    {\n      ...$Exact<EnhancedCompProps>,\n      ...$Exact<{ a: { hello: string }, setA: (a: { hello: string }) => void }>,\n    },\n    EnhancedCompProps\n  >),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError\n    eB: (props.eA: string),\n  }))\n)\n\n// withReducer see withState above\n// lifecycle see  withState above\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_withContext.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, withContext } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ eA }) =>\n  <div>\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  withContext({}, props => {\n    // $ExpectError eA nor any nor string\n    ;(props.eA: string)\n    return {}\n  }),\n  withProps(props => ({\n    eA: (props.eA: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_withHandlers.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\n\nimport React from 'react'\nimport { compose, withProps, withHandlers } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = {\n  value: number,\n  onChange: (value: number) => void,\n  onOtherChange: (value: { id: string }) => void,\n}\n\nconst enhancer: HOC<*, EnhancedCompProps> = compose(\n  withHandlers({\n    onValueChange: props => value => {\n      props.onChange(value)\n      return true\n    },\n    onOtherValueChange: props => value => {\n      props.onOtherChange(value)\n      return true\n    },\n  }),\n  // here props itself will not be infered without explicit handler args types\n  withProps(props => ({\n    valueClone: (props.value: number),\n    resType: (props.onValueChange(0): boolean),\n    ee: props.onOtherValueChange({ id: 'aa' }),\n\n    // $ExpectError result is not any or number\n    resTypeErr: (props.onValueChange(0): number),\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\n// check that factory init works as expected\nconst enhancer2: HOC<*, EnhancedCompProps> = compose(\n  withHandlers(() => ({\n    onValueChange: props => value => {\n      props.onChange(value)\n      return true\n    },\n  })),\n  // here props itself will not be infered without explicit handler args types\n  withProps(props => ({\n    valueClone: (props.value: number),\n    resType: (props.onValueChange(0): boolean),\n\n    // $ExpectError result is not any or number\n    resTypeErr: (props.onValueChange(0): number),\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst BaseComp = ({ value, onValueChange }) =>\n  <div\n    onClick={() => {\n      const res = onValueChange(1)\n      ;(res: boolean)\n      // $ExpectError\n      ;(res: number)\n    }}\n  >\n    {(value: number)}\n    {\n      // $ExpectError value is not any or string\n      (value: string)\n    }\n  </div>\n\nconst Enhanced = enhancer(BaseComp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_withProps.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { a: string, b: number }\n\nconst Comp = ({ hello, b }) =>\n  <div>\n    {hello}\n    {b}\n    {\n      // $ExpectError\n      (b: number)\n    }\n    {\n      // $ExpectError\n      (hello: number)\n    }\n  </div>\n\nconst enhancer: HOC<*, EnhancedCompProps> = compose(\n  withProps(({ a, b }) => ({\n    hello: a,\n    b: `${b}`,\n  })),\n  withProps(({ b, hello }) => ({\n    hello: (hello: string),\n    // $ExpectError (This type is incompatible with number)\n    c: (b: number),\n  })),\n  // check non functional form of with props\n  withProps({\n    d: 'hi',\n  }),\n  withProps(props => ({\n    a: (props.a: string),\n    d: (props.d: string),\n    // $ExpectError property not found\n    err: props.iMNotExists,\n    // $ExpectError a not a number and not any\n    aErr: (props.a: number),\n    // $ExpectError d not a number and not any\n    dErr: (props.d: number),\n  }))\n)\n\nconst EnhancedComponent = enhancer(Comp)\n;<EnhancedComponent a={'1'} b={1} />\n\n// $ExpectError\n;<EnhancedComponent a={'1'} b={'1'} />\n\n// $ExpectError\n;<EnhancedComponent a={'1'} />\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_withPropsOnChange.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions, arrow-body-style */\n/* @flow */\nimport React from 'react'\nimport { compose, withProps, withPropsOnChange } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = { eA: 1 }\n\nconst Comp = ({ hello, eA }) =>\n  <div>\n    {(hello: string)}\n    {(eA: number)}\n    {\n      // $ExpectError eA nor any nor string\n      (eA: string)\n    }\n    {\n      // $ExpectError hello nor any nor number\n      (hello: number)\n    }\n  </div>\n\nconst enhacer: HOC<*, EnhancedCompProps> = compose(\n  withPropsOnChange(['eA'], ({ eA }) => ({\n    hello: `${eA}`,\n  })),\n  withProps(props => ({\n    hello: (props.hello: string),\n    eA: (props.eA: number),\n    // $ExpectError hello nor any nor number\n    helloErr: (props.hello: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  })),\n  withProps(props => ({\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst enhacerFn: HOC<*, EnhancedCompProps> = compose(\n  withPropsOnChange(\n    (props, nextProps) => {\n      ;(props.eA: number)\n      ;(nextProps.eA: number)\n      // $ExpectError eA nor any nor string\n      ;(props.eA: string)\n      // $ExpectError eA nor any nor string\n      ;(nextProps.eA: string)\n      return props.eA === props.eA\n    },\n    ({ eA }) => ({\n      hello: `${eA}`,\n    })\n  ),\n  withProps(props => ({\n    hello: (props.hello: string),\n    eA: (props.eA: number),\n    // $ExpectError hello nor any nor number\n    helloErr: (props.hello: number),\n    // $ExpectError eA nor any nor string\n    eAErr: (props.eA: string),\n  }))\n)\n\nconst enhacerErr: HOC<*, EnhancedCompProps> = compose(\n  // $ExpectError property property `eB` not found\n  withPropsOnChange(['eA', 'eB'], ({ eA }) => ({\n    hello: `${eA}`,\n  }))\n)\n\nconst enhacerFnErr: HOC<*, EnhancedCompProps> = compose(\n  withPropsOnChange(\n    (props, nextProps) => {\n      // $ExpectError boolean\n      return 1\n    },\n    ({ eA }) => ({\n      hello: `${eA}`,\n    })\n  ),\n  withProps(props => ({\n    hello: (props.hello: string),\n    eA: (props.eA: number),\n  }))\n)\n\nconst EnhancedComponent = enhacer(Comp)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/types/test_withStateHandlers.js",
    "content": "/* eslint-disable no-unused-vars, no-unused-expressions */\n/* @flow */\n\nimport React from 'react'\nimport { compose, withProps, withStateHandlers } from '../..'\n\nimport type { HOC } from '../..'\n\ntype EnhancedCompProps = {\n  initialCounter: number,\n}\n\nconst enhancer: HOC<*, EnhancedCompProps> = compose(\n  withStateHandlers(\n    { value: 'Hello', letIt: 'be', obj: ({}: { [key: string]: string }) },\n    {\n      // we need to set argument type so inference will work good\n      setValue: (state, props) => (value: string) => ({\n        value,\n      }),\n      changeValue: (state, props) => (\n        { i, j }: { i: number, j: string },\n        k: number\n      ) => ({\n        value: `world again ${i} ${j}`,\n      }),\n      inform: state => () => {},\n    }\n  ),\n  // here props itself will not be infered without explicit handler args types\n  withProps(props => ({\n    hi: (props.value: string),\n    ic: (props.initialCounter: number),\n    cc: (props.obj.a: string),\n    // $ExpectError value not a number or any\n    ehi: (props.value: number),\n    // $ExpectError not a number\n    cn: (props.obj.a: number),\n    // $ExpectError property not found (to detect that props is not any)\n    err: props.iMNotExists,\n    // $ExpectError initialCounter not any nor string\n    icErr: (props.initialCounter: string),\n  }))\n)\n\nconst enhancerFuncInit: HOC<*, EnhancedCompProps> = compose(\n  withStateHandlers(\n    props => ({\n      counter: props.initialCounter,\n    }),\n    {\n      // it's better to set argument type with named props, easier to find an error\n      // if you call it with wrong arguments\n      incCounter: ({ counter }) => ({ value }: { value: number }) => ({\n        counter: counter + value,\n      }),\n    }\n  ),\n  withProps(props => ({\n    // check that result is void\n    iVal: (props.incCounter({ value: 1 }): void),\n    // $ExpectError check that incCounter is not any\n    iVal2: (props.incCounter({ value: 1 }): number),\n    // $ExpectError property not found\n    err: props.iMNotExists,\n  }))\n)\n\nconst BaseComponent = ({ hi, changeValue, setValue }) =>\n  <div\n    onClick={() => {\n      // check that supports few arguments\n      const x = changeValue({ i: 1, j: '1' }, 1)\n\n      setValue('ww')\n      // Check that result is void\n      ;(x: void)\n\n      // $ExpectError check that x is not any\n      ;(x: {})\n\n      // Check hi\n      ;(hi: string)\n\n      // $ExpectError check that hi is not any\n      ;(hi: number)\n    }}\n  >\n    {hi}\n  </div>\n\nconst EnhancedComponent = enhancer(BaseComponent)\n;<EnhancedComponent initialCounter={0} />\n\n// Without $Exact<State> this will cause error\nconst enhancer3: HOC<*, EnhancedCompProps> = compose(\n  withStateHandlers(\n    ({\n      mapA2B: {},\n    }: { mapA2B: { [key: string]: string } }),\n    {}\n  ),\n  withProps(props => ({\n    // check that result is void\n    iVal: props.mapA2B.c,\n  }))\n)\n"
  },
  {
    "path": "src/packages/recompose/__tests__/utils.js",
    "content": "import React from 'react'\nimport setDisplayName from '../setDisplayName'\nimport wrapDisplayName from '../wrapDisplayName'\n\nexport const countRenders = BaseComponent => {\n  class CountRenders extends React.Component {\n    renderCount = 0\n\n    render() {\n      this.renderCount += 1\n      return <BaseComponent renderCount={this.renderCount} {...this.props} />\n    }\n  }\n\n  return setDisplayName(wrapDisplayName(BaseComponent, 'countRenders'))(\n    CountRenders\n  )\n}\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withContext-test.js",
    "content": "/* eslint-disable react/require-default-props */\nimport React, { Component } from 'react'\nimport PropTypes from 'prop-types'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { withContext, getContext, compose, mapProps } from '../'\n\ntest('withContext + getContext adds to and grabs from context', () => {\n  // Mini React Redux clone\n  const store = {\n    getState: () => ({\n      todos: ['eat', 'drink', 'sleep'],\n      counter: 12,\n    }),\n  }\n\n  class BaseProvider extends Component {\n    static propTypes = {\n      children: PropTypes.node,\n    }\n\n    render() {\n      return this.props.children\n    }\n  }\n\n  const Provider = compose(\n    withContext({ store: PropTypes.object }, props => ({ store: props.store }))\n  )(BaseProvider)\n\n  expect(Provider.displayName).toBe('withContext(BaseProvider)')\n\n  const connect = selector =>\n    compose(\n      getContext({ store: PropTypes.object }),\n      mapProps(props => selector(props.store.getState()))\n    )\n\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const TodoList = connect(({ todos }) => ({ todos }))(component)\n\n  expect(TodoList.displayName).toBe('getContext(mapProps(component))')\n\n  mount(\n    <Provider store={store}>\n      <TodoList />\n    </Provider>\n  )\n\n  expect(component.lastCall.args[0].todos).toEqual(['eat', 'drink', 'sleep'])\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withHandlers-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { withHandlers, withState, compose } from '../'\n\ntest('withHandlers passes handlers to base component', () => {\n  let submittedFormValue\n  const enhanceForm = compose(\n    withState('value', 'updateValue', ''),\n    withHandlers({\n      onChange: props => event => {\n        props.updateValue(event.target.value)\n      },\n      onSubmit: props => () => {\n        submittedFormValue = props.value\n      },\n    })\n  )\n\n  const Form = enhanceForm(({ value, onChange, onSubmit }) =>\n    <form onSubmit={onSubmit}>\n      <label>\n        Value\n        <input type=\"text\" value={value} onChange={onChange} />\n      </label>\n      <p>\n        {value}\n      </p>\n    </form>\n  )\n\n  const wrapper = mount(<Form />)\n  const input = wrapper.find('input')\n  const output = wrapper.find('p')\n  const form = wrapper.find('form')\n\n  input.simulate('change', { target: { value: 'Yay' } })\n  expect(output.text()).toBe('Yay')\n\n  input.simulate('change', { target: { value: 'Yay!!' } })\n  expect(output.text()).toBe('Yay!!')\n\n  form.simulate('submit')\n  expect(submittedFormValue).toBe('Yay!!')\n})\n\ntest('withHandlers passes immutable handlers', () => {\n  const enhance = withHandlers({\n    handler: () => () => null,\n  })\n  const component = sinon.spy(() => null)\n  const Div = enhance(component)\n\n  const wrapper = mount(<Div />)\n  wrapper.setProps({ foo: 'bar' })\n\n  expect(component.calledTwice).toBe(true)\n  expect(component.firstCall.args[0].handler).toBe(\n    component.secondCall.args[0].handler\n  )\n})\n\ntest('withHandlers warns if handler is not a higher-order function', () => {\n  const error = sinon.stub(console, 'error')\n\n  const Button = withHandlers({\n    onClick: () => {},\n  })('button')\n\n  const wrapper = mount(<Button />)\n  const button = wrapper.find('button')\n\n  expect(() => button.simulate('click')).toThrowError(/undefined/)\n\n  expect(error.firstCall.args[0]).toBe(\n    'withHandlers(): Expected a map of higher-order functions. Refer to ' +\n      'the docs for more info.'\n  )\n\n  /* eslint-disable */\n  console.error.restore()\n  /* eslint-enable */\n})\n\ntest('withHandlers allow handers to be a factory', () => {\n  const enhance = withHandlers(initialProps => {\n    let cache_\n\n    return {\n      handler: () => () => {\n        if (cache_) {\n          return cache_\n        }\n        cache_ = { ...initialProps }\n\n        return cache_\n      },\n    }\n  })\n\n  const componentHandlers = []\n  const componentHandlers2 = []\n\n  const Component = enhance(({ handler }) => {\n    componentHandlers.push(handler())\n    return null\n  })\n\n  const Component2 = enhance(({ handler }) => {\n    componentHandlers2.push(handler())\n    return null\n  })\n\n  const wrapper = mount(<Component hello={'foo'} />)\n  wrapper.setProps({ hello: 'bar' })\n  expect(componentHandlers[0]).toBe(componentHandlers[1])\n\n  // check that cache is not shared\n  mount(<Component2 hello={'foo'} />)\n  expect(componentHandlers[0]).toEqual(componentHandlers2[0])\n  expect(componentHandlers[0]).not.toBe(componentHandlers2[0])\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withProps-test.js",
    "content": "import React from 'react'\nimport { shallow } from 'enzyme'\nimport { withProps } from '../'\n\ntest('withProps passes additional props to base component', () => {\n  const DoReMi = withProps({ 'data-so': 'do', 'data-la': 'fa' })('div')\n  expect(DoReMi.displayName).toBe('withProps(div)')\n\n  const div = shallow(<DoReMi />).find('div')\n  expect(div.prop('data-so')).toBe('do')\n  expect(div.prop('data-la')).toBe('fa')\n})\n\ntest('withProps takes precedent over owner props', () => {\n  const DoReMi = withProps({ 'data-so': 'do', 'data-la': 'fa' })('div')\n\n  const div = shallow(<DoReMi data-la=\"ti\" />).find('div')\n  expect(div.prop('data-so')).toBe('do')\n  expect(div.prop('data-la')).toBe('fa')\n})\n\ntest('withProps should accept function', () => {\n  const DoReMi = withProps(props => ({\n    'data-so': props['data-la'],\n  }))('div')\n\n  const div = shallow(<DoReMi data-la=\"la\" />).find('div')\n  expect(div.prop('data-so')).toBe('la')\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withPropsOnChange-test.js",
    "content": "import * as React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport {\n  withPropsOnChange,\n  withState,\n  withStateHandlers,\n  flattenProp,\n  compose,\n} from '../'\n\ntest('withPropsOnChange maps subset of owner props to child props', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const mapSpy = sinon.spy()\n  const StringConcat = compose(\n    withState('strings', 'updateStrings', { a: 'a', b: 'b', c: 'c' }),\n    flattenProp('strings'),\n    withPropsOnChange(['a', 'b'], ({ a, b, ...props }) => {\n      mapSpy()\n      return {\n        ...props,\n        foobar: a + b,\n      }\n    })\n  )(component)\n\n  expect(StringConcat.displayName).toBe(\n    'withState(flattenProp(withPropsOnChange(component)))'\n  )\n\n  mount(<StringConcat />)\n  const { updateStrings } = component.firstCall.args[0]\n  expect(component.lastCall.args[0].foobar).toBe('ab')\n  expect(component.calledOnce).toBe(true)\n  expect(mapSpy.callCount).toBe(1)\n\n  // Does not re-map for non-dependent prop updates\n  updateStrings(strings => ({ ...strings, c: 'baz' }))\n  expect(component.lastCall.args[0].foobar).toBe('ab')\n  expect(component.lastCall.args[0].c).toBe('c')\n  expect(component.calledTwice).toBe(true)\n  expect(mapSpy.callCount).toBe(1)\n\n  updateStrings(strings => ({ ...strings, a: 'foo', b: 'bar' }))\n  expect(component.lastCall.args[0].foobar).toBe('foobar')\n  expect(component.lastCall.args[0].c).toBe('baz')\n  expect(component.calledThrice).toBe(true)\n  expect(mapSpy.callCount).toBe(2)\n})\n\ntest('withPropsOnChange maps subset of owner props to child props with custom predicate', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const mapSpy = sinon.spy()\n  const shouldMapSpy = sinon.spy()\n  const PageContainer = compose(\n    withStateHandlers(\n      { result: { hasError: false, loading: true, error: null } },\n      {\n        updateResult: ({ result }) => payload => ({\n          result: { ...result, ...payload },\n        }),\n      }\n    ),\n    withPropsOnChange(\n      ({ result }, { result: nextResult }) => {\n        shouldMapSpy(result, nextResult)\n        return !result.hasError && nextResult.hasError\n      },\n      ({ result: { hasError, error } }) => {\n        mapSpy()\n\n        if (hasError) {\n          return {\n            errorEverHappened: true,\n            lastError: error,\n          }\n        }\n\n        return {\n          errorEverHappened: false,\n        }\n      }\n    )\n  )(component)\n\n  expect(PageContainer.displayName).toBe(\n    'withStateHandlers(withPropsOnChange(component))'\n  )\n\n  mount(<PageContainer />)\n  const { updateResult } = component.firstCall.args[0]\n  expect(component.lastCall.args[0].errorEverHappened).toBe(false)\n  expect(component.lastCall.args[0].lastError).toBeUndefined()\n  expect(component.calledOnce).toBe(true)\n  expect(mapSpy.callCount).toBe(1)\n  expect(shouldMapSpy.callCount).toBe(1)\n\n  updateResult({ loading: false, hasError: true, error: '1' })\n  expect(component.lastCall.args[0].errorEverHappened).toBe(true)\n  expect(component.lastCall.args[0].lastError).toBe('1')\n  expect(component.calledTwice).toBe(true)\n  expect(mapSpy.callCount).toBe(2)\n\n  // Does not re-map for false map result\n  updateResult({ loading: true, hasError: false, error: null })\n  expect(component.lastCall.args[0].errorEverHappened).toBe(true)\n  expect(component.lastCall.args[0].lastError).toBe('1')\n  expect(component.calledThrice).toBe(true)\n  expect(mapSpy.callCount).toBe(2)\n\n  updateResult({ loading: false, hasError: true, error: '2' })\n  expect(component.lastCall.args[0].errorEverHappened).toBe(true)\n  expect(component.lastCall.args[0].lastError).toBe('2')\n  expect(component.callCount).toBe(4)\n  expect(mapSpy.callCount).toBe(3)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withReducer-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\nimport { withReducer, compose, flattenProp } from '../'\n\nconst SET_COUNTER = 'SET_COUNTER'\n\ntest('adds a stateful value and a function for updating it', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const initialState = { counter: 0 }\n\n  const reducer = (state, action) =>\n    action.type === SET_COUNTER ? { counter: action.payload } : state\n\n  const Counter = compose(\n    withReducer('state', 'dispatch', reducer, initialState),\n    flattenProp('state')\n  )(component)\n\n  expect(Counter.displayName).toBe('withReducer(flattenProp(component))')\n\n  mount(<Counter />)\n  const { dispatch } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n\n  dispatch({ type: SET_COUNTER, payload: 18 })\n  expect(component.lastCall.args[0].counter).toBe(18)\n})\n\ntest('calls initialState when it is a function', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const initialState = ({ initialCount }) => ({ counter: initialCount })\n\n  const reducer = (state, action) =>\n    action.type === SET_COUNTER ? { counter: action.payload } : state\n\n  const Counter = compose(\n    withReducer('state', 'dispatch', reducer, initialState),\n    flattenProp('state')\n  )(component)\n\n  mount(<Counter initialCount={10} />)\n\n  expect(component.lastCall.args[0].counter).toBe(10)\n})\n\ntest('receives state from reducer when initialState is not provided', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const initialState = { counter: 0 }\n\n  const reducer = (state = initialState, action) =>\n    action.type === SET_COUNTER ? { counter: action.payload } : state\n\n  const Counter = compose(\n    withReducer('state', 'dispatch', reducer),\n    flattenProp('state')\n  )(component)\n\n  mount(<Counter />)\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n})\n\ntest('calls the given callback with new state after a dispatch call', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const initialState = { counter: 0 }\n\n  const reducer = (state, action) =>\n    action.type === SET_COUNTER ? { counter: action.payload } : state\n\n  const Counter = compose(\n    withReducer('state', 'dispatch', reducer, initialState),\n    flattenProp('state')\n  )(component)\n\n  mount(<Counter />)\n  const dispatch = sinon.spy(component.firstCall.args[0].dispatch)\n  const callback = sinon.spy()\n\n  dispatch({ type: SET_COUNTER, payload: 11 }, callback)\n  expect(dispatch.calledBefore(callback)).toBe(true)\n  expect(dispatch.calledOnce).toBe(true)\n  expect(callback.calledAfter(dispatch)).toBe(true)\n  expect(callback.calledOnce).toBe(true)\n  expect(callback.getCall(0).args.length).toBe(1)\n  expect(callback.getCall(0).args[0]).toEqual({ counter: 11 })\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withState-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\n\nimport { withState } from '../'\n\ntest('withState adds a stateful value and a function for updating it', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withState('counter', 'updateCounter', 0)(component)\n  expect(Counter.displayName).toBe('withState(component)')\n\n  mount(<Counter pass=\"through\" />)\n  const { updateCounter } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n  expect(component.lastCall.args[0].pass).toBe('through')\n\n  updateCounter(n => n + 9)\n  updateCounter(n => n * 2)\n\n  expect(component.lastCall.args[0].counter).toBe(18)\n  expect(component.lastCall.args[0].pass).toBe('through')\n})\n\ntest('withState also accepts a non-function, which is passed directly to setState()', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withState('counter', 'updateCounter', 0)(component)\n  mount(<Counter />)\n  const { updateCounter } = component.firstCall.args[0]\n\n  updateCounter(18)\n  expect(component.lastCall.args[0].counter).toBe(18)\n})\n\ntest('withState accepts setState() callback', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withState('counter', 'updateCounter', 0)(component)\n  mount(<Counter />)\n  const { updateCounter } = component.firstCall.args[0]\n\n  const renderSpy = sinon.spy(() => {\n    expect(component.lastCall.args[0].counter).toBe(18)\n  })\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n  updateCounter(18, renderSpy)\n})\n\ntest('withState also accepts initialState as function of props', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withState(\n    'counter',\n    'updateCounter',\n    props => props.initialCounter\n  )(component)\n\n  mount(<Counter initialCounter={1} />)\n  const { updateCounter } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].counter).toBe(1)\n  updateCounter(n => n * 3)\n  expect(component.lastCall.args[0].counter).toBe(3)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/withStateHandlers-test.js",
    "content": "import React from 'react'\nimport { mount } from 'enzyme'\nimport sinon from 'sinon'\n\nimport { compose, withStateHandlers } from '../'\n\ntest('withStateHandlers should persist events passed as argument', () => {\n  const component = ({ value, onChange }) =>\n    <div>\n      <input type=\"text\" value={value} onChange={onChange} />\n      <p>\n        {value}\n      </p>\n    </div>\n\n  const InputComponent = withStateHandlers(\n    { value: '' },\n    {\n      onChange: () => e => ({\n        value: e.target.value,\n      }),\n    }\n  )(component)\n\n  const wrapper = mount(<InputComponent />)\n  const input = wrapper.find('input')\n  const output = wrapper.find('p')\n  // having that enzyme simulate does not simulate real situation\n  // emulate persist\n  input.simulate('change', {\n    persist() {\n      this.target = { value: 'Yay' }\n    },\n  })\n  expect(output.text()).toBe('Yay')\n\n  input.simulate('change', { target: { value: 'empty' } })\n  expect(output.text()).toBe('empty')\n})\n\ntest('withStateHandlers adds a stateful value and a function for updating it', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withStateHandlers(\n    { counter: 0 },\n    {\n      updateCounter: ({ counter }) => increment => ({\n        counter: counter + increment,\n      }),\n    }\n  )(component)\n  expect(Counter.displayName).toBe('withStateHandlers(component)')\n\n  mount(<Counter pass=\"through\" />)\n  const { updateCounter } = component.firstCall.args[0]\n\n  expect(component.lastCall.args[0].counter).toBe(0)\n  expect(component.lastCall.args[0].pass).toBe('through')\n\n  updateCounter(9)\n  expect(component.lastCall.args[0].counter).toBe(9)\n  updateCounter(1)\n  updateCounter(10)\n\n  expect(component.lastCall.args[0].counter).toBe(20)\n  expect(component.lastCall.args[0].pass).toBe('through')\n})\n\ntest('withStateHandlers accepts initialState as function of props', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withStateHandlers(\n    ({ initialCounter }) => ({\n      counter: initialCounter,\n    }),\n    {\n      updateCounter: ({ counter }) => increment => ({\n        counter: counter + increment,\n      }),\n    }\n  )(component)\n\n  const initialCounter = 101\n\n  mount(<Counter initialCounter={initialCounter} />)\n  expect(component.lastCall.args[0].counter).toBe(initialCounter)\n})\n\ntest('withStateHandlers initial state must be function or object or null or undefined', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withStateHandlers(1, {})(component)\n  // React throws an error\n  // expect(() => mount(<Counter />)).toThrow()\n  const error = sinon.stub(console, 'error')\n  mount(<Counter />)\n  expect(error.called).toBe(true)\n})\n\ntest('withStateHandlers have access to props', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withStateHandlers(\n    ({ initialCounter }) => ({\n      counter: initialCounter,\n    }),\n    {\n      increment: ({ counter }, { incrementValue }) => () => ({\n        counter: counter + incrementValue,\n      }),\n    }\n  )(component)\n\n  const initialCounter = 101\n  const incrementValue = 37\n\n  mount(\n    <Counter initialCounter={initialCounter} incrementValue={incrementValue} />\n  )\n\n  const { increment } = component.firstCall.args[0]\n\n  increment()\n  expect(component.lastCall.args[0].counter).toBe(\n    initialCounter + incrementValue\n  )\n})\n\ntest('withStateHandlers passes immutable state updaters', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withStateHandlers(\n    ({ initialCounter }) => ({\n      counter: initialCounter,\n    }),\n    {\n      increment: ({ counter }, { incrementValue }) => () => ({\n        counter: counter + incrementValue,\n      }),\n    }\n  )(component)\n\n  const initialCounter = 101\n  const incrementValue = 37\n\n  mount(\n    <Counter initialCounter={initialCounter} incrementValue={incrementValue} />\n  )\n\n  const { increment } = component.firstCall.args[0]\n\n  increment()\n  expect(component.lastCall.args[0].counter).toBe(\n    initialCounter + incrementValue\n  )\n})\n\ntest('withStateHandlers does not rerender if state updater returns undefined', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = withStateHandlers(\n    ({ initialCounter }) => ({\n      counter: initialCounter,\n    }),\n    {\n      updateCounter: ({ counter }) => increment =>\n        increment === 0\n          ? undefined\n          : {\n              counter: counter + increment,\n            },\n    }\n  )(component)\n\n  const initialCounter = 101\n\n  mount(<Counter initialCounter={initialCounter} />)\n  expect(component.callCount).toBe(1)\n\n  const { updateCounter } = component.firstCall.args[0]\n\n  updateCounter(1)\n  expect(component.callCount).toBe(2)\n\n  updateCounter(0)\n  expect(component.callCount).toBe(2)\n})\n\ntest('withStateHandlers rerenders if parent props changed', () => {\n  const component = sinon.spy(() => null)\n  component.displayName = 'component'\n\n  const Counter = compose(\n    withStateHandlers(\n      ({ initialCounter }) => ({\n        counter: initialCounter,\n      }),\n      {\n        increment: ({ counter }) => incrementValue => ({\n          counter: counter + incrementValue,\n        }),\n      }\n    ),\n    withStateHandlers(\n      { incrementValue: 1 },\n      {\n        // updates parent state and return undefined\n        updateParentIncrement: ({ incrementValue }, { increment }) => () => {\n          increment(incrementValue)\n          return undefined\n        },\n      }\n    )\n  )(component)\n\n  const initialCounter = 101\n\n  mount(<Counter initialCounter={initialCounter} />)\n\n  const { updateParentIncrement } = component.firstCall.args[0]\n\n  updateParentIncrement()\n  expect(component.lastCall.args[0].counter).toBe(initialCounter + 1)\n})\n"
  },
  {
    "path": "src/packages/recompose/__tests__/wrapDisplayName-test.js",
    "content": "import React from 'react'\nimport { wrapDisplayName } from '../'\n\ntest('wrapDisplayName wraps the display name of a React component with the name of an HoC, Relay-style', () => {\n  class SomeComponent extends React.Component {\n    render() {\n      return <div />\n    }\n  }\n\n  expect(wrapDisplayName(SomeComponent, 'someHoC')).toBe(\n    'someHoC(SomeComponent)'\n  )\n})\n"
  },
  {
    "path": "src/packages/recompose/baconObservableConfig.js",
    "content": "import $$observable from 'symbol-observable'\nimport Bacon from 'baconjs'\n\nconst config = {\n  fromESObservable: observable =>\n    Bacon.fromBinder(sink => {\n      const { unsubscribe } = observable.subscribe({\n        next: val => sink(new Bacon.Next(val)),\n        error: err => sink(new Bacon.Error(err)),\n        complete: () => sink(new Bacon.End()),\n      })\n      return unsubscribe\n    }),\n  toESObservable: stream => ({\n    subscribe: observer => {\n      const unsubscribe = stream.subscribe(event => {\n        if (event.hasValue()) {\n          observer.next(event.value())\n        } else if (event.isError()) {\n          observer.error(event.error)\n        } else if (event.isEnd()) {\n          observer.complete()\n        }\n      })\n      return { unsubscribe }\n    },\n    [$$observable]() {\n      return this\n    },\n  }),\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose/branch.js",
    "content": "import { createFactory } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst identity = Component => Component\n\nconst branch = (test, left, right = identity) => BaseComponent => {\n  let leftFactory\n  let rightFactory\n  const Branch = props => {\n    if (test(props)) {\n      leftFactory = leftFactory || createFactory(left(BaseComponent))\n      return leftFactory(props)\n    }\n    rightFactory = rightFactory || createFactory(right(BaseComponent))\n    return rightFactory(props)\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'branch'))(Branch)\n  }\n  return Branch\n}\n\nexport default branch\n"
  },
  {
    "path": "src/packages/recompose/componentFromProp.js",
    "content": "import { createElement } from 'react'\nimport omit from './utils/omit'\n\nconst componentFromProp = propName => {\n  const Component = props =>\n    createElement(props[propName], omit(props, [propName]))\n  Component.displayName = `componentFromProp(${propName})`\n  return Component\n}\n\nexport default componentFromProp\n"
  },
  {
    "path": "src/packages/recompose/componentFromStream.js",
    "content": "import { Component } from 'react'\nimport { createChangeEmitter } from 'change-emitter'\nimport $$observable from 'symbol-observable'\nimport { config as globalConfig } from './setObservableConfig'\n\nexport const componentFromStreamWithConfig = config => propsToVdom =>\n  class ComponentFromStream extends Component {\n    state = { vdom: null }\n\n    propsEmitter = createChangeEmitter()\n\n    // Stream of props\n    props$ = config.fromESObservable({\n      subscribe: observer => {\n        const unsubscribe = this.propsEmitter.listen(props => {\n          if (props) {\n            observer.next(props)\n          } else {\n            observer.complete()\n          }\n        })\n        return { unsubscribe }\n      },\n      [$$observable]() {\n        return this\n      },\n    })\n\n    // Stream of vdom\n    vdom$ = config.toESObservable(propsToVdom(this.props$))\n\n    componentWillMount() {\n      // Subscribe to child prop changes so we know when to re-render\n      this.subscription = this.vdom$.subscribe({\n        next: vdom => {\n          this.setState({ vdom })\n        },\n      })\n      this.propsEmitter.emit(this.props)\n    }\n\n    componentWillReceiveProps(nextProps) {\n      // Receive new props from the owner\n      this.propsEmitter.emit(nextProps)\n    }\n\n    shouldComponentUpdate(nextProps, nextState) {\n      return nextState.vdom !== this.state.vdom\n    }\n\n    componentWillUnmount() {\n      // Call without arguments to complete stream\n      this.propsEmitter.emit()\n\n      // Clean-up subscription before un-mounting\n      this.subscription.unsubscribe()\n    }\n\n    render() {\n      return this.state.vdom\n    }\n  }\n\nconst componentFromStream = propsToVdom =>\n  componentFromStreamWithConfig(globalConfig)(propsToVdom)\n\nexport default componentFromStream\n"
  },
  {
    "path": "src/packages/recompose/compose.js",
    "content": "const compose = (...funcs) =>\n  funcs.reduce((a, b) => (...args) => a(b(...args)), arg => arg)\n\nexport default compose\n"
  },
  {
    "path": "src/packages/recompose/createEventHandler.js",
    "content": "import $$observable from 'symbol-observable'\nimport { createChangeEmitter } from 'change-emitter'\nimport { config as globalConfig } from './setObservableConfig'\n\nexport const createEventHandlerWithConfig = config => () => {\n  const emitter = createChangeEmitter()\n  const stream = config.fromESObservable({\n    subscribe(observer) {\n      const unsubscribe = emitter.listen(value => observer.next(value))\n      return { unsubscribe }\n    },\n    [$$observable]() {\n      return this\n    },\n  })\n  return {\n    handler: emitter.emit,\n    stream,\n  }\n}\n\nconst createEventHandler = createEventHandlerWithConfig(globalConfig)\n\nexport default createEventHandler\n"
  },
  {
    "path": "src/packages/recompose/createSink.js",
    "content": "import { Component } from 'react'\nimport { polyfill } from 'react-lifecycles-compat'\n\nconst createSink = callback => {\n  class Sink extends Component {\n    state = {}\n\n    static getDerivedStateFromProps(nextProps) {\n      callback(nextProps)\n      return null\n    }\n\n    render() {\n      return null\n    }\n  }\n\n  polyfill(Sink)\n  return Sink\n}\n\nexport default createSink\n"
  },
  {
    "path": "src/packages/recompose/defaultProps.js",
    "content": "import { createFactory } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst defaultProps = props => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  const DefaultProps = ownerProps => factory(ownerProps)\n  DefaultProps.defaultProps = props\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'defaultProps'))(\n      DefaultProps\n    )\n  }\n  return DefaultProps\n}\n\nexport default defaultProps\n"
  },
  {
    "path": "src/packages/recompose/flattenProp.js",
    "content": "import { createFactory } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst flattenProp = propName => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  const FlattenProp = props =>\n    factory({\n      ...props,\n      ...props[propName],\n    })\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'flattenProp'))(\n      FlattenProp\n    )\n  }\n  return FlattenProp\n}\n\nexport default flattenProp\n"
  },
  {
    "path": "src/packages/recompose/flydObservableConfig.js",
    "content": "import $$observable from 'symbol-observable'\nimport flyd from 'flyd'\n\nconst noop = () => {}\n\nconst config = {\n  fromESObservable: observable => {\n    const stream = flyd.stream()\n    const { unsubscribe } = observable.subscribe({\n      next: value => stream(value),\n      error: error => stream({ error }),\n      complete: () => stream.end(true),\n    })\n\n    flyd.on(unsubscribe, stream.end)\n    return stream\n  },\n\n  toESObservable: stream => ({\n    subscribe: observer => {\n      const sub = flyd.on(observer.next || noop, stream)\n      flyd.on(_ => observer.complete(), sub.end)\n      return {\n        unsubscribe: () => sub.end(true),\n      }\n    },\n    [$$observable]() {\n      return this\n    },\n  }),\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose/fromRenderProps.js",
    "content": "import React from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst fromRenderProps = (\n  RenderPropsComponent,\n  propsMapper,\n  renderPropName = 'children'\n) => BaseComponent => {\n  const baseFactory = React.createFactory(BaseComponent)\n  const renderPropsFactory = React.createFactory(RenderPropsComponent)\n\n  const FromRenderProps = ownerProps =>\n    renderPropsFactory({\n      [renderPropName]: (...props) =>\n        baseFactory({ ...ownerProps, ...propsMapper(...props) }),\n    })\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'fromRenderProps'))(\n      FromRenderProps\n    )\n  }\n\n  return FromRenderProps\n}\n\nexport default fromRenderProps\n"
  },
  {
    "path": "src/packages/recompose/getContext.js",
    "content": "import { createFactory } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst getContext = contextTypes => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  const GetContext = (ownerProps, context) =>\n    factory({\n      ...ownerProps,\n      ...context,\n    })\n\n  GetContext.contextTypes = contextTypes\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'getContext'))(\n      GetContext\n    )\n  }\n  return GetContext\n}\n\nexport default getContext\n"
  },
  {
    "path": "src/packages/recompose/getDisplayName.js",
    "content": "const getDisplayName = Component => {\n  if (typeof Component === 'string') {\n    return Component\n  }\n\n  if (!Component) {\n    return undefined\n  }\n\n  return Component.displayName || Component.name || 'Component'\n}\n\nexport default getDisplayName\n"
  },
  {
    "path": "src/packages/recompose/hoistStatics.js",
    "content": "import hoistNonReactStatics from 'hoist-non-react-statics'\n\nconst hoistStatics = (higherOrderComponent, blacklist) => BaseComponent => {\n  const NewComponent = higherOrderComponent(BaseComponent)\n  hoistNonReactStatics(NewComponent, BaseComponent, blacklist)\n  return NewComponent\n}\n\nexport default hoistStatics\n"
  },
  {
    "path": "src/packages/recompose/index.js",
    "content": "// Higher-order component helpers\nexport { default as mapProps } from './mapProps'\nexport { default as withProps } from './withProps'\nexport { default as withPropsOnChange } from './withPropsOnChange'\nexport { default as withHandlers } from './withHandlers'\nexport { default as defaultProps } from './defaultProps'\nexport { default as renameProp } from './renameProp'\nexport { default as renameProps } from './renameProps'\nexport { default as flattenProp } from './flattenProp'\nexport { default as withState } from './withState'\nexport { default as withStateHandlers } from './withStateHandlers'\nexport { default as withReducer } from './withReducer'\nexport { default as branch } from './branch'\nexport { default as renderComponent } from './renderComponent'\nexport { default as renderNothing } from './renderNothing'\nexport { default as shouldUpdate } from './shouldUpdate'\nexport { default as pure } from './pure'\nexport { default as onlyUpdateForKeys } from './onlyUpdateForKeys'\nexport { default as onlyUpdateForPropTypes } from './onlyUpdateForPropTypes'\nexport { default as withContext } from './withContext'\nexport { default as getContext } from './getContext'\nexport { default as lifecycle } from './lifecycle'\nexport { default as toClass } from './toClass'\nexport { default as toRenderProps } from './toRenderProps'\nexport { default as fromRenderProps } from './fromRenderProps'\n\n// Static property helpers\nexport { default as setStatic } from './setStatic'\nexport { default as setPropTypes } from './setPropTypes'\nexport { default as setDisplayName } from './setDisplayName'\n\n// Composition function\nexport { default as compose } from './compose'\n\n// Other utils\nexport { default as getDisplayName } from './getDisplayName'\nexport { default as wrapDisplayName } from './wrapDisplayName'\nexport { default as shallowEqual } from './shallowEqual'\nexport { default as isClassComponent } from './isClassComponent'\nexport { default as createSink } from './createSink'\nexport { default as componentFromProp } from './componentFromProp'\nexport { default as nest } from './nest'\nexport { default as hoistStatics } from './hoistStatics'\n\n// Observable helpers\nexport {\n  default as componentFromStream,\n  componentFromStreamWithConfig,\n} from './componentFromStream'\nexport {\n  default as mapPropsStream,\n  mapPropsStreamWithConfig,\n} from './mapPropsStream'\nexport {\n  default as createEventHandler,\n  createEventHandlerWithConfig,\n} from './createEventHandler'\nexport { default as setObservableConfig } from './setObservableConfig'\n"
  },
  {
    "path": "src/packages/recompose/index.js.flow",
    "content": "/* eslint-disable */\n\n/* @flow strict */\n\n/**\n * 1) Types give additional constraint on a language, recompose was written on the untyped language\n * as a consequence of this fact\n * for some recompose HOCs is near impossible to add correct typings.\n * 2) flow sometimes does not work as expected.\n *\n *  So any help and suggestions will be very appreciated.\n *\n * -----------------------------------------------------------------------------------\n * Type definition of recompose HOCs are splitted into 2 parts,\n * \"HOCs with good flow support\" - in most cases you can use them without big issues,\n * see `test_${hocName}.js` for the idea.\n * Some known issues:\n * see test_mapProps.js - inference work but type errors are not detected in hocs\n *\n * SUPPORTED HOCs:\n * defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure,\n * onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange,\n * onlyUpdateForPropTypes, toClass, withContext, getContext,\n * setStatic, setPropTypes, setDisplayName,\n * -----------------------------------------------------------------------------------\n * \"TODO (UNSUPPORTED) HOCs\" - you need to provide type information\n * (no automatic type inference), voodoo dancing etc\n * see `test_voodoo.js` for the idea\n *\n * remember that:\n * flattenProp,renameProp, renameProps can easily be replaced with withProps\n * withReducer, withState -> use withStateHandlers instead\n * lifecycle -> you don't need recompose if you need a lifecycle, just use React class instead\n * mapPropsStream -> see test_mapPropsStream.js\n * -----------------------------------------------------------------------------------\n *\n * utils:\n * getDisplayName, wrapDisplayName, shallowEqual,\n * isClassComponent, createSink, componentFromProp,\n * nest, hoistStatics,\n */\n\n//-------------------\n\n// -----------------------------------------------------------------\n// Private declarations\n// -----------------------------------------------------------------\n\ndeclare type ExtractToVoid = <A, B, C, R>(\n  v: (a: A, b: B, c: C) => R\n) => (A, B, C) => void\n\ndeclare type ExtractStateHandlersCodomain = <State, Enhanced, V>(\n  v: (state: State, props: Enhanced) => V\n) => V\n\ndeclare type ExtractHandlersCodomain = <Enhanced, V>(\n  v: (props: Enhanced) => V\n) => V\n\ndeclare type UnaryFn<A, R> = (a: A) => R\n\n// -----------------------------------------------------------------\n// Public declarations\n// -----------------------------------------------------------------\n\nexport type Component<A> = React$ComponentType<A>\n\nexport type HOC<Base, Enhanced> = UnaryFn<Component<Base>, Component<Enhanced>>\n\ndeclare export var compose: $Compose\n\n// ---------------------------------------------------------------------------\n// ----------------===<<<HOCs with good flow support>>>===--------------------\n// ---------------------------------------------------------------------------\n\ndeclare export function defaultProps<Default, Enhanced>(\n  defProps: Default\n): HOC<{ ...$Exact<Enhanced>, ...Default }, Enhanced>\n\ndeclare export function mapProps<Base, Enhanced>(\n  propsMapper: (ownerProps: Enhanced) => Base\n): HOC<Base, Enhanced>\n\ndeclare export function withProps<BaseAdd, Enhanced>(\n  propsMapper: ((ownerProps: Enhanced) => BaseAdd) | BaseAdd\n): HOC<{ ...$Exact<Enhanced>, ...BaseAdd }, Enhanced>\n\ndeclare export function withStateHandlers<\n  State,\n  Enhanced,\n  StateHandlers: {\n    [key: string]: (\n      state: State,\n      props: Enhanced\n    ) => (...payload: any[]) => $Shape<State>,\n  }\n>(\n  initialState: ((props: Enhanced) => State) | State,\n  stateUpdaters: StateHandlers\n): HOC<\n  {\n    ...$Exact<Enhanced>,\n    ...$Exact<State>,\n    ...$ObjMap<\n      $ObjMap<StateHandlers, ExtractStateHandlersCodomain>,\n      ExtractToVoid\n    >,\n  },\n  Enhanced\n>\n\ndeclare export function withHandlers<\n  Enhanced,\n  Handlers:\n    | ((\n        props: Enhanced\n      ) => {\n        [key: string]: (props: Enhanced) => Function,\n      })\n    | {\n        [key: string]: (props: Enhanced) => Function,\n      }\n>(\n  handlers: ((props: Enhanced) => Handlers) | Handlers\n): HOC<\n  {\n    ...$Exact<Enhanced>,\n    ...$ObjMap<Handlers, ExtractHandlersCodomain>,\n  },\n  Enhanced\n>\n\ndeclare export function pure<A>(a: Component<A>): Component<A>\ndeclare export function onlyUpdateForPropTypes<A>(a: Component<A>): Component<A>\ndeclare export function onlyUpdateForKeys<A>(Array<$Keys<A>>): HOC<A, A>\ndeclare export function shouldUpdate<A>(\n  (props: A, nextProps: A) => boolean\n): HOC<A, A>\n\ndeclare export function toClass<A>(a: Component<A>): Component<A>\n\ndeclare export function withContext<A, ContextPropTypes, ContextObj>(\n  childContextTypes: ContextPropTypes,\n  getChildContext: (props: A) => ContextObj\n): HOC<A, A>\n\ndeclare export function getContext<CtxTypes, Enhanced>(\n  contextTypes: CtxTypes\n): HOC<{ ...$Exact<Enhanced>, ...CtxTypes }, Enhanced>\n\n/**\n * It's wrong declaration but having that renderNothing and renderComponent are somehow useless\n * outside branch enhancer, we just give it an id type\n * so common way of using branch like\n * `branch(testFn, renderNothing | renderComponent(Comp))` will work as expected.\n * Tests are placed at test_branch.\n */\ndeclare export function renderNothing<A>(C: Component<A>): Component<A>\ndeclare export function renderComponent<A>(a: Component<A>): HOC<A, A>\n\n/**\n * We make an assumtion that left and right have the same type if exists\n */\ndeclare export function branch<Base, Enhanced>(\n  testFn: (props: Enhanced) => boolean,\n  // not a HOC because of inference problems, this works but HOC<Base, Enhanced> is not\n  left: (Component<Base>) => Component<Enhanced>,\n  // I never use right part and it can be a problem with inference as should be same type as left\n  right?: (Component<Base>) => Component<Enhanced>\n): HOC<Base, Enhanced>\n\n// test_statics\ndeclare export function setStatic<A>(key: string, value: any): HOC<A, A>\ndeclare export function setPropTypes<A>(propTypes: Object): HOC<A, A>\ndeclare export function setDisplayName<A>(displayName: string): HOC<A, A>\n\ndeclare export function withPropsOnChange<BaseAdd, Enhanced>(\n  shouldMapOrKeys:\n    | ((props: Enhanced, nextProps: Enhanced) => boolean)\n    | Array<$Keys<Enhanced>>,\n  propsMapper: (ownerProps: Enhanced) => BaseAdd\n): HOC<{ ...$Exact<Enhanced>, ...BaseAdd }, Enhanced>\n\n// ---------------------------------------------------------------------------\n// ----------------===<<<TODO (UNSUPPORTED) HOCs>>>===------------------------\n// ---------------------------------------------------------------------------\n\n// use withProps instead\ndeclare export function flattenProp<Base, Enhanced>(\n  propName: $Keys<Enhanced>\n): HOC<Base, Enhanced>\n\n// use withProps instead\ndeclare export function renameProp<Base, Enhanced>(\n  oldName: $Keys<Enhanced>,\n  newName: $Keys<Base>\n): HOC<Base, Enhanced>\n\n// use withProps instead\ndeclare export function renameProps<Base, Enhanced>(nameMap: {\n  [key: $Keys<Enhanced>]: $Keys<Base>,\n}): HOC<Base, Enhanced>\n\n// use withStateHandlers instead\ndeclare export function withState<Base, Enhanced, T>(\n  stateName: string,\n  stateUpdaterName: string,\n  initialState: T | ((props: Enhanced) => T)\n): HOC<Base, Enhanced>\n\n// use withStateHandlers instead\ndeclare export function withReducer<A, B, Action, State>(\n  stateName: string,\n  dispatchName: string,\n  reducer: (state: State, action: Action) => State,\n  initialState: State\n): HOC<A, B>\n\n// lifecycle use React instead\ndeclare export function lifecycle<A, B>(spec: Object): HOC<A, B>\n\n// Help needed, as explicitly providing the type\n// errors not detected, see TODO at test_mapPropsStream.js\ndeclare export function mapPropsStream<Base, Enhanced>(\n  (props$: any) => any\n): HOC<Base, Enhanced>\n\n// ---------------------------------------------------------------------------\n// -----------------------------===<<<Utils>>>===-----------------------------\n// ---------------------------------------------------------------------------\n\ndeclare export function getDisplayName<A>(C: Component<A>): string\n\ndeclare export function wrapDisplayName<A>(\n  C: Component<A>,\n  wrapperName: string\n): string\n\ndeclare export function shallowEqual(objA: mixed, objB: mixed): boolean\n\ndeclare export function isClassComponent(value: any): boolean\n\ndeclare export function createSink<A>(\n  callback: (props: A) => void\n): Component<A>\n\ndeclare export function componentFromProp<A>(propName: string): Component<A>\n\ndeclare export function nest<A>(\n  ...Components: Array<Component<any> | string>\n): Component<A>\n\ndeclare export function hoistStatics<A, B, H: HOC<A, B>>(hoc: H): H\n\ndeclare export function componentFromStream<T>(\n  (props$: any) => any\n): T => React$Element<any>\n\ndeclare export function createEventHandler(): {\n  stream: any,\n  handler: Function,\n}\n\ndeclare export function toRenderProps<B, E>(\n  hoc: HOC<B, E>\n): React$ComponentType<{|\n  ...$Exact<E>,\n  children: (b: B) => React$Node,\n|}>\n\ndeclare export function fromRenderProps<B, E, RenderPropName, Props>(\n  RenderPropsComponent: Component<{\n    [RenderPropName]: (...props: Props) => React$Node,\n  }>,\n  propsMapper: ((...props: Props) => B),\n  renderPropName?: RenderPropName\n): HOC<{ ...$Exact<E>, ...B }, E>\n"
  },
  {
    "path": "src/packages/recompose/isClassComponent.js",
    "content": "const isClassComponent = Component =>\n  Boolean(\n    Component &&\n      Component.prototype &&\n      typeof Component.prototype.render === 'function'\n  )\n\nexport default isClassComponent\n"
  },
  {
    "path": "src/packages/recompose/kefirObservableConfig.js",
    "content": "import Kefir from 'kefir'\n\nconst config = {\n  fromESObservable: Kefir.fromESObservable,\n  toESObservable: stream => stream.toESObservable(),\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose/lifecycle.js",
    "content": "/* eslint-disable no-console */\nimport { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst lifecycle = spec => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n\n  if (process.env.NODE_ENV !== 'production' && spec.hasOwnProperty('render')) {\n    console.error(\n      'lifecycle() does not support the render method; its behavior is to ' +\n        'pass all props and state to the base component.'\n    )\n  }\n\n  class Lifecycle extends Component {\n    render() {\n      return factory({\n        ...this.props,\n        ...this.state,\n      })\n    }\n  }\n\n  Object.keys(spec).forEach(hook => (Lifecycle.prototype[hook] = spec[hook]))\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'lifecycle'))(\n      Lifecycle\n    )\n  }\n  return Lifecycle\n}\n\nexport default lifecycle\n"
  },
  {
    "path": "src/packages/recompose/mapProps.js",
    "content": "import { createFactory } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst mapProps = propsMapper => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  const MapProps = props => factory(propsMapper(props))\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'mapProps'))(MapProps)\n  }\n  return MapProps\n}\n\nexport default mapProps\n"
  },
  {
    "path": "src/packages/recompose/mapPropsStream.js",
    "content": "import { createFactory } from 'react'\nimport $$observable from 'symbol-observable'\nimport { componentFromStreamWithConfig } from './componentFromStream'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\nimport { config as globalConfig } from './setObservableConfig'\n\nconst identity = t => t\n\nexport const mapPropsStreamWithConfig = config => {\n  const componentFromStream = componentFromStreamWithConfig({\n    fromESObservable: identity,\n    toESObservable: identity,\n  })\n  return transform => BaseComponent => {\n    const factory = createFactory(BaseComponent)\n    const { fromESObservable, toESObservable } = config\n    return componentFromStream(props$ => ({\n      subscribe(observer) {\n        const subscription = toESObservable(\n          transform(fromESObservable(props$))\n        ).subscribe({\n          next: childProps => observer.next(factory(childProps)),\n        })\n        return {\n          unsubscribe: () => subscription.unsubscribe(),\n        }\n      },\n      [$$observable]() {\n        return this\n      },\n    }))\n  }\n}\n\nconst mapPropsStream = transform => {\n  const hoc = mapPropsStreamWithConfig(globalConfig)(transform)\n\n  if (process.env.NODE_ENV !== 'production') {\n    return BaseComponent =>\n      setDisplayName(wrapDisplayName(BaseComponent, 'mapPropsStream'))(\n        hoc(BaseComponent)\n      )\n  }\n  return hoc\n}\n\nexport default mapPropsStream\n"
  },
  {
    "path": "src/packages/recompose/mostObservableConfig.js",
    "content": "import { from, Stream } from 'most'\n\nconst config = {\n  fromESObservable: from || Stream.from,\n  toESObservable: stream => stream,\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose/nest.js",
    "content": "import { createFactory } from 'react'\nimport getDisplayName from './getDisplayName'\n\nconst nest = (...Components) => {\n  const factories = Components.map(createFactory)\n  const Nest = ({ children, ...props }) =>\n    factories.reduceRight((child, factory) => factory(props, child), children)\n\n  if (process.env.NODE_ENV !== 'production') {\n    const displayNames = Components.map(getDisplayName)\n    Nest.displayName = `nest(${displayNames.join(', ')})`\n  }\n\n  return Nest\n}\n\nexport default nest\n"
  },
  {
    "path": "src/packages/recompose/onlyUpdateForKeys.js",
    "content": "import shouldUpdate from './shouldUpdate'\nimport shallowEqual from './shallowEqual'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\nimport pick from './utils/pick'\n\nconst onlyUpdateForKeys = propKeys => {\n  const hoc = shouldUpdate(\n    (props, nextProps) =>\n      !shallowEqual(pick(nextProps, propKeys), pick(props, propKeys))\n  )\n\n  if (process.env.NODE_ENV !== 'production') {\n    return BaseComponent =>\n      setDisplayName(wrapDisplayName(BaseComponent, 'onlyUpdateForKeys'))(\n        hoc(BaseComponent)\n      )\n  }\n  return hoc\n}\n\nexport default onlyUpdateForKeys\n"
  },
  {
    "path": "src/packages/recompose/onlyUpdateForPropTypes.js",
    "content": "import onlyUpdateForKeys from './onlyUpdateForKeys'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\nimport getDisplayName from './getDisplayName'\n\nconst onlyUpdateForPropTypes = BaseComponent => {\n  const propTypes = BaseComponent.propTypes\n\n  if (process.env.NODE_ENV !== 'production') {\n    if (!propTypes) {\n      /* eslint-disable */\n      console.error(\n        'A component without any `propTypes` was passed to ' +\n          '`onlyUpdateForPropTypes()`. Check the implementation of the ' +\n          `component with display name \"${getDisplayName(BaseComponent)}\".`\n      )\n      /* eslint-enable */\n    }\n  }\n\n  const propKeys = Object.keys(propTypes || {})\n  const OnlyUpdateForPropTypes = onlyUpdateForKeys(propKeys)(BaseComponent)\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(\n      wrapDisplayName(BaseComponent, 'onlyUpdateForPropTypes')\n    )(OnlyUpdateForPropTypes)\n  }\n  return OnlyUpdateForPropTypes\n}\n\nexport default onlyUpdateForPropTypes\n"
  },
  {
    "path": "src/packages/recompose/package.json",
    "content": "{\n  \"description\": \"A React utility belt for function components and higher-order components\",\n  \"keywords\": [\n    \"react\",\n    \"higher-order\",\n    \"components\",\n    \"microcomponentization\",\n    \"toolkit\",\n    \"utilities\",\n    \"composition\"\n  ],\n  \"main\": \"dist/Recompose.cjs.js\",\n  \"module\": \"dist/Recompose.esm.js\",\n  \"dependencies\": {\n    \"@babel/runtime\": \"^7.0.0\",\n    \"change-emitter\": \"^0.1.2\",\n    \"hoist-non-react-statics\": \"^2.3.1\",\n    \"react-lifecycles-compat\": \"^3.0.2\",\n    \"symbol-observable\": \"^1.0.4\"\n  },\n  \"peerDependencies\": {\n    \"react\": \"^0.14.0 || ^15.0.0 || ^16.0.0\"\n  }\n}\n"
  },
  {
    "path": "src/packages/recompose/pure.js",
    "content": "import shouldUpdate from './shouldUpdate'\nimport shallowEqual from './shallowEqual'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst pure = BaseComponent => {\n  const hoc = shouldUpdate(\n    (props, nextProps) => !shallowEqual(props, nextProps)\n  )\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'pure'))(\n      hoc(BaseComponent)\n    )\n  }\n\n  return hoc(BaseComponent)\n}\n\nexport default pure\n"
  },
  {
    "path": "src/packages/recompose/renameProp.js",
    "content": "import omit from './utils/omit'\nimport mapProps from './mapProps'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst renameProp = (oldName, newName) => {\n  const hoc = mapProps(props => ({\n    ...omit(props, [oldName]),\n    [newName]: props[oldName],\n  }))\n  if (process.env.NODE_ENV !== 'production') {\n    return BaseComponent =>\n      setDisplayName(wrapDisplayName(BaseComponent, 'renameProp'))(\n        hoc(BaseComponent)\n      )\n  }\n  return hoc\n}\n\nexport default renameProp\n"
  },
  {
    "path": "src/packages/recompose/renameProps.js",
    "content": "import omit from './utils/omit'\nimport pick from './utils/pick'\nimport mapProps from './mapProps'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst { keys } = Object\n\nconst mapKeys = (obj, func) =>\n  keys(obj).reduce((result, key) => {\n    const val = obj[key]\n    /* eslint-disable no-param-reassign */\n    result[func(val, key)] = val\n    /* eslint-enable no-param-reassign */\n    return result\n  }, {})\n\nconst renameProps = nameMap => {\n  const hoc = mapProps(props => ({\n    ...omit(props, keys(nameMap)),\n    ...mapKeys(pick(props, keys(nameMap)), (_, oldName) => nameMap[oldName]),\n  }))\n  if (process.env.NODE_ENV !== 'production') {\n    return BaseComponent =>\n      setDisplayName(wrapDisplayName(BaseComponent, 'renameProps'))(\n        hoc(BaseComponent)\n      )\n  }\n  return hoc\n}\n\nexport default renameProps\n"
  },
  {
    "path": "src/packages/recompose/renderComponent.js",
    "content": "import { createFactory } from 'react'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst renderComponent = Component => _ => {\n  const factory = createFactory(Component)\n  const RenderComponent = props => factory(props)\n  if (process.env.NODE_ENV !== 'production') {\n    RenderComponent.displayName = wrapDisplayName(Component, 'renderComponent')\n  }\n  return RenderComponent\n}\n\nexport default renderComponent\n"
  },
  {
    "path": "src/packages/recompose/renderNothing.js",
    "content": "import { Component } from 'react'\n\nclass Nothing extends Component {\n  render() {\n    return null\n  }\n}\n\nconst renderNothing = _ => Nothing\n\nexport default renderNothing\n"
  },
  {
    "path": "src/packages/recompose/rxjs4ObservableConfig.js",
    "content": "import $$observable from 'symbol-observable'\nimport Rx from 'rx'\n\nconst config = {\n  fromESObservable: observable =>\n    Rx.Observable.create(observer => {\n      const { unsubscribe } = observable.subscribe({\n        next: val => observer.onNext(val),\n        error: error => observer.onError(error),\n        complete: () => observer.onCompleted(),\n      })\n      return unsubscribe\n    }),\n  toESObservable: rxObservable => ({\n    subscribe: observer => {\n      const subscription = rxObservable.subscribe(\n        val => observer.next(val),\n        error => observer.error(error),\n        () => observer.complete()\n      )\n      return { unsubscribe: () => subscription.dispose() }\n    },\n    [$$observable]() {\n      return this\n    },\n  }),\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose/rxjsObservableConfig.js",
    "content": "import Rx from 'rxjs'\n\nconst config = {\n  fromESObservable: Rx.Observable.from,\n  toESObservable: stream => stream,\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose/setDisplayName.js",
    "content": "import setStatic from './setStatic'\n\nconst setDisplayName = displayName => setStatic('displayName', displayName)\n\nexport default setDisplayName\n"
  },
  {
    "path": "src/packages/recompose/setObservableConfig.js",
    "content": "let _config = {\n  fromESObservable: null,\n  toESObservable: null,\n}\n\nconst configureObservable = c => {\n  _config = c\n}\n\nexport const config = {\n  fromESObservable: observable =>\n    typeof _config.fromESObservable === 'function'\n      ? _config.fromESObservable(observable)\n      : observable,\n  toESObservable: stream =>\n    typeof _config.toESObservable === 'function'\n      ? _config.toESObservable(stream)\n      : stream,\n}\n\nexport default configureObservable\n"
  },
  {
    "path": "src/packages/recompose/setPropTypes.js",
    "content": "import setStatic from './setStatic'\n\nconst setPropTypes = propTypes => setStatic('propTypes', propTypes)\n\nexport default setPropTypes\n"
  },
  {
    "path": "src/packages/recompose/setStatic.js",
    "content": "const setStatic = (key, value) => BaseComponent => {\n  /* eslint-disable no-param-reassign */\n  BaseComponent[key] = value\n  /* eslint-enable no-param-reassign */\n  return BaseComponent\n}\n\nexport default setStatic\n"
  },
  {
    "path": "src/packages/recompose/shallowEqual.js",
    "content": "/**\n * Copyright (c) 2013-present, Facebook, Inc.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n *\n * @providesModule shallowEqual\n * @typechecks\n */\n\n/* eslint-disable no-self-compare */\n\nconst hasOwnProperty = Object.prototype.hasOwnProperty\n\n/**\n * inlined Object.is polyfill to avoid requiring consumers ship their own\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is\n */\nfunction is(x, y) {\n  // SameValue algorithm\n  if (x === y) {\n    // Steps 1-5, 7-10\n    // Steps 6.b-6.e: +0 != -0\n    // Added the nonzero y check to make Flow happy, but it is redundant\n    return x !== 0 || y !== 0 || 1 / x === 1 / y\n  }\n  // Step 6.a: NaN == NaN\n  return x !== x && y !== y\n}\n\n/**\n * Performs equality by iterating through keys on an object and returning false\n * when any key has values which are not strictly equal between the arguments.\n * Returns true when the values of all keys are strictly equal.\n */\nfunction shallowEqual(objA, objB) {\n  if (is(objA, objB)) {\n    return true\n  }\n\n  if (\n    typeof objA !== 'object' ||\n    objA === null ||\n    typeof objB !== 'object' ||\n    objB === null\n  ) {\n    return false\n  }\n\n  const keysA = Object.keys(objA)\n  const keysB = Object.keys(objB)\n\n  if (keysA.length !== keysB.length) {\n    return false\n  }\n\n  // Test for A's keys different from B.\n  for (let i = 0; i < keysA.length; i++) {\n    if (\n      !hasOwnProperty.call(objB, keysA[i]) ||\n      !is(objA[keysA[i]], objB[keysA[i]])\n    ) {\n      return false\n    }\n  }\n\n  return true\n}\n\nexport default shallowEqual\n"
  },
  {
    "path": "src/packages/recompose/shouldUpdate.js",
    "content": "import { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst shouldUpdate = test => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  class ShouldUpdate extends Component {\n    shouldComponentUpdate(nextProps) {\n      return test(this.props, nextProps)\n    }\n\n    render() {\n      return factory(this.props)\n    }\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'shouldUpdate'))(\n      ShouldUpdate\n    )\n  }\n  return ShouldUpdate\n}\n\nexport default shouldUpdate\n"
  },
  {
    "path": "src/packages/recompose/toClass.js",
    "content": "import React, { Component } from 'react'\nimport getDisplayName from './getDisplayName'\nimport isClassComponent from './isClassComponent'\n\nconst toClass = baseComponent =>\n  isClassComponent(baseComponent)\n    ? baseComponent\n    : class ToClass extends Component {\n        static displayName = getDisplayName(baseComponent)\n        static propTypes = baseComponent.propTypes\n        static contextTypes = baseComponent.contextTypes\n        static defaultProps = baseComponent.defaultProps\n        render() {\n          if (typeof baseComponent === 'string') {\n            return React.createElement(baseComponent, this.props)\n          }\n          return baseComponent(this.props, this.context)\n        }\n      }\nexport default toClass\n"
  },
  {
    "path": "src/packages/recompose/toRenderProps.js",
    "content": "export default function toRenderProps(hoc) {\n  const RenderPropsComponent = props => props.children(props)\n  return hoc(RenderPropsComponent)\n}\n"
  },
  {
    "path": "src/packages/recompose/utils/mapValues.js",
    "content": "const mapValues = (obj, func) => {\n  const result = {}\n  /* eslint-disable no-restricted-syntax */\n  for (const key in obj) {\n    if (obj.hasOwnProperty(key)) {\n      result[key] = func(obj[key], key)\n    }\n  }\n  /* eslint-enable no-restricted-syntax */\n  return result\n}\n\nexport default mapValues\n"
  },
  {
    "path": "src/packages/recompose/utils/omit.js",
    "content": "const omit = (obj, keys) => {\n  const { ...rest } = obj\n  for (let i = 0; i < keys.length; i++) {\n    const key = keys[i]\n    if (rest.hasOwnProperty(key)) {\n      delete rest[key]\n    }\n  }\n  return rest\n}\n\nexport default omit\n"
  },
  {
    "path": "src/packages/recompose/utils/pick.js",
    "content": "const pick = (obj, keys) => {\n  const result = {}\n  for (let i = 0; i < keys.length; i++) {\n    const key = keys[i]\n    if (obj.hasOwnProperty(key)) {\n      result[key] = obj[key]\n    }\n  }\n  return result\n}\n\nexport default pick\n"
  },
  {
    "path": "src/packages/recompose/withContext.js",
    "content": "import { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst withContext = (childContextTypes, getChildContext) => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  class WithContext extends Component {\n    getChildContext = () => getChildContext(this.props)\n\n    render() {\n      return factory(this.props)\n    }\n  }\n\n  WithContext.childContextTypes = childContextTypes\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'withContext'))(\n      WithContext\n    )\n  }\n  return WithContext\n}\n\nexport default withContext\n"
  },
  {
    "path": "src/packages/recompose/withHandlers.js",
    "content": "/* eslint-disable no-console */\nimport { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\nimport mapValues from './utils/mapValues'\n\nconst withHandlers = handlers => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  class WithHandlers extends Component {\n    handlers = mapValues(\n      typeof handlers === 'function' ? handlers(this.props) : handlers,\n      createHandler => (...args) => {\n        const handler = createHandler(this.props)\n\n        if (\n          process.env.NODE_ENV !== 'production' &&\n          typeof handler !== 'function'\n        ) {\n          console.error(\n            // eslint-disable-line no-console\n            'withHandlers(): Expected a map of higher-order functions. ' +\n              'Refer to the docs for more info.'\n          )\n        }\n\n        return handler(...args)\n      }\n    )\n\n    render() {\n      return factory({\n        ...this.props,\n        ...this.handlers,\n      })\n    }\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'withHandlers'))(\n      WithHandlers\n    )\n  }\n  return WithHandlers\n}\n\nexport default withHandlers\n"
  },
  {
    "path": "src/packages/recompose/withProps.js",
    "content": "import wrapDisplayName from './wrapDisplayName'\nimport setDisplayName from './setDisplayName'\nimport mapProps from './mapProps'\n\nconst withProps = input => {\n  const hoc = mapProps(props => ({\n    ...props,\n    ...(typeof input === 'function' ? input(props) : input),\n  }))\n  if (process.env.NODE_ENV !== 'production') {\n    return BaseComponent =>\n      setDisplayName(wrapDisplayName(BaseComponent, 'withProps'))(\n        hoc(BaseComponent)\n      )\n  }\n  return hoc\n}\n\nexport default withProps\n"
  },
  {
    "path": "src/packages/recompose/withPropsOnChange.js",
    "content": "import { createFactory, Component } from 'react'\nimport { polyfill } from 'react-lifecycles-compat'\nimport pick from './utils/pick'\nimport shallowEqual from './shallowEqual'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst withPropsOnChange = (shouldMapOrKeys, propsMapper) => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  const shouldMap =\n    typeof shouldMapOrKeys === 'function'\n      ? shouldMapOrKeys\n      : (props, nextProps) =>\n          !shallowEqual(\n            pick(props, shouldMapOrKeys),\n            pick(nextProps, shouldMapOrKeys)\n          )\n\n  class WithPropsOnChange extends Component {\n    state = {\n      computedProps: propsMapper(this.props),\n      prevProps: this.props,\n    }\n\n    static getDerivedStateFromProps(nextProps, prevState) {\n      if (shouldMap(prevState.prevProps, nextProps)) {\n        return {\n          computedProps: propsMapper(nextProps),\n          prevProps: nextProps,\n        }\n      }\n\n      return {\n        prevProps: nextProps,\n      }\n    }\n\n    render() {\n      return factory({\n        ...this.props,\n        ...this.state.computedProps,\n      })\n    }\n  }\n\n  polyfill(WithPropsOnChange)\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'withPropsOnChange'))(\n      WithPropsOnChange\n    )\n  }\n\n  return WithPropsOnChange\n}\n\nexport default withPropsOnChange\n"
  },
  {
    "path": "src/packages/recompose/withReducer.js",
    "content": "import { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst noop = () => {}\n\nconst withReducer = (\n  stateName,\n  dispatchName,\n  reducer,\n  initialState\n) => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  class WithReducer extends Component {\n    state = {\n      stateValue: this.initializeStateValue(),\n    }\n\n    initializeStateValue() {\n      if (initialState !== undefined) {\n        return typeof initialState === 'function'\n          ? initialState(this.props)\n          : initialState\n      }\n      return reducer(undefined, { type: '@@recompose/INIT' })\n    }\n\n    dispatch = (action, callback = noop) =>\n      this.setState(\n        ({ stateValue }) => ({\n          stateValue: reducer(stateValue, action),\n        }),\n        () => callback(this.state.stateValue)\n      )\n\n    render() {\n      return factory({\n        ...this.props,\n        [stateName]: this.state.stateValue,\n        [dispatchName]: this.dispatch,\n      })\n    }\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'withReducer'))(\n      WithReducer\n    )\n  }\n  return WithReducer\n}\n\nexport default withReducer\n"
  },
  {
    "path": "src/packages/recompose/withState.js",
    "content": "import { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\n\nconst withState = (\n  stateName,\n  stateUpdaterName,\n  initialState\n) => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n  class WithState extends Component {\n    state = {\n      stateValue:\n        typeof initialState === 'function'\n          ? initialState(this.props)\n          : initialState,\n    }\n\n    updateStateValue = (updateFn, callback) =>\n      this.setState(\n        ({ stateValue }) => ({\n          stateValue:\n            typeof updateFn === 'function' ? updateFn(stateValue) : updateFn,\n        }),\n        callback\n      )\n\n    render() {\n      return factory({\n        ...this.props,\n        [stateName]: this.state.stateValue,\n        [stateUpdaterName]: this.updateStateValue,\n      })\n    }\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'withState'))(\n      WithState\n    )\n  }\n  return WithState\n}\n\nexport default withState\n"
  },
  {
    "path": "src/packages/recompose/withStateHandlers.js",
    "content": "import { createFactory, Component } from 'react'\nimport setDisplayName from './setDisplayName'\nimport wrapDisplayName from './wrapDisplayName'\nimport mapValues from './utils/mapValues'\n\nconst withStateHandlers = (initialState, stateUpdaters) => BaseComponent => {\n  const factory = createFactory(BaseComponent)\n\n  class WithStateHandlers extends Component {\n    state = typeof initialState === 'function'\n      ? initialState(this.props)\n      : initialState\n\n    stateUpdaters = mapValues(\n      stateUpdaters,\n      handler => (mayBeEvent, ...args) => {\n        // Having that functional form of setState can be called async\n        // we need to persist SyntheticEvent\n        if (mayBeEvent && typeof mayBeEvent.persist === 'function') {\n          mayBeEvent.persist()\n        }\n\n        this.setState((state, props) =>\n          handler(state, props)(mayBeEvent, ...args)\n        )\n      }\n    )\n\n    render() {\n      return factory({\n        ...this.props,\n        ...this.state,\n        ...this.stateUpdaters,\n      })\n    }\n  }\n\n  if (process.env.NODE_ENV !== 'production') {\n    return setDisplayName(wrapDisplayName(BaseComponent, 'withStateHandlers'))(\n      WithStateHandlers\n    )\n  }\n  return WithStateHandlers\n}\n\nexport default withStateHandlers\n"
  },
  {
    "path": "src/packages/recompose/wrapDisplayName.js",
    "content": "import getDisplayName from './getDisplayName'\n\nconst wrapDisplayName = (BaseComponent, hocName) =>\n  `${hocName}(${getDisplayName(BaseComponent)})`\n\nexport default wrapDisplayName\n"
  },
  {
    "path": "src/packages/recompose/xstreamObservableConfig.js",
    "content": "import $$observable from 'symbol-observable'\nimport xstream from 'xstream'\n\nconst noop = () => {}\n\nconst config = {\n  fromESObservable: observable =>\n    xstream.create({\n      subscription: null,\n      start(listener) {\n        this.subscription = observable.subscribe(listener)\n      },\n      stop() {\n        this.subscription.unsubscribe()\n      },\n    }),\n  toESObservable: stream => ({\n    subscribe: observer => {\n      const listener = {\n        next: observer.next || noop,\n        error: observer.error || noop,\n        complete: observer.complete || noop,\n      }\n      stream.addListener(listener)\n      return {\n        unsubscribe: () => stream.removeListener(listener),\n      }\n    },\n    [$$observable]() {\n      return this\n    },\n  }),\n}\n\nexport default config\n"
  },
  {
    "path": "src/packages/recompose-relay/.npmignore",
    "content": "/**/__tests__\n"
  },
  {
    "path": "src/packages/recompose-relay/README.md",
    "content": "recompose-relay\n===============\n\n[![npm version](https://img.shields.io/npm/v/recompose-relay.svg?style=flat-square)](https://www.npmjs.com/package/recompose-relay)\n\n[Recompose](https://github.com/acdlite/recompose) helpers for [Relay](https://facebook.github.io/relay).\n\n```\nnpm install --save recompose-relay\n```\n\n## API\n\n### `createContainer()`\n\n```js\ncreateContainer(\n  specification: Object,\n  BaseComponent: ReactElementType\n): ReactElementType\n```\n\nA curried, component-last version of `Relay.createContainer()`. This makes it composable with other Recompose helpers.\n\nIf the base component is not a class component, it is converted to one using `toClass()`. This allows Relay to add a ref to the base component without causing React to print a warning. (Function components cannot have refs.) This behavior will be removed once Relay updates to support function components.\n\nTip: Use `flattenProp()` in combination with `createContainer()` to flatten fragment props:\n\n```js\nconst Post = compose(\n  createContainer({\n    fragments: {\n      post: () => Relay.QL`\n        fragment on Post {\n          title,\n          content,\n          author {\n            name\n          }\n        }\n      `\n    }\n  }),\n  flattenProp('post')\n)(({ title, content, author }) => (\n  <article>\n    <h1>{title}</h1>\n    <h2>By {author.name}</h2>\n    <div>{content}</div>\n  </article>\n));\n```\n"
  },
  {
    "path": "src/packages/recompose-relay/VERSION",
    "content": "0.3.1\n"
  },
  {
    "path": "src/packages/recompose-relay/createContainer.js",
    "content": "import Relay from 'react-relay'\nimport { toClass } from 'recompose'\n\nconst createContainer = options => BaseComponent =>\n  Relay.createContainer(toClass(BaseComponent), options)\n\nexport default createContainer\n"
  },
  {
    "path": "src/packages/recompose-relay/index.js",
    "content": "export { default as createContainer } from './createContainer'\n"
  },
  {
    "path": "src/packages/recompose-relay/package.json",
    "content": "{\n  \"description\": \"Recompose helpers for Relay.\",\n  \"scripts\": {\n    \"update-schema\": \"node -r babel-core/register updateSchema.js\"\n  },\n  \"keywords\": [\n    \"recompose\",\n    \"relay\",\n    \"react\",\n    \"higher-order\",\n    \"components\",\n    \"microcomponentization\",\n    \"toolkit\",\n    \"utilities\",\n    \"composition\"\n  ],\n  \"main\": \"cjs/RecomposeRelay.js\",\n  \"module\": \"es/RecomposeRelay.js\",\n  \"dependencies\": {\n    \"lodash\": \"^4.0.0\"\n  },\n  \"peerDependencies\": {\n    \"recompose\": \"^0.17.0 || ^0.18.0 || ^0.19.0 || ^0.20.0\",\n    \"react\": \"^0.14.0 || ^15.0.0\",\n    \"react-relay\": \"^0.6.0 || ^0.7.0 || ^0.8.0 || ^0.9.0\"\n  }\n}\n"
  },
  {
    "path": "types/README.md",
    "content": "# Flow support for recompose\n\n## How it works\n\nIn most cases all you need is to declare a props type of enhanced Component.\nFlow will infer all other types you need.\n\nExample:\n\n```javascript\nimport type { HOC } from 'recompose';\n\ntype EnhancedComponentProps = {\n  text?: string,\n};\n\nconst baseComponent = ({ text }) => <div>{text}</div>;\n\nconst enhance:HOC<*, EnhancedComponentProps> = compose(\n  defaultProps({\n    text: 'world',\n  }),\n  withProps(({ text }) => ({\n    text: `Hello ${text}`\n  }))\n);\n\nexport default enhance(baseComponent);\n\n```\n\nSee it in action.\n\n![recompose-flow](https://user-images.githubusercontent.com/5077042/28116959-0c96ae2c-6714-11e7-930e-b1454c629908.gif)\n\n## How to start\n\nThe easiest way is to start from example.\n\nLook at [this](http://grader-meets-16837.netlify.com/) app [source](./flow-example)\n\nLook at [library definitions and tests](./flow-typed/recompose_v0.24.x-/flow_v0.49.x-)\n\nTo add into project you can download library definitions [here](./flow-typed/recompose_v0.24.x/flow_v0.53.x-/recompose_v0.24.x.js) and add a path to it into `[lib]` section of `.flowconfig`.\n\nOr use [flow-typed](https://github.com/flowtype/flow-typed)\n\n```bash\nflow-typed install recompose@0.24.x\n```\n\n## Support\n\nType definitions of recompose HOCs are splitted into 2 parts.\n\n### Part 1 - HOCs with good flow support\n\nIn most cases you can use them without big issues.\nType inference and errors detection works near well.\n\nThese HOCs are: *defaultProps, mapProps, withProps, withStateHandlers, withHandlers, pure, onlyUpdateForKeys, shouldUpdate, renderNothing, renderComponent, branch, withPropsOnChange, onlyUpdateForPropTypes, toClass, withContext, getContext, setStatic, setPropTypes, setDisplayName*\n\n#### Known issues for \"good\" HOCs\n\nsee `test_mapProps.js` - inference work but type errors are not detected in hocs\n\n### Part 2 - other HOCs\n\nTo use these HOCs - you need to provide type information (no automatic type inference).\nYou must be a good voodoo dancer.\n\nSee `test_voodoo.js` for the idea.\n\nSome recomendations:\n\n- *flattenProp,renameProp, renameProps* can easily be replaced with _withProps_\n- *withReducer, withState* -> use _withStateHandlers_ instead\n- _lifecycle_ -> you don't need recompose if you need a _lifecycle_, just use React class instead\n- _mapPropsStream_ -> see `test_mapPropsStream.js`\n\n#### Known issues for above HOCs\n\nSee `test_voodoo.js`, `test_mapPropsStream.js`\n\n### Utils\n\n*getDisplayName, wrapDisplayName, shallowEqual,isClassComponent, createSink, componentFromProp, nest, hoistStatics.*\n\n### Articles \n\n[Typing Higher-order Components in Recompose With Flow](https://medium.com/flow-type/flow-support-in-recompose-1b76f58f4cfc)\n\n### Faq\n\nWhy to use existential type with `HOC<*, Blbla>` isn't it possible to avoid this?\n\n*I tried to use type alias but haven't found how to make it work.*\n\n## Thanks\n\nBig thanks to [@gcanti](https://github.com/gcanti) for his work on PR [#241](https://github.com/acdlite/recompose/pull/241), it was nice and clear base for current definitions.\n"
  },
  {
    "path": "types/flow-example/.eslintrc",
    "content": "{\n  \"extends\": \"react-app\"\n}\n"
  },
  {
    "path": "types/flow-example/.flowconfig",
    "content": "[ignore]\n.*/node_modules/eslint-plugin-jsx-a11y/.*\n# TODO: remove after react-motion will be updated with new flow typedefs\n.*/node_modules/react-motion/lib/*\n\n[include]\n\n[libs]\n../flow-typed/recompose_v0.24.x/flow_v0.55.x-/recompose_v0.24.x.js\n\n[options]\nsuppress_comment=\\\\(.\\\\|\\n\\\\)*\\\\$ExpectError\n\n[lints]\n"
  },
  {
    "path": "types/flow-example/.gitignore",
    "content": "# See https://help.github.com/ignore-files/ for more about ignoring files.\n\n# dependencies\n/node_modules\n\n# testing\n/coverage\n\n# production\n/build\n\n# misc\n.DS_Store\n.env.local\n.env.development.local\n.env.test.local\n.env.production.local\n\nnpm-debug.log*\nyarn-debug.log*\nyarn-error.log*\n"
  },
  {
    "path": "types/flow-example/README.md",
    "content": "# recompose with flow usage example\n\nThis project was bootstrapped with [Create React App](https://github.com/facebookincubator/create-react-app).\n"
  },
  {
    "path": "types/flow-example/flow-typed/glamor.js",
    "content": "declare module 'glamor' {\n  declare type CSSF = (...style: Object[]) => Object\n  declare type CSS = {\n    insert: (css: string) => void,\n    // hack https://github.com/facebook/flow/issues/2966\n    $call: (...style: Object[]) => Object,\n  }\n\n  declare export var css: CSS\n}\n"
  },
  {
    "path": "types/flow-example/flow-typed/react-motion.js",
    "content": "// TODO: remove after react-motion will be updated with new flow typedefs\ndeclare module 'react-motion' {\n  declare export function spring<A>(\n    val: number,\n    config?: A\n  ): { val: number, ...$Exact<A> }\n\n  declare export var TransitionMotion: React$ComponentType<{ styles: any }>\n}\n"
  },
  {
    "path": "types/flow-example/package.json",
    "content": "{\n  \"name\": \"coolmenu\",\n  \"version\": \"0.1.0\",\n  \"private\": true,\n  \"dependencies\": {\n    \"change-emitter\": \"^0.1.6\",\n    \"flow\": \"^0.2.3\",\n    \"flow-bin\": \"^0.55.0\",\n    \"glamor\": \"^3.0.0-3\",\n    \"glamor-reset\": \"^3.0.0-2\",\n    \"hoist-non-react-statics\": \"^2.0.0\",\n    \"react\": \"^15.6.1\",\n    \"react-dom\": \"^15.6.1\",\n    \"react-motion\": \"^0.5.0\",\n    \"recompose\": \"^0.24.0\"\n  },\n  \"devDependencies\": {\n    \"react-scripts\": \"1.0.10\"\n  },\n  \"scripts\": {\n    \"start\": \"react-scripts start\",\n    \"build\": \"react-scripts build\",\n    \"flow\": \"flow\"\n  }\n}\n"
  },
  {
    "path": "types/flow-example/public/index.html",
    "content": "<!doctype html>\n<html lang=\"en\">\n\n<head>\n  <meta charset=\"utf-8\">\n  <meta name=\"viewport\" content=\"width=device-width, initial-scale=1, shrink-to-fit=no\">\n  <meta name=\"theme-color\" content=\"#000000\">\n  <!--\n      manifest.json provides metadata used when your web app is added to the\n      homescreen on Android. See https://developers.google.com/web/fundamentals/engage-and-retain/web-app-manifest/\n    -->\n  <link rel=\"manifest\" href=\"%PUBLIC_URL%/manifest.json\">\n  <link rel=\"shortcut icon\" href=\"%PUBLIC_URL%/favicon.ico\">\n  <!--\n      Notice the use of %PUBLIC_URL% in the tags above.\n      It will be replaced with the URL of the `public` folder during the build.\n      Only files inside the `public` folder can be referenced from the HTML.\n\n      Unlike \"/favicon.ico\" or \"favicon.ico\", \"%PUBLIC_URL%/favicon.ico\" will\n      work correctly both with client-side routing and a non-root public URL.\n      Learn how to configure a non-root public URL by running `npm run build`.\n    -->\n  <title>Recompose coolmenu</title>\n</head>\n\n<body>\n  <noscript>\n    You need to enable JavaScript to run this app.\n  </noscript>\n  <div id=\"root\"></div>\n  <!--\n      This HTML file is a template.\n      If you open it directly in the browser, you will see an empty page.\n\n      You can add webfonts, meta tags, or analytics to this file.\n      The build step will place the bundled scripts into the <body> tag.\n\n      To begin the development, run `npm start` or `yarn start`.\n      To create a production bundle, use `npm run build` or `yarn build`.\n    -->\n</body>\n\n</html>"
  },
  {
    "path": "types/flow-example/public/manifest.json",
    "content": "{\n  \"short_name\": \"React App\",\n  \"name\": \"Create React App Sample\",\n  \"icons\": [\n    {\n      \"src\": \"favicon.ico\",\n      \"sizes\": \"192x192\",\n      \"type\": \"image/png\"\n    }\n  ],\n  \"start_url\": \"./index.html\",\n  \"display\": \"standalone\",\n  \"theme_color\": \"#000000\",\n  \"background_color\": \"#ffffff\"\n}\n"
  },
  {
    "path": "types/flow-example/src/App.js",
    "content": "/* @flow */\nimport React from 'react'\nimport { css } from 'glamor'\nimport { compose, defaultProps } from 'recompose'\nimport MouseDetector from './MouseDetector'\nimport ItemsAnimator from './ItemsAnimator'\nimport type { HOC } from 'recompose'\nimport type { MousePosition } from './MouseDetector'\n\n// Enhanced component props type\ntype AppProps = {}\n\nconst app = ({ styles, items }) =>\n  <div {...styles.app}>\n    <div {...styles.header}>\n      <a href={'https://github.com/acdlite/recompose/types/flow-example'}>\n        Coolmenu\n      </a>{' '}\n      <span>recompose flow typed example</span>\n    </div>\n    <div {...styles.content}>\n      <MouseDetector>\n        {({ x, y }: MousePosition) =>\n          <ItemsAnimator items={items} spacing={-10} mousePos={{ x, y }} />}\n      </MouseDetector>\n    </div>\n    <div {...styles.footer}>\n      <span>created by</span>{' '}\n      <a href={'https://github.com/istarkov'}>Ivan Starkov</a>\n    </div>\n  </div>\n\nconst appEnhancer: HOC<*, AppProps> = compose(\n  defaultProps({\n    items: [\n      { id: 1, title: 'Recompose', color: '#FFB02E' },\n      { id: 2, title: 'Has', color: '#FFB02E' },\n      { id: 3, title: 'Flow', color: '#FFB02E' },\n      { id: 4, title: 'Support', color: '#FFB02E' },\n      { id: 5, title: 'Now!', color: '#FFB02E' },\n    ],\n    styles: {\n      app: css({\n        display: 'flex',\n        flex: 1,\n        flexDirection: 'column',\n      }),\n      header: css({\n        padding: '1rem 5rem',\n        borderBottom: '1px solid rgba(255,255,255,0.2)',\n        fontSize: '1.2rem',\n        backgroundColor: 'rgba(0,0,0,0.05)',\n        '>SPAN': {\n          fontSize: '0.8rem',\n        },\n        '>A': {\n          color: '#CCCCFF',\n          textDecoration: 'none',\n        },\n      }),\n      content: css({\n        display: 'flex',\n        flex: 1,\n        alignItems: 'center',\n        justifyContent: 'center',\n      }),\n      footer: css({\n        padding: '0.5rem 5rem',\n        marginTop: 'auto',\n        borderTop: '1px solid rgba(255,255,255,0.2)',\n        backgroundColor: 'rgba(0,0,0,0.05)',\n        textAlign: 'right',\n        '>SPAN': {\n          fontSize: '0.8rem',\n        },\n        '>A': {\n          color: '#CCCCFF',\n          textDecoration: 'none',\n        },\n      }),\n    },\n  })\n)\n\nexport default appEnhancer(app)\n"
  },
  {
    "path": "types/flow-example/src/Item.js",
    "content": "/* @flow */\n\nimport React from 'react'\nimport { css } from 'glamor'\nimport { compose, defaultProps, withProps, withPropsOnChange } from 'recompose'\nimport type { HOC } from 'recompose'\n\n// Props type of enhanced component\n// It's the only props type we need to declare using supporting recompose enhancers\ntype ItemProps = {\n  title: string,\n  styles?: {\n    component: Object,\n    title: Object,\n    border: Object,\n  },\n  size?: number,\n  x?: number,\n  y?: number,\n  borderCount?: number,\n  hovered?: boolean,\n  color?: string,\n  textColor?: string,\n  hoveredColor?: string,\n}\n\nconst item = ({ title, componentDynamicStyle, styles, borders }) =>\n  <div {...styles.component} style={componentDynamicStyle}>\n    <div {...styles.title}>\n      {title}\n    </div>\n    {borders.map(({ style, id }) =>\n      <div key={id} style={style} {...styles.border} />\n    )}\n  </div>\n\n// set existential * type for base component,\n// flow is smart enough to infer base component and enhancers props types\nconst enhanceItem: HOC<*, ItemProps> = compose(\n  defaultProps({\n    title: '',\n    styles: {\n      component: css({\n        position: 'absolute',\n        display: 'flex',\n      }),\n      title: css({\n        margin: 'auto',\n        color: 'deeppink',\n        fontWeight: '600',\n      }),\n      border: css({\n        position: 'absolute',\n        border: '1px solid deeppink',\n        left: 0,\n        right: 0,\n        top: 0,\n        bottom: 0,\n        borderRadius: 5,\n        cursor: 'pointer',\n      }),\n    },\n    size: 100,\n    x: 0,\n    y: 0,\n    borderCount: 9,\n    borderK: 2,\n    hovered: false,\n    color: '#CCCCFF',\n    textColor: 'white',\n    hoveredColor: 'white',\n  }),\n  /**\n   * calculate css based on hovered prop\n   * better to use withProps as glamour uses class caching\n   * BTW it's flow example\n   */\n  withPropsOnChange(\n    ['hovered', 'styles', 'color', 'hoveredColor', 'textColor'],\n    ({ hovered, styles, color, textColor, hoveredColor }) => ({\n      styles: {\n        ...styles,\n        title: hovered\n          ? css(styles.title, { color: hoveredColor })\n          : css(styles.title, { color: textColor }),\n\n        border: hovered\n          ? css(styles.border, { borderColor: hoveredColor })\n          : css(styles.border, { borderColor: color }),\n      },\n    })\n  ),\n  /**\n   * calculate component dynamic style\n   */\n  withProps(({ size, x, y, hovered }) => ({\n    componentDynamicStyle: {\n      width: size,\n      height: size,\n      left: x - size / 2,\n      top: y - size / 2,\n      zIndex: hovered ? 1 : 0,\n    },\n  })),\n  /**\n   * generate borders props\n   */\n  withProps(({ borderCount, borderK }) => ({\n    borders: Array(borderCount).fill(0).map((_, index) => ({\n      id: index,\n      style: {\n        transform: `rotate(${borderK * Math.PI * index / borderCount}rad)`,\n        borderRadius: 5,\n      },\n    })),\n  }))\n)\n\nexport default enhanceItem(item)\n"
  },
  {
    "path": "types/flow-example/src/ItemsAnimator.js",
    "content": "/* @flow */\n\nimport React from 'react'\nimport { css } from 'glamor'\nimport { compose, defaultProps, withHandlers, withProps } from 'recompose'\nimport Item from './Item'\nimport { TransitionMotion, spring } from 'react-motion'\n// types\nimport type { HOC } from 'recompose'\nimport type { MousePosition } from './MouseDetector'\n\ntype ItemT = {\n  id: number,\n  title: string,\n  color?: string,\n}\n\n// Props type of enhanced component\n// It's the only props type we need to declare using supporting recompose enhancers\ntype ItemsAnimatorProps = {\n  items: Array<ItemT>,\n  config?: {\n    size: number,\n    hoverSize: number,\n    hoverRotation: number,\n    spacing: number,\n  },\n  mousePos: MousePosition,\n}\n\n// set existential * type for base component,\n// flow is smart enough to infer base component and enhancers props types\nconst itemsAnimator = ({ styles, animStyles }) =>\n  <TransitionMotion styles={animStyles}>\n    {(\n      interpolated: Array<{\n        key: string,\n        style: { x: number, y: number, size: number, borderK: number },\n        data: { ...$Exact<ItemT>, hovered: boolean },\n      }>\n    ) =>\n      <div {...styles.component}>\n        {interpolated.map(({ key, data, style }) =>\n          <Item\n            key={key}\n            color={data.color}\n            title={data.title}\n            size={style.size}\n            hovered={data.hovered}\n            x={style.x}\n            y={style.y}\n            borderK={style.borderK}\n          />\n        )}\n      </div>}\n  </TransitionMotion>\n\nconst enhanceItemsAnimator: HOC<*, ItemsAnimatorProps> = compose(\n  /**\n   * Defaults\n   */\n  defaultProps({\n    styles: {\n      component: css({\n        position: 'absolute',\n      }),\n    },\n    config: {\n      size: 110,\n      hoverSize: 150,\n      hoverRotation: 2 * Math.PI,\n      spacing: -10,\n    },\n    springConfig: {\n      stiffness: 170,\n      damping: 4,\n      precision: 0.001,\n    },\n  }),\n  /**\n   * Function to calculate items positions size and hover\n   * based on mouse position and previously hovered item\n   */\n  withHandlers(() => {\n    let hoveredItemId_ = -1\n\n    return {\n      getItemsViewProps: ({ mousePos, items, config }) => () => {\n        if (items.length === 0) return []\n\n        const itemMaxWidth = config.size * Math.sqrt(2)\n        const cIdx = (items.length - 1) / 2\n        const itemsD = items\n          .map((item, index) => ({\n            ...item,\n            size: hoveredItemId_ === item.id ? config.hoverSize : config.size,\n            x: (index - cIdx) * (itemMaxWidth + config.spacing),\n            y: 0,\n          }))\n          .map(item => ({\n            ...item,\n            x:\n              hoveredItemId_ === item.id\n                ? item.x + (mousePos.x - item.x) / 3\n                : item.x,\n            y:\n              hoveredItemId_ === item.id\n                ? item.y + (mousePos.y - item.y) / 3\n                : item.y,\n          }))\n          .map(item => ({\n            ...item,\n            distance:\n              Math.sqrt(\n                Math.pow(mousePos.x - item.x, 2) + Math.pow(mousePos.y, 2)\n              ) /\n              (item.size * Math.sqrt(2) / 2),\n          }))\n        const nearestItem = [...itemsD].sort(\n          (a, b) => a.distance - b.distance\n        )[0]\n\n        if (nearestItem && nearestItem.distance < 1) {\n          hoveredItemId_ = nearestItem.id\n          // console.log('nearestItem', nearestItem);\n        } else {\n          hoveredItemId_ = -1\n        }\n\n        return itemsD.map(item => ({\n          ...item,\n          hovered: item.id === hoveredItemId_,\n        }))\n      },\n    }\n  }),\n  /**\n   * Recalculate items positions, size, hover\n   */\n  withProps(({ getItemsViewProps }) => ({\n    items: getItemsViewProps(),\n  })),\n  /**\n   * Prepare data for react-motion\n   */\n  withProps(({ items, springConfig }) => ({\n    animStyles: items.map(item => ({\n      key: `${item.id}`,\n      data: item,\n      style: {\n        x: spring(item.x, springConfig),\n        y: spring(item.y, springConfig),\n        size: spring(item.size, springConfig),\n        borderK: spring(item.hovered ? 3 : 2, springConfig),\n      },\n    })),\n  }))\n)\n\nexport default enhanceItemsAnimator(itemsAnimator)\n"
  },
  {
    "path": "types/flow-example/src/MouseDetector.js",
    "content": "/* @flow */\nimport React from 'react'\nimport {\n  compose,\n  defaultProps,\n  withHandlers,\n  withProps,\n  withStateHandlers,\n} from 'recompose'\nimport { css } from 'glamor'\nimport type { HOC } from 'recompose'\n\n// shared type\nexport type MousePosition = { x: number, y: number }\n\n// Props type of enhanced component\n// It's the only props type we need to declare using supporting recompose enhancers\ntype EnhancedMouseDetectorProps = {\n  styles?: { component: Object },\n  children: (mousePos: MousePosition) => ?React$Element<any>,\n}\n\n// base component\nconst mouseDetector = ({ styles, registerChild, children, mousePos }) =>\n  <div ref={registerChild} {...styles.component}>\n    {children(mousePos)}\n  </div>\n\n// set existential * type for base component i.e. mouseDetector,\n// flow is smart enough to infer base component and enhancers props types\nconst enhanceMouseDetector: HOC<*, EnhancedMouseDetectorProps> = compose(\n  /**\n   * styles can be overwritten by parent component\n   */\n  defaultProps({\n    styles: {\n      component: css({\n        backgroundColor: 'red',\n        position: 'relative',\n        width: 0,\n        height: 0,\n      }),\n    },\n  }),\n  /**\n   * Component state and state handlers needed to calculate mouse position\n   * relative to current component\n   */\n  withStateHandlers(\n    // flow is smart enough to detect state type\n    { mousePos: { x: Infinity, y: Infinity }, offset: { x: 0, y: 0 } },\n    {\n      // flow infers state and props types but\n      // we need to declare type for handler argument i.e. x,y here\n      // otherwise type inference will not work for following enhancers\n      setMousePosition: (state, props) => (x: number, y: number) => ({\n        mousePos: { x, y },\n      }),\n      // the same as above, we need to declare arg type\n      setInitialOffsetYAndScrollY: () => (x: number, y: number) => ({\n        offset: {\n          x,\n          y,\n        },\n      }),\n    }\n  ),\n  /**\n   * withHandlers hack to intercept document events\n   */\n  withHandlers(() => {\n    let resizeHandler_\n    let mouseMoveHandler_\n\n    return {\n      // hovering on state updater functions gives you a type like\n      // Void<SomeFunctionType>, Void type helper transforms function result type to void\n      // See libdef and tests, I haven't found more prettier solution\n      registerChild: ({ setInitialOffsetYAndScrollY, setMousePosition }) => (\n        ref: ?HTMLDivElement\n      ) => {\n        // I have no idea why window has any type so this is not covered\n        const window: Node = document.defaultView\n\n        if (ref) {\n          // like ComponentDidMount if ref is not null\n          resizeHandler_ = () => {\n            if (!ref) return\n            const refRect = ref.getBoundingClientRect()\n\n            const docRect =\n              document.documentElement &&\n              document.documentElement.getBoundingClientRect()\n\n            if (docRect) {\n              // documentElement can be null so flow asks to check;\n              const offsetX = refRect.left - docRect.left\n              const offsetY = refRect.top - docRect.top\n\n              setInitialOffsetYAndScrollY(offsetX, offsetY)\n            }\n          }\n\n          // call initially to update state\n          resizeHandler_()\n\n          mouseMoveHandler_ = (evt: MouseEvent) =>\n            setMousePosition(evt.pageX, evt.pageY)\n\n          window.addEventListener('resize', resizeHandler_)\n          document.addEventListener('mousemove', mouseMoveHandler_)\n        } else {\n          // like ComponentWillUnmount if ref is null\n\n          if (resizeHandler_)\n            window.removeEventListener('resize', resizeHandler_)\n          if (mouseMoveHandler_)\n            document.removeEventListener('mousemove', mouseMoveHandler_)\n\n          resizeHandler_ = undefined\n          mouseMoveHandler_ = undefined\n        }\n      },\n    }\n  }),\n  /**\n   * convert mouse coordinates into local\n  */\n  withProps(({ mousePos, offset }) => ({\n    mousePos: {\n      x: mousePos.x - offset.x,\n      y: mousePos.y - offset.y,\n    },\n  }))\n)\n\nexport default enhanceMouseDetector(mouseDetector)\n"
  },
  {
    "path": "types/flow-example/src/index.js",
    "content": "/* @flow */\nimport React from 'react'\nimport ReactDOM from 'react-dom'\nimport App from './App'\nimport { css } from 'glamor'\nimport 'glamor-reset'\n\ncss.insert(`\n  body, html {\n    height: 100vh;\n    font-size: 16px;\n    color: #666;\n    -webkit-font-smoothing: antialiased;\n    background-color: indigo;\n  }\n`)\n\ncss.insert(`\n  * {\n    min-width: 0;\n    min-height: 0;\n    box-sizing: border-box;\n  }\n`)\n\ncss.insert(`\n  #root {\n    min-height: 100%; /* not 100 vh because of mobile chrome */\n    display: flex;\n  }\n`)\n\nconst mountNode = document.getElementById('root')\nReactDOM.render(<App />, mountNode)\n\nif (module.hot) {\n  ;((module.hot: any): {\n    accept: (a: string, b: () => void) => void,\n  }).accept('./App', () => {\n    const NextApp = require('./App').default // eslint-disable-line\n    ReactDOM.render(<NextApp />, mountNode)\n  })\n}\n"
  }
]