Skip to content

Commit

Permalink
Provide example for wrapping built-in functions
Browse files Browse the repository at this point in the history
  • Loading branch information
bergie committed Feb 19, 2018
1 parent bed1933 commit a9334d7
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/lib/AsComponent.coffee
Expand Up @@ -27,6 +27,23 @@ getParams = require 'get-function-params'
# description: 'Generate a random number',
# });
# };
#
# ### Wrapping built-in functions
#
# Built-in JavaScript functions don't make their arguments introspectable. Because of this, these
# cannot be directly converted to components. You'll have to provide a wrapper JavaScript function to make
# the arguments appear as ports.
#
# Example:
#
# exports.getComponent = function () {
# return noflo.asComponent(function (selector) {
# return document.querySelector(selector);
# }, {
# description: 'Return an element matching the CSS selector',
# icon: 'html5',
# });
# };
exports.asComponent = (func, options) ->
hasCallback = false
params = getParams(func).filter (p) ->
Expand Down

0 comments on commit a9334d7

Please sign in to comment.