mcollina / bloomrun

A js pattern matcher
MIT License
120 stars 10 forks source link

[WIP] Optional Payload Ability #1

Closed mcdonnelldean closed 9 years ago

mcdonnelldean commented 9 years ago

Ok so I've added the ability to have an optional payload if your in to that sort of thing, it would allow this:

'use strict'

var fill = require('nanite-fill')
var drain = require('nanite-drain')
var bloomrun = require('./')()

var handler = drain(function(msg, done) {
  console.log(msg)
  done()
})

bloomrun.add({ cmd: 'say-hello' }, handler)
var found = bloomrun.lookup({ cmd: 'say-hello' })

fill(['hello', 'world']).pipe(found)

Without breaking existing logic.

This is just initial for discussion, Don't pull this yet, I just want to get an idea of whether you want something like this or not. I need it for Nanite that's why I am starting discussions on it.

Edit I also turned off linting because it was being very noisy and I didn't want to add all those changes here.

mcollina commented 9 years ago

I'm 100% :+1: on this. I planned to add it but I completely forgot.

Not sure about the linting, what do you mean?

I also added some more README, would you like to add also the new add parameter?

mcdonnelldean commented 9 years ago

@mcollina Awesome, let me tidy it up first before we add it in. The linting is more because I had an older copy yesterday so we should be ok on my next pull.

mcdonnelldean commented 9 years ago

@mcollina Do you want to give this a quick once over before I merge?

mcollina commented 9 years ago

All good.