Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Single endpoint overload API #8

Closed
barneycarroll opened this issue Jan 2, 2018 · 1 comment · Fixed by #9
Closed

Single endpoint overload API #8

barneycarroll opened this issue Jan 2, 2018 · 1 comment · Fixed by #9
Assignees

Comments

@barneycarroll
Copy link
Owner

barneycarroll commented Jan 2, 2018

Full patchinko functionality can be achieved with a single API endpoint based on signature sniffing. This is useful for a certain kind of don't-make-me-think cognitive style, whereby the shape of the code is the focus and the diverse patchinko API references are noisy to remember / read. A drop-in extension would read as follows:

const O = (x, ...more) =>
  x
  ? more.length
    ? P(x, ...more)
    : typeof x === 'function'
      ? new S(x)
      : PS(x)
  : D

…such that, testing sequentially:

Overload invocation… …forks to
O() D
O(...severalArguments) P(...severalArguments)
O(function) S(function)
O(oneNonFunctionArgument) PS(oneNonFunctionArgument)

This comes at the cost of disabling immutable PS(replacement, patch) since multiple arguments are necessarily forwarded to P. Thus immutable nested property patching would require the more verbose O(definition => O(replacement, definition, patch)).

@barneycarroll
Copy link
Owner Author

barneycarroll added a commit that referenced this issue Jan 3, 2018
Version 2.1.0:

* Alternative single-reference don't-make-me-think API, fixes #8
* Fix docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant