MCPcopy
hub / github.com/Effect-TS/effect / clamp

Function clamp

packages/effect/src/Schema.ts:5286–5299  ·  view source on GitHub ↗
(minimum: number, maximum: number)

Source from the content-addressed store, hash-verified

5284 * @since 3.10.0
5285 */
5286export const clamp = (minimum: number, maximum: number) =>
5287<S extends Schema.Any, A extends number>(
5288 self: S & Schema<A, Schema.Encoded<S>, Schema.Context<S>>
5289): transform<S, filter<SchemaClass<A>>> => {
5290 return transform(
5291 self,
5292 typeSchema(self).pipe(between(minimum, maximum)),
5293 {
5294 strict: false,
5295 decode: (i) => number_.clamp(i, { minimum, maximum }),
5296 encode: identity
5297 }
5298 )
5299}
5300
5301/**
5302 * Transforms a `string` into a `number` by parsing the string using the `parse`

Callers

nothing calls this directly

Calls 4

typeSchemaFunction · 0.85
transformInterface · 0.70
betweenFunction · 0.70
pipeMethod · 0.65

Tested by

no test coverage detected