Skip to content

Preserve own function props#2

Open
devinivy wants to merge 1 commit intodominictarr:masterfrom
devinivy:preserve-fn-props
Open

Preserve own function props#2
devinivy wants to merge 1 commit intodominictarr:masterfrom
devinivy:preserve-fn-props

Conversation

@devinivy
Copy link
Copy Markdown

@devinivy devinivy commented Feb 28, 2021

I was hoping to write a utility that adds some properties to a function, similar to how hoox adds a hook property. This utility is used in the context of secret-stack, so the function is eventually wrapped using hoox which doesn't currently preserve these properties. Proposed here is a backwards-compatible change to preserve the original function's own properties. Here's a little example to illustrate:

  var add = function (a, b) {
    return a + b
  };

  add.operation = 'addition'

  var h = Hoox(add)

  t.equal(h.operation, 'addition')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant