MCPcopy Create free account
hub / github.com/api-platform/website / getDictionary

Function getDictionary

pwa/utils/con/humanize-duration.js:96–117  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

94
95 // Build dictionary from options
96 function getDictionary(options) {
97 var languagesFromOptions = [options.language];
98
99 if (has(options, "fallbacks")) {
100 if (isArray(options.fallbacks) && options.fallbacks.length) {
101 languagesFromOptions = languagesFromOptions.concat(options.fallbacks);
102 } else {
103 throw new Error("fallbacks must be an array with at least one element");
104 }
105 }
106
107 for (var i = 0; i < languagesFromOptions.length; i++) {
108 var languageToTry = languagesFromOptions[i];
109 if (has(options.languages, languageToTry)) {
110 return options.languages[languageToTry];
111 } else if (has(LANGUAGES, languageToTry)) {
112 return LANGUAGES[languageToTry];
113 }
114 }
115
116 throw new Error("No language found.");
117 }
118
119 // doHumanization does the bulk of the work.
120 function doHumanization(ms, options) {

Callers 1

doHumanizationFunction · 0.70

Calls 1

hasFunction · 0.85

Tested by

no test coverage detected