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

Function compareCodePoints

packages/icu-messageformat-parser/printer.ts:183–199  ·  view source on GitHub ↗
(a: string, b: string)

Source from the content-addressed store, hash-verified

181
182// Rust string ordering is UTF-8 lexicographic, which matches code point order.
183function compareCodePoints(a: string, b: string): number {
184 const aIter = a[Symbol.iterator]()
185 const bIter = b[Symbol.iterator]()
186
187 while (true) {
188 const aNext = aIter.next()
189 const bNext = bIter.next()
190 if (aNext.done || bNext.done) {
191 return aNext.done === bNext.done ? 0 : aNext.done ? -1 : 1
192 }
193
194 const diff = aNext.value.codePointAt(0)! - bNext.value.codePointAt(0)!
195 if (diff !== 0) {
196 return diff
197 }
198 }
199}
200
201function printSelectElement(el: SelectElement) {
202 const keys = Object.keys(el.options).sort(compareCodePoints)

Callers

nothing calls this directly

Calls 1

nextMethod · 0.80

Tested by

no test coverage detected