Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

rename-function

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

rename-function - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

5

CHANGELOG.md
## 1.0.1 - 2016-04-14
- Release v1.0.1 / npm@v1.0.1
- update description and docs
- allow passing context as third argument or as bind/call/apply-ing `renameFunction`
## 1.0.0 - 2016-04-14

@@ -4,0 +9,0 @@ - Release v1.0.0 / npm@v1.0.0

7

index.js

@@ -31,2 +31,3 @@ /*!

* @param {String} `name`
* @param {Object} `ctx`
* @return {Function}

@@ -36,3 +37,3 @@ * @api public

module.exports = function renameFunction (fn, name) {
module.exports = function renameFunction (fn, name, ctx) {
if (typeof fn !== 'function') {

@@ -45,4 +46,4 @@ throw new TypeError('rename-function: expect `fn` be function')

name = utils.namify(name)
var str = format('return function %s(){return fn.apply(this,arguments)}', name)
var func = (new Function('fn', str))(fn) // eslint-disable-line no-new-func
var str = format('return function %s() { return fn.apply(ctx || this, arguments) }', name)
var func = (new Function('fn', 'ctx', str))(fn, ctx || this) // eslint-disable-line no-new-func

@@ -49,0 +50,0 @@ utils.defineProperty(func, 'toString', function toString () {

{
"name": "rename-function",
"version": "1.0.0",
"description": "Rename a given function. Tries to be cross-platform and guaranteed. Useful when you want to preserve name of bound function.",
"version": "1.0.1",
"description": "Rename a given function. Tries to be cross-platform and guaranteed. Useful when you want to preserve name of bound function. In bonus, allows passing context to the renamed function.",
"repository": "tunnckoCore/rename-function",

@@ -6,0 +6,0 @@ "author": "Charlike Mike Reagent <@tunnckoCore> (http://www.tunnckocore.tk)",

# [rename-function][author-www-url] [![npmjs.com][npmjs-img]][npmjs-url] [![The MIT License][license-img]][license-url]
> Rename a given function. Tries to be cross-platform and guaranteed. Useful when you want to preserve name of bound function.
> Rename a given function. Tries to be cross-platform and guaranteed. Useful when you want to preserve name of bound function. In bonus, allows passing context to the renamed function.

@@ -19,3 +19,3 @@ [![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]

### [renameFunction](index.js#L35)
### [renameFunction](index.js#L36)
> Rename given `fn` with `name`. If given `name` is same as old, then the `fn` is just returned earlier, nothing more is done.

@@ -27,2 +27,3 @@

* `name` **{String}**
* `ctx` **{Object}**
* `returns` **{Function}**

@@ -29,0 +30,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc