speech_rules.js 662 B

12345678910111213141516
  1. import { Axis, DynamicCstr } from '../rule_engine/dynamic_cstr.js';
  2. const funcStore = new Map();
  3. export function addStore(constr, inherit, store) {
  4. const values = {};
  5. if (inherit) {
  6. const inherits = funcStore.get(inherit) || {};
  7. Object.assign(values, inherits);
  8. }
  9. funcStore.set(constr, Object.assign(values, store));
  10. }
  11. export function getStore(locale, modality, domain) {
  12. return (funcStore.get([locale, modality, domain].join('.')) ||
  13. funcStore.get([DynamicCstr.DEFAULT_VALUES[Axis.LOCALE], modality, domain].join('.')) ||
  14. funcStore.get([DynamicCstr.BASE_LOCALE, modality, domain].join('.')) ||
  15. {});
  16. }