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

mimic-fn

Package Overview
Dependencies
Maintainers
2
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mimic-fn - npm Package Compare versions

Comparing version 3.1.0 to 4.0.0

24

index.d.ts

@@ -1,10 +0,8 @@

declare namespace mimicFn {
interface Options {
/**
Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
export interface Options {
/**
Skip modifying [non-configurable properties](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyDescriptor#Description) instead of throwing an error.
@default false
*/
readonly ignoreNonConfigurable?: boolean;
}
@default false
*/
readonly ignoreNonConfigurable?: boolean;
}

@@ -25,3 +23,3 @@

```
import mimicFn = require('mimic-fn');
import mimicFunction from 'mimic-fn';

@@ -38,3 +36,3 @@ function foo() {}

mimicFn(wrapper, foo);
mimicFunction(wrapper, foo);

@@ -48,3 +46,3 @@ console.log(wrapper.name);

*/
declare function mimicFn<
export default function mimicFunction<
ArgumentsType extends unknown[],

@@ -56,5 +54,3 @@ ReturnType,

from: FunctionType,
options?: mimicFn.Options,
options?: Options,
): FunctionType;
export = mimicFn;

@@ -1,3 +0,1 @@

'use strict';
const copyProperty = (to, from, property, ignoreNonConfigurable) => {

@@ -26,4 +24,4 @@ // `Function#length` should reflect the parameters of `to` not `from` since we keep its body.

// `Object.defineProperty()` throws if the property exists, is not configurable and either:
// - one its descriptors is changed
// - it is non-writable and its value is changed
// - one its descriptors is changed
// - it is non-writable and its value is changed
const canCopyProperty = function (toDescriptor, fromDescriptor) {

@@ -63,3 +61,3 @@ return toDescriptor === undefined || toDescriptor.configurable || (

const mimicFn = (to, from, {ignoreNonConfigurable = false} = {}) => {
export default function mimicFunction(to, from, {ignoreNonConfigurable = false} = {}) {
const {name} = to;

@@ -75,4 +73,2 @@

return to;
};
module.exports = mimicFn;
}
{
"name": "mimic-fn",
"version": "3.1.0",
"version": "4.0.0",
"description": "Make a function mimic another one",
"license": "MIT",
"repository": "sindresorhus/mimic-fn",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},

@@ -38,6 +41,6 @@ "scripts": {

"devDependencies": {
"ava": "^2.1.0",
"tsd": "^0.7.1",
"xo": "^0.24.0"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
}
}
<img src="media/logo.svg" alt="mimic-fn" width="400">
<br>
[![Build Status](https://travis-ci.org/sindresorhus/mimic-fn.svg?branch=master)](https://travis-ci.org/sindresorhus/mimic-fn)
> Make a function mimic another one

@@ -10,3 +8,2 @@

## Install

@@ -18,7 +15,6 @@

## Usage
```js
const mimicFn = require('mimic-fn');
import mimicFunction from 'mimic-fn';

@@ -35,3 +31,3 @@ function foo() {}

mimicFn(wrapper, foo);
mimicFunction(wrapper, foo);

@@ -51,3 +47,3 @@ console.log(wrapper.name);

### mimicFn(to, from, options?)
### mimicFunction(to, from, options?)

@@ -78,3 +74,3 @@ Modifies the `to` function to mimic the `from` function. Returns the `to` function.

Type: `boolean`<br>
Type: `boolean`\
Default: `false`

@@ -89,3 +85,2 @@

---

@@ -92,0 +87,0 @@

Sorry, the diff of this file is not supported yet

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