Socket
Socket
Sign inDemoInstall

mimic-fn

Package Overview
Dependencies
0
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 2.0.0 to 2.1.0

69

index.d.ts

@@ -1,15 +0,54 @@

/**
* Make a function mimic another one. It will copy over the properties `name`, `length`, `displayName`, and any custom properties you may have set.
*
* @param to - Mimicking function.
* @param from - Function to mimic.
* @returns The modified `to` function.
*/
export default function mimicFn<
ArgumentsType extends unknown[],
ReturnType,
FunctionType extends (...arguments: ArgumentsType) => ReturnType
>(
to: (...arguments: ArgumentsType) => ReturnType,
from: FunctionType
): FunctionType;
declare const mimicFn: {
/**
Make a function mimic another one. It will copy over the properties `name`, `length`, `displayName`, and any custom properties you may have set.
@param to - Mimicking function.
@param from - Function to mimic.
@returns The modified `to` function.
@example
```
import mimicFn = require('mimic-fn');
function foo() {}
foo.unicorn = '🦄';
function wrapper() {
return foo();
}
console.log(wrapper.name);
//=> 'wrapper'
mimicFn(wrapper, foo);
console.log(wrapper.name);
//=> 'foo'
console.log(wrapper.unicorn);
//=> '🦄'
```
*/
<
ArgumentsType extends unknown[],
ReturnType,
FunctionType extends (...arguments: ArgumentsType) => ReturnType
>(
to: (...arguments: ArgumentsType) => ReturnType,
from: FunctionType
): FunctionType;
// TODO: Remove this for the next major release, refactor the whole definition to:
// declare function mimicFn<
// ArgumentsType extends unknown[],
// ReturnType,
// FunctionType extends (...arguments: ArgumentsType) => ReturnType
// >(
// to: (...arguments: ArgumentsType) => ReturnType,
// from: FunctionType
// ): FunctionType;
// export = mimicFn;
default: typeof mimicFn;
};
export = mimicFn;

@@ -12,2 +12,3 @@ 'use strict';

module.exports = mimicFn;
// TODO: Remove this for the next major release
module.exports.default = mimicFn;
{
"name": "mimic-fn",
"version": "2.0.0",
"version": "2.1.0",
"description": "Make a function mimic another one",

@@ -16,3 +16,3 @@ "license": "MIT",

"scripts": {
"test": "xo && ava && tsd-check"
"test": "xo && ava && tsd"
},

@@ -39,6 +39,6 @@ "files": [

"devDependencies": {
"ava": "^1.3.1",
"tsd-check": "^0.3.0",
"ava": "^1.4.1",
"tsd": "^0.7.1",
"xo": "^0.24.0"
}
}

@@ -24,3 +24,3 @@ # mimic-fn [![Build Status](https://travis-ci.org/sindresorhus/mimic-fn.svg?branch=master)](https://travis-ci.org/sindresorhus/mimic-fn)

function wrapper() {
return foo() {};
return foo();
}

@@ -65,2 +65,3 @@

- [rename-fn](https://github.com/sindresorhus/rename-fn) - Rename a function
- [keep-func-props](https://github.com/ehmicky/keep-func-props) - Wrap a function without changing its name, length and other properties

@@ -67,0 +68,0 @@

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc