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

Function selectRandomMessage

benchmarks/cli-comparison/generate-test-files.mjs:74–87  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

72]
73
74function selectRandomMessage() {
75 const random = Math.random() * 100
76 let cumulative = 0
77
78 for (const {type, weight} of MESSAGE_DISTRIBUTION) {
79 cumulative += weight
80 if (random < cumulative) {
81 const templates = MESSAGE_TEMPLATES[type]
82 return templates[Math.floor(Math.random() * templates.length)]
83 }
84 }
85
86 return MESSAGE_TEMPLATES.simple[0]
87}
88
89function generateFileContent(fileIndex) {
90 const numMessages = Math.floor(Math.random() * 10) + 5 // 5-15 messages per file

Callers 1

generateFileContentFunction · 0.85

Calls 1

floorMethod · 0.80

Tested by

no test coverage detected