JSPM

function-double

1.0.0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 5711
  • Score
    100M100P100Q124114F
  • License ISC

Stand-in for a function

Package Exports

  • function-double

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (function-double) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

function-double

CircleCI status

Stands for the real function passing though all the descriptions and properties of the source function.

It is literally impossible to distinguish the real function, and it's double.

import functionDouble from 'function-double';

const secretFunction = (a,b) => a+b;
secretFunction.propTypes = "this is not React";
const wrapperFunction = (...args) => secretFunction(...args) + 4;

secretFunction.length === 2
wrapperFunction.length === 0
wrapperFunction.propTypes === undefined

const result = functionDouble(wrapperFunction, secretFunction);

wrapperFunction.propTypes === "this is not React";
wrapperFunction.length === 2;


result === wrapperFunction;/ / But not in IE11 :)

API

functionDouble(targetFunction, sourceFunction, [options]) - moves all the stuff from sourceFunction to target.

  • options.toString = (sourceFunction) => string. Override method for toString.
  • options.name = (sourceFunction) => string. Override method for name.

License

MIT