hmpo-countries-lib
Advanced tools
Comparing version 1.0.1 to 1.0.2
'use strict'; | ||
const HmpoCachedModel = require('hmpo-cached-model'); | ||
const debug = require('debug')('hmpo:countries-cached-model'); | ||
const _ = require('underscore'); | ||
@@ -32,7 +33,12 @@ | ||
this._countryCache.on('change', this._indexCountries.bind(this)); | ||
this._policyCache.on('change', this._indexPolicies.bind(this)); | ||
this.on('change', this._indexCountries.bind(this)); | ||
} | ||
on(event, handler) { | ||
this._countryCache.on(event, handler); | ||
this._policyCache.on(event, handler); | ||
} | ||
start() { | ||
debug('start'); | ||
this._countryCache.start(); | ||
@@ -43,2 +49,3 @@ this._policyCache.start(); | ||
stop() { | ||
debug('stop'); | ||
this._countryCache.stop(); | ||
@@ -57,2 +64,3 @@ this._policyCache.stop(); | ||
_indexCountries() { | ||
debug('indexing countries'); | ||
let countries = this._countryCache.get('data'); | ||
@@ -68,2 +76,3 @@ this._residentCountries = _.filter( | ||
_indexPolicies() { | ||
debug('indexing policies'); | ||
let policies = this._policyCache.get('data'); | ||
@@ -70,0 +79,0 @@ this._policiesById = _.indexBy(policies, 'id'); |
{ | ||
"name": "hmpo-countries-lib", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"description": "Country lists", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
18678
377