MCPcopy
hub / github.com/vitest-dev/vitest / ordinal

Function ordinal

packages/utils/src/helpers.ts:371–388  ·  view source on GitHub ↗
(i: number)

Source from the content-addressed store, hash-verified

369}
370
371export function ordinal(i: number): string {
372 const j = i % 10
373 const k = i % 100
374
375 if (j === 1 && k !== 11) {
376 return `${i}st`
377 }
378
379 if (j === 2 && k !== 12) {
380 return `${i}nd`
381 }
382
383 if (j === 3 && k !== 13) {
384 return `${i}rd`
385 }
386
387 return `${i}th`
388}
389
390/**
391 * Deep merge :P

Callers 4

getUsedPropsFunction · 0.90
JestChaiExpectFunction · 0.90
formatCallsFunction · 0.90
formatReturnsFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected