MCPcopy Create free account
hub / github.com/SlexAxton/listpattern / extractListPatterns

Function extractListPatterns

index.js:6–29  ·  view source on GitHub ↗
(data)

Source from the content-addressed store, hash-verified

4// Internal function that extracts the important bits of the CLDR data
5// and throws away the cruft.
6function extractListPatterns(data) {
7 // Break early if we have a reduced config object
8 if (typeof data[LIST_PATTERN_PREFIX + DEFAULT_LIST_PATTERN] == 'object') {
9 return data;
10 }
11
12 // Determine the key where the actual config values lie
13 if (data && data.main)
14 for (var key in data.main) {
15 if (data.main.hasOwnProperty(key)) {
16 if (
17 data.main[key] &&
18 data.main[key].listPatterns &&
19 data.main[key].listPatterns[
20 LIST_PATTERN_PREFIX + DEFAULT_LIST_PATTERN
21 ]
22 ) {
23 return data.main[key].listPatterns;
24 }
25 }
26 }
27
28 throw new Error('Could not find listPattern set in configuration data.');
29}
30
31// Logic to format the literal length rules (e.g. "2": "{0} and {1}")
32function formatLiteralPattern(list, listPattern) {

Callers 1

ListPatternFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected