Back to Explore

sindresorhus/mimic-function

GitHub
3 watchersOpen source

Last release:

mimic-function is a JavaScript utility that modifies one function to mimic another function’s name and properties. It’s useful when wrapping a function but you want the wrapper to preserve the original function’s identity details, while keeping a modified to.toString() that reflects the wrapper.

Project status

  • The repository appears largely dormant today, with the last recorded upstream push on 2024-10-28 and the most recent published updates from 2024-03-14 (v5.0.1), over a year ago relative to 2026-09-10.
  • Update cadence looks very low and release-driven, with major changes in 2023-11 (v5.0.0), a patch in 2024-03 (v5.0.1), and then much earlier major changes (2021-04 v4.0.0, 2020-07 v3.1.0), suggesting long intervals between updates.

AI summary generated

AI-generated from public sources. May be inaccurate. Report

Recent updates

  • v5.0.1

    v5.0.1 is a small patch release focused on fixing how mimic-function composes functions when the target has a non-value `.toString` property descriptor. The code changes adjust how the `.toString` property is redefined to avoid issues with accessor descriptors.

  • v5.0.0

    v5.0.0 is primarily a major release that renames the package from mimic-fn to mimic-function and raises the minimum supported Node.js version to 18. The code diff also includes a few packaging and TypeScript declaration changes beyond what is mentioned in the release notes.

    Breaking
  • v4.0.0

    v4.0.0 makes mimic-fn a pure ESM package and raises the minimum supported Node.js version to 12. The core runtime behavior is the same (wraps a function and copies properties), but the module interface for consumers changes due to the switch to ES modules and a default export.

    Breaking
  • v3.1.0

    v3.1.0 improves React Native compatibility. The code change adds an explicit guard to prevent copying the function properties named "arguments" and "caller" when mimicking properties from the source function.

  • v3.0.0

    v3.0.0 expands mimic-fn's behavior by copying more function properties while also changing how certain properties are handled, notably `length`. It also introduces an `ignoreNonConfigurable` option, patches `to.toString` so that `String(to)` reflects the original function, and updates runtime support to drop Node 6.

    BreakingFeatures
  • v2.1.0

    v2.1.0 primarily updates the TypeScript typings and module export shape to be compatible with CommonJS usage. It also adjusts the project’s TypeScript test tooling (tsd vs tsd-check) and makes small documentation/test-related changes.

  • v2.0.0

    This v2.0.0 release introduces TypeScript type definitions and updates the package's runtime requirements. It also contains a breaking change that increases the minimum supported Node.js version.

    BreakingFeatures