Library for quote scoring calculations
Add lib-quote-scoring to package.json
"dependencies": {
"lib-quote-scoring": "github:karhoo/lib-quote-scoring#semver:v0.2.0",
}And then:
npm iIn app entry:
import { init } from 'lib-quote-scoring'
init()This will fetch remote scores config to be used in algorithm.
Note: Library uses Fetch API - make sure to provide polyfill, if necessary.
Use library in a non-blocking manner:
import { getPreferredQuote } from 'lib-quote-scoring'
const quote = getPreferredQuote([])Or make sure that initialization is finished, before usage:
import { init, getPreferredQuote } from 'lib-quote-scoring'
init().then(() => {
const quote = getPreferredQuote([])
})If you need more control over how config is provided, it is possible to use createGetPreferredQuote function:
import { createGetPreferredQuote } from 'lib-quote-scoring/src/createGetPreferredQuote'
const getCustomConfig = () => {
const config = {} // get custom config object somehow
return config
}
const getPreferredQuote = createGetPreferredQuote(getCustomConfig)