Open
Conversation
Implements a clamp function to constrain a value between minimum and maximum bounds. Includes TokenScript implementation, JSON schema definition, and comprehensive unit tests covering various edge cases and value types.
There was a problem hiding this comment.
Pull request overview
Introduces a general-purpose numeric clamp function with a TokenScript implementation, JSON schema, and unit tests to constrain values between minimum and maximum bounds.
Changes:
- Adds
clamp.tokenscriptimplementing numeric clamping via TokenScript’smin/maxprimitives. - Defines
schema.jsonfor theclampfunction, including input/return types and illustrative examples. - Adds
unit.test.tswith Vitest coverage for schema presence and clamping behavior for integers, negatives, and floating-point values and boundaries.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/schemas/functions/clamp/clamp.tokenscript | Implements the clamp operation as min(max_val, max(min_val, value)) using TokenScript built-ins. |
| src/schemas/functions/clamp/schema.json | Declares the clamp function’s schema, metadata, input array (value, min, max), return type, and example usages. |
| src/schemas/functions/clamp/unit.test.ts | Verifies the function schema and runtime behavior across in-range, out-of-range, boundary, negative, and decimal inputs. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements a clamp function to constrain a value between minimum and maximum bounds. Includes TokenScript implementation, JSON schema definition, and comprehensive unit tests covering various edge cases and value types.