benhmoore / Knwl

Find Dates, Places, Times, and More. A .js library for parsing text for specific information.
MIT License
5.29k stars 214 forks source link

RFE: multiiple parser instances #70

Closed rektide closed 9 years ago

rektide commented 9 years ago

Presently all functionality stems from data stored on the rootmost require('knwl') object. This makes it impossible to have more than one parse running at a time. I would like to see the ability to instantiate individual parser instances each parsing different strings.

marshall007 commented 9 years ago

Agreed, and I think plugins should be the same way. This would also allow you to pass in configuration for both the parser and plugins.

benhmoore commented 9 years ago

Added support for multiple instances of Knwl.js (and plugins): 541bf35d9cd1604eff34e83d08de99abcccd5fa0

marshall007 commented 9 years ago

@loadfive sorry for not getting back sooner, but for plugins I was imagining you'd do something like this:

knwl.register('places', require('./default_plugins/places')())
knwl.register('places-en', require('./default_plugins/places')({ locale: 'en' }))

Which would allow you to pass configuration to plugins and also register the same plugin multiple times with different configurations.