aboutsummaryrefslogtreecommitdiff
path: root/api/bytes.yaml
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2025-08-16 17:21:01 -0400
committerBruce Hill <bruce@bruce-hill.com>2025-08-16 17:21:01 -0400
commitc72b0406a32ffc3f04324f7b6c321486762fca41 (patch)
tree244e51c858890ea2ffb8c74a2c33c81b79de376e /api/bytes.yaml
parent849fd423a759edf1b58b548a6148c177a6f8cd71 (diff)
Improved parsing and prefix/suffix matching using a `remainder`
parameter
Diffstat (limited to 'api/bytes.yaml')
-rw-r--r--api/bytes.yaml28
1 files changed, 21 insertions, 7 deletions
diff --git a/api/bytes.yaml b/api/bytes.yaml
index 2785513d..f7b8cb5d 100644
--- a/api/bytes.yaml
+++ b/api/bytes.yaml
@@ -54,7 +54,7 @@ Byte.hex:
example: |
>> Byte(18).hex()
= "0x12"
-
+
Byte.is_between:
short: test if inside a range
description: >
@@ -83,7 +83,7 @@ Byte.is_between:
= no
>> Byte(7).is_between(1, 7)
= yes
-
+
Byte.parse:
short: convert text to a byte
description: >
@@ -97,12 +97,26 @@ Byte.parse:
type: 'Text'
description: >
The text to parse.
+ remainder:
+ type: '&Text?'
+ default: 'none'
+ description: >
+ If non-none, this argument will be set to the remainder of the text after the matching part.
+ If none, parsing will only succeed if the entire text matches.
example: |
>> Byte.parse("5")
- = Byte(5)?
+ = Byte(5) : Byte?
>> Byte.parse("asdf")
- = none
-
+ = none : Byte?
+
+ >> Byte.parse("123xyz")
+ = none : Byte?
+ remainder : Text
+ >> Byte.parse("123xyz", &remainder)
+ = Byte(123) : Byte?
+ >> remainder
+ = "xyz"
+
Byte.to:
short: iterate over a range of bytes
description: >
@@ -132,7 +146,7 @@ Byte.to:
= [Byte(2), Byte(3), Byte(4), Byte(5)]
>> [x for x in Byte(5).to(2)]
= [Byte(5), Byte(4), Byte(3), Byte(2)]
-
+
>> [x for x in Byte(2).to(5, step=2)]
= [Byte(2), Byte(4)]
-
+