rjrodger / patrun

A fast pattern matcher on JavaScript object properties.
MIT License
143 stars 19 forks source link

Another findall? #2

Closed mcollina closed 10 years ago

mcollina commented 10 years ago

I'm thinking about using patrun as the matching engine of a pub/sub system, just like event emitter, similar to mqemitter. I would like to see this code work:

var patrun = require('patrun')
   , pm = patrun()

pm.add({ the: 'heading' }, function a() { console.log('a', arguments) })
pm.add({ the: 'heading' }, function b() { console.log('b', arguments) })

pm.findall({ the: 'heading', a: 'message' })[0].data('it works!')

I'm not sure how to add this functionality to patrun, some feedback is highly needed :).

rjrodger commented 10 years ago

Funny you should mention that...

0.2.0 just out - take a look at the README!

mcollina commented 10 years ago

:dancers: thanks!

mcollina commented 10 years ago

Here is my night coding effort: https://github.com/mcollina/patrun-emitter :)