Skip to content

Commit

Permalink
Rename second parameter function to
Browse files Browse the repository at this point in the history
  • Loading branch information
vic committed Aug 12, 2012
1 parent 7dd0970 commit 23b4a8e
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
6 changes: 3 additions & 3 deletions README.md
Expand Up @@ -180,14 +180,14 @@ NOR.b(false) // here we are changing the value of the b cell
The `NoR` function form is:

```javascript
NoR(gate, optional_setup, optional_self)
NoR(gate, wiring, self)
```

Where `gate` is a function that receives *cells* and is invoked
whenever one of them changes. An `optional_setup` can be a function
whenever one of them changes. An `wiring` function can be specified
that receives the same *cells* than `gate` for the sake of setting up
cell subscriptions or creating inner gates. If a value for
`optional_self` if given it will be wrapped on an special *cell* named
`self` if given it will be wrapped on an special *cell* named
`self` and its value will be used as `this` whenever `gate` gets
called, of course changing the gate's self will trigger its evaluation.

Expand Down
14 changes: 9 additions & 5 deletions lib/NoR.js
Expand Up @@ -50,8 +50,11 @@
return port
}

var gate = function(impl, setup, self){
var gate = function(impl, wire, self){
var args = arguments
, hasImpl = typeof impl === 'function'
, proto = hasImpl ? null : impl
, impl = hasImpl ? impl : function(){}
, names = {}
, cells = argCells(impl, names)
, timeout
Expand Down Expand Up @@ -91,9 +94,9 @@
}
return '{'+buff.join(', ')+'}'
}
if(setup){
var innerCells = argCells(setup, names)
setup.apply(self(), innerCells)
if(wire){
var innerCells = argCells(wire, names)
wire.apply(self(), innerCells)
}
self.subscribe(execute)
for(var i in cells) {
Expand All @@ -105,7 +108,8 @@
var ARGS_RE = /^function\s+\(([^\)]+)\)/, SEP_RE = /,?\s+/

var argCells = function(impl, store){
var names = impl.toString().match(ARGS_RE)[1].split(SEP_RE)
var names = impl.toString().match(ARGS_RE)
, names = names && names[1].split(SEP_RE) || []
, cells = []
, store = store || {}
for(var i in names){
Expand Down

0 comments on commit 23b4a8e

Please sign in to comment.