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

Function fromStringEncoded

packages/effect/src/unstable/cluster/ShardId.ts:148–162  ·  view source on GitHub ↗
(s: string)

Source from the content-addressed store, hash-verified

146 * @since 4.0.0
147 */
148export function fromStringEncoded(s: string): {
149 readonly group: string
150 readonly id: number
151} {
152 const index = s.lastIndexOf(":")
153 if (index === -1) {
154 throw new Error(`Invalid ShardId format`)
155 }
156 const group = s.substring(0, index)
157 const id = Number(s.substring(index + 1))
158 if (isNaN(id)) {
159 throw new Error(`ShardId id must be a number`)
160 }
161 return { group, id }
162}
163
164/**
165 * Parses a `group:id` string into a cached `ShardId`.

Callers 1

fromStringFunction · 0.85

Calls 1

NumberInterface · 0.50

Tested by

no test coverage detected