Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

[keys] support string-argument (make it regexp) #15

Merged
merged 1 commit into from

2 participants

@guybrush

with this PR one can do:

var rpc = require('rpc-stream')
var v = require('eventvat')()
var s = rpc(v)
var c = rpc()
c.pipe(s).pipe(c)
var r = c.wrap(['set','keys'])
v.onAny(function(){console.log(this.event,'',[].slice.call(arguments))})
r.set('foo','bar')
r.keys('f.*')
// output:
// set foo → [ 'bar' ]
// set → [ 'foo', 'bar' ]
// keys → [ /f.*/, [ 'foo' ] ]

(also it would be easier to implement in guybrush/socketvat)

@hij1nx hij1nx merged commit 6430efa into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Jun 1, 2012
  1. @guybrush
This page is out of date. Refresh to see the latest.
Showing with 4 additions and 0 deletions.
  1. +4 −0 lib/eventvat.js
View
4 lib/eventvat.js
@@ -153,6 +153,10 @@
return Object.keys(this.hash).length;
}
+ if(typeof regex === 'string') {
+ regex = new RegExp(regex)
+ }
+
for(var k in this.hash) {
if(has(this.hash, k) && regex.test(k)) {
keys.push(k);
Something went wrong with that request. Please try again.