MCPcopy Index your code
hub / github.com/formatjs/formatjs / prepareLocaleSegmentationRules

Function prepareLocaleSegmentationRules

packages/intl-segmenter/segmenter.ts:77–105  ·  view source on GitHub ↗
(
  segmentationTypeValue: SegmentationTypeTypeRaw
)

Source from the content-addressed store, hash-verified

75}
76
77const prepareLocaleSegmentationRules = (
78 segmentationTypeValue: SegmentationTypeTypeRaw
79) => {
80 const preparedRules: Record<string, SegmentationRule> = {}
81 for (const ruleNr of Object.keys(segmentationTypeValue.segmentRules)) {
82 const ruleValue = segmentationTypeValue.segmentRules[ruleNr]
83 const preparedRule: SegmentationRule = {
84 breaks: ruleValue.breaks,
85 }
86
87 if ('before' in ruleValue && ruleValue.before) {
88 preparedRule.before = generateRuleRegex(
89 ruleValue.before,
90 segmentationTypeValue.variables,
91 false
92 )
93 }
94 if ('after' in ruleValue && ruleValue.after) {
95 preparedRule.after = generateRuleRegex(
96 ruleValue.after,
97 segmentationTypeValue.variables,
98 true
99 )
100 }
101
102 preparedRules[ruleNr] = preparedRule
103 }
104 return preparedRules
105}
106
107const breaksAtResult = (
108 breaks: boolean,

Callers 1

constructorMethod · 0.85

Calls 1

generateRuleRegexFunction · 0.85

Tested by

no test coverage detected