Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add link to related keep-func-props package #12

Merged
merged 1 commit into from
Mar 31, 2019
Merged

Add link to related keep-func-props package #12

merged 1 commit into from
Mar 31, 2019

Conversation

ehmicky
Copy link
Collaborator

@ehmicky ehmicky commented Feb 27, 2019

keep-func-props is a thin wrapper around mimic-fn for the common use case where the "mimicking" happens inside a function wrapper. E.g. for functional helpers like memoize or once.

Instead of:

const mimic = require('mimic-fn')
const memoize = require('lodash/memoize')

const anyFunction = function() { return true }

const memoizedFunction = memoize(anyFunction)
mimic(memoizedFunction, anyFunction)

One can do:

const keepFuncProps = require('keep-func-props')
const memoize = require('lodash/memoize')
const betterMemoize = keepFuncProps(memoize)

const anyFunction = function() { return true }

const memoizedFunction = betterMemoize(anyFunction)

`keep-func-props` is a thin wrapper around `mimic-fn` for the common use case where the "mimicking" happens inside a function wrapper.

E.g. for functional helpers like memoize or `once`.

Instead of:

```js
const mimic = require('mimic-fn')
const memoize = require('lodash/memoize')

const anyFunction = function() { return true }

const memoizedFunction = memoize(anyFunction)
mimic(memoizedFunction, anyFunction)
``` 

One can do:

```js
const keepFuncProps = require('keep-func-props')
const memoize = require('lodash/memoize')
const betterMemoize = keepFuncProps(memoize)

const anyFunction = function() { return true }

const memoizedFunction = betterMemoize(anyFunction)
```
@sindresorhus sindresorhus changed the title Add link to keep-func-props Add link to related keep-func-props package Mar 31, 2019
@sindresorhus sindresorhus merged commit 856cb8c into sindresorhus:master Mar 31, 2019
@ehmicky ehmicky deleted the patch-1 branch March 31, 2019 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants