.verb.md
# [{%= name %}][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url]
> {%= description %}
[![code climate][codeclimate-img]][codeclimate-url] [![standard code style][standard-img]][standard-url] [![travis build status][travis-img]][travis-url] [![coverage status][coveralls-img]][coveralls-url] [![dependency status][david-img]][david-url]
## Install
```
npm i {%= name %} --save
```
## How it works? Strategy. Name priority.
There's a couple of things that you **should be aware off and make your attention**, few scenarios - you can do few things with package like this - rename function, binding function with context and both together.
- Just rename given `fn` to have `name` instead of original name.
- Throw `TypeError` if given `fn` not a function.
- If only `fn` is given, it is returned without modifications - nothing done.
- If `fn` is given and falsey `name` (meaning non-string) - just returns the `fn` - nothing done.
- If `fn` is given and `name` is same as original name - just returns the `fn` - nothing done.
- If `fn`, `name` and `ctx` is given, and `name` is as original - returns function with `ctx` and same name.
- If `fn` and `ctx` is given, then function remains the same - only `ctx` is bound.
Meaning, this package try to follow native behaviours. Because you can't do such thing
```js
function zooparks () { return this }
var boundOne = renameFunction(zooparks, {foo: 'one'})
var boundTwo = renameFunction(boundOne, {foo: 'two'})
var boundZzz = renameFunction(boundTwo, {foo: 'zzz'})
console.log(boundZzz()) // => {foo: 'one'}
```
and expect `boundZzz()` to return `{foo: 'zzz'}`, it would be `{foo: 'one'}` always. It's still a bit strange even to me, because of use the thing that I call "smart binding" with which I tried to solve this problem and will continue. Kinda strange, when debugging it seems it shows expected results. But in other hand that's the native behaviour, see this one:
```js
function zooparks () { return this }
var boundOne = zooparks.bind({foo: 'one'})
var boundTwo = boundOne.bind({foo: 'two'})
var boundZzz = boundTwo.bind({foo: 'zzz'})
console.log(boundZzz()) // => {foo: 'one'}
```
## Usage
> For more use-cases see the [tests](./test.js)
```js
const {%= varname %} = require('{%= name %}')
```
{%= apidocs('index.js') %}
{% if (verb.related && verb.related.list && verb.related.list.length) { %}
## Related
{%= related(verb.related.list, {words: 12}) %}
{% } %}
## Contributing
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/{%= repository %}/issues/new).
But before doing anything, please read the [CONTRIBUTING.md](./CONTRIBUTING.md) guidelines.
## [Charlike Make Reagent](http://j.mp/1stW47C) [![new message to charlike][new-message-img]][new-message-url] [![freenode #charlike][freenode-img]][freenode-url]
[![{%= author.username %}.tk][author-www-img]][author-www-url] [![keybase {%= author.username %}][keybase-img]][keybase-url] [![{%= author.username %} npm][author-npm-img]][author-npm-url] [![{%= author.username %} twitter][author-twitter-img]][author-twitter-url] [![{%= author.username %} github][author-github-img]][author-github-url]
{%= reflinks(verb.reflinks) %}
[npmjs-url]: https://www.npmjs.com/package/{%= name %}
[npmjs-img]: https://img.shields.io/npm/v/{%= name %}.svg?label={%= name %}
[license-url]: https://github.com/{%= repository %}/blob/master/LICENSE
[license-img]: https://img.shields.io/badge/license-MIT-blue.svg
[codeclimate-url]: https://codeclimate.com/github/{%= repository %}
[codeclimate-img]: https://img.shields.io/codeclimate/github/{%= repository %}.svg
[travis-url]: https://travis-ci.org/{%= repository %}
[travis-img]: https://img.shields.io/travis/{%= repository %}/master.svg
[coveralls-url]: https://coveralls.io/r/{%= repository %}
[coveralls-img]: https://img.shields.io/coveralls/{%= repository %}.svg
[david-url]: https://david-dm.org/{%= repository %}
[david-img]: https://img.shields.io/david/{%= repository %}.svg
[standard-url]: https://github.com/feross/standard
[standard-img]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg
[author-www-url]: http://www.{%= author.username.toLowerCase() %}.tk
[author-www-img]: https://img.shields.io/badge/www-{%= author.username.toLowerCase() %}.tk-fe7d37.svg
[keybase-url]: https://keybase.io/{%= author.username.toLowerCase() %}
[keybase-img]: https://img.shields.io/badge/keybase-{%= author.username.toLowerCase() %}-8a7967.svg
[author-npm-url]: https://www.npmjs.com/~{%= author.username.toLowerCase() %}
[author-npm-img]: https://img.shields.io/badge/npm-~{%= author.username.toLowerCase() %}-cb3837.svg
[author-twitter-url]: https://twitter.com/{%= author.username %}
[author-twitter-img]: https://img.shields.io/badge/twitter-@{%= author.username %}-55acee.svg
[author-github-url]: https://github.com/{%= author.username %}
[author-github-img]: https://img.shields.io/badge/github-@{%= author.username %}-4183c4.svg
[freenode-url]: http://webchat.freenode.net/?channels=charlike
[freenode-img]: https://img.shields.io/badge/freenode-%23charlike-5654a4.svg
[new-message-url]: https://github.com/{%= author.username %}/ama
[new-message-img]: https://img.shields.io/badge/ask%20me-anything-green.svg