MCPcopy Create free account
hub / github.com/Effect-TS/effect / comparePrerelease

Function comparePrerelease

packages/effect/src/SemVer.ts:152–168  ·  view source on GitHub ↗
(
  self: ReadonlyArray<string | number>,
  that: ReadonlyArray<string | number>
)

Source from the content-addressed store, hash-verified

150export type Core = Pick<SemVer, "major" | "minor" | "patch" | "prerelease">
151
152const comparePrerelease = (
153 self: ReadonlyArray<string | number>,
154 that: ReadonlyArray<string | number>
155): -1 | 0 | 1 => {
156 if (self.length === 0) return that.length === 0 ? 0 : 1
157 if (that.length === 0) return -1
158 const length = Math.min(self.length, that.length)
159 for (let i = 0; i < length; i++) {
160 const a = self[i]
161 const b = that[i]
162 if (a === b) continue
163 if (typeof a === "number") return typeof b === "number" ? order.Number(a, b) : -1
164 if (typeof b === "number") return 1
165 return order.String(a, b)
166 }
167 return order.Number(self.length, that.length)
168}
169
170/** @internal */
171export const sameCore = (self: Core, that: Core): boolean =>

Callers 1

compareCoreFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected