An event emitter that emits only new events. Because sometimes we don't care about old events.
var NewsEmitter = ;var news = ;news;news;news;news;news;news;news;// new item: hello there// new item: hello world// new item: hey
Creates an instance of a NewsEmitter.
options can be
filter- An array of events that will be affected. If not given, events names will not be filtered.
ignore- An array of events that will be ignored. Defaults to
maxHistory- Maximum number of history items to remember. Default is
manageHistory- If true, does not add emitted events to history. Instead expects you to manually manage history with
addHistory(). Defaults to
identifier- Function used to compare one event to another. Takes 1 arguments, the array-like
NewsEmitter#emit()is called with. Should return a string. Default is
Emits an event, only if it has not been emitted before. Returns true if item is new and emtted. False otherwise.
Resets history of an event. If no event given, resets all history.
Adds items in
event's history. Truncated as necessary based on max history length considering the last item in the array as newest.
npm install newsemitter
Tests are written with mocha