Skip to content

Commit 684df98

Browse files
authored
feat(stdlib): Deprecate Buffer.set operations in favour of Bytes.set (#2303)
1 parent 1992734 commit 684df98

File tree

2 files changed

+132
-24
lines changed

2 files changed

+132
-24
lines changed

stdlib/buffer.gr

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -626,8 +626,11 @@ provide let getInt8 = (index, buffer) => {
626626
* Buffer.setInt8(0, 3s, buf)
627627
* assert Buffer.getInt8(0, buf) == 3s
628628
*
629+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
630+
*
629631
* @since v0.4.0
630632
* @history v0.6.0: `value` argument type changed to `Int8`
633+
* @history v0.7.1: Deprecated in favor of `Bytes.setInt8`
631634
*/
632635
provide let setInt8 = (index, value, buffer) => {
633636
checkIsIndexInBounds(index, _8BIT_LEN, buffer)
@@ -693,7 +696,10 @@ provide let getUint8 = (index, buffer) => {
693696
* Buffer.setUint8(4us, buf)
694697
* assert Buffer.getUint8(0, buf) == 4us
695698
*
699+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
700+
*
696701
* @since v0.6.0
702+
* @history v0.7.1: Deprecated in favor of `Bytes.setUint8`
697703
*/
698704
provide let setUint8 = (index, value, buffer) => {
699705
checkIsIndexInBounds(index, _8BIT_LEN, buffer)
@@ -758,8 +764,11 @@ provide let getInt16 = (index, buffer) => {
758764
* Buffer.setInt16(5, 1S, buf)
759765
* assert Buffer.getInt16(5, buf) == 1S
760766
*
767+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
768+
*
761769
* @since v0.4.0
762770
* @history v0.6.0: `value` argument type changed to `Int16`
771+
* @history v0.7.1: Deprecated in favor of `Bytes.setInt16`
763772
*/
764773
provide let setInt16 = (index, value, buffer) => {
765774
checkIsIndexInBounds(index, _16BIT_LEN, buffer)
@@ -825,7 +834,10 @@ provide let getUint16 = (index, buffer) => {
825834
* Buffer.setUint16(0, 1uS, buf)
826835
* assert Buffer.getUint16(0, buf) == 1uS
827836
*
837+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
838+
*
828839
* @since v0.6.0
840+
* @history v0.7.1: Deprecated in favor of `Bytes.setUint16`
829841
*/
830842
provide let setUint16 = (index, value, buffer) => {
831843
checkIsIndexInBounds(index, _16BIT_LEN, buffer)
@@ -889,7 +901,10 @@ provide let getInt32 = (index, buffer) => {
889901
* Buffer.setInt32(3, 1l, buf)
890902
* assert Buffer.getInt32(3, buf) == 1l
891903
*
904+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
905+
*
892906
* @since v0.4.0
907+
* @history v0.7.1: Deprecated in favor of `Bytes.setInt32`
893908
*/
894909
provide let setInt32 = (index, value, buffer) => {
895910
checkIsIndexInBounds(index, _32BIT_LEN, buffer)
@@ -953,7 +968,10 @@ provide let getUint32 = (index, buffer) => {
953968
* Buffer.setUint32(0, 1ul, buf)
954969
* assert Buffer.getUint32(0, buf) == 1ul
955970
*
971+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
972+
*
956973
* @since v0.6.0
974+
* @history v0.7.1: Deprecated in favor of `Bytes.setUint32`
957975
*/
958976
provide let setUint32 = (index, value, buffer) => {
959977
checkIsIndexInBounds(index, _32BIT_LEN, buffer)
@@ -1017,7 +1035,10 @@ provide let getFloat32 = (index, buffer) => {
10171035
* Buffer.setFloat32(0, 1.0f, buf)
10181036
* assert Buffer.getFloat32(0, buf) == 1.0f
10191037
*
1038+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
1039+
*
10201040
* @since v0.4.0
1041+
* @history v0.7.1: Deprecated in favor of `Bytes.setFloat32`
10211042
*/
10221043
provide let setFloat32 = (index, value, buffer) => {
10231044
checkIsIndexInBounds(index, _32BIT_LEN, buffer)
@@ -1084,7 +1105,10 @@ provide let getInt64 = (index, buffer) => {
10841105
* Buffer.setInt64(0, 1L, buf)
10851106
* assert Buffer.getInt64(0, buf) == 1L
10861107
*
1108+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
1109+
*
10871110
* @since v0.4.0
1111+
* @history v0.7.1: Deprecated in favor of `Bytes.setInt64
10881112
*/
10891113
provide let setInt64 = (index, value, buffer) => {
10901114
checkIsIndexInBounds(index, _64BIT_LEN, buffer)
@@ -1151,7 +1175,10 @@ provide let getUint64 = (index, buffer) => {
11511175
* Buffer.setUint64(0, 1uL, buf)
11521176
* assert Buffer.getUint64(0, buf) == 1uL
11531177
*
1178+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
1179+
*
11541180
* @since v0.6.0
1181+
* @history v0.7.1: Deprecated in favor of `Bytes.setUint64`
11551182
*/
11561183
provide let setUint64 = (index, value, buffer) => {
11571184
checkIsIndexInBounds(index, _64BIT_LEN, buffer)
@@ -1218,7 +1245,10 @@ provide let getFloat64 = (index, buffer) => {
12181245
* Buffer.setFloat64(0, 1.0F, buf)
12191246
* assert Buffer.getFloat64(0, buf) == 1.0F
12201247
*
1248+
* @deprecated Use `Bytes` instead of `Buffer` for set operations.
1249+
*
12211250
* @since v0.4.0
1251+
* @history v0.7.1: Deprecated in favor of `Bytes.setFloat64`
12221252
*/
12231253
provide let setFloat64 = (index, value, buffer) => {
12241254
checkIsIndexInBounds(index, _64BIT_LEN, buffer)

stdlib/buffer.md

Lines changed: 102 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -715,6 +715,8 @@ assert Buffer.getInt8(0, buf) == 1s
715715

716716
### Buffer.**setInt8**
717717

718+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
719+
718720
<details>
719721
<summary>Added in <code>0.4.0</code></summary>
720722
<table>
@@ -723,6 +725,7 @@ assert Buffer.getInt8(0, buf) == 1s
723725
</thead>
724726
<tbody>
725727
<tr><td><code>0.6.0</code></td><td>`value` argument type changed to `Int8`</td></tr>
728+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setInt8`</td></tr>
726729
</tbody>
727730
</table>
728731
</details>
@@ -844,9 +847,18 @@ assert Buffer.getUint8(0, buf) == 3us
844847

845848
### Buffer.**setUint8**
846849

847-
<details disabled>
848-
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
849-
No other changes yet.
850+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
851+
852+
<details>
853+
<summary>Added in <code>0.6.0</code></summary>
854+
<table>
855+
<thead>
856+
<tr><th>version</th><th>changes</th></tr>
857+
</thead>
858+
<tbody>
859+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setUint8`</td></tr>
860+
</tbody>
861+
</table>
850862
</details>
851863

852864
```grain
@@ -959,6 +971,8 @@ assert Buffer.getInt16(0, buf) == 1S
959971

960972
### Buffer.**setInt16**
961973

974+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
975+
962976
<details>
963977
<summary>Added in <code>0.4.0</code></summary>
964978
<table>
@@ -967,6 +981,7 @@ assert Buffer.getInt16(0, buf) == 1S
967981
</thead>
968982
<tbody>
969983
<tr><td><code>0.6.0</code></td><td>`value` argument type changed to `Int16`</td></tr>
984+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setInt16`</td></tr>
970985
</tbody>
971986
</table>
972987
</details>
@@ -1088,9 +1103,18 @@ assert Buffer.getUint16(0, buf) == 1uS
10881103

10891104
### Buffer.**setUint16**
10901105

1091-
<details disabled>
1092-
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
1093-
No other changes yet.
1106+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1107+
1108+
<details>
1109+
<summary>Added in <code>0.6.0</code></summary>
1110+
<table>
1111+
<thead>
1112+
<tr><th>version</th><th>changes</th></tr>
1113+
</thead>
1114+
<tbody>
1115+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setUint16`</td></tr>
1116+
</tbody>
1117+
</table>
10941118
</details>
10951119

10961120
```grain
@@ -1196,9 +1220,18 @@ assert Buffer.getInt32(0, buf) == 1l
11961220

11971221
### Buffer.**setInt32**
11981222

1199-
<details disabled>
1200-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
1201-
No other changes yet.
1223+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1224+
1225+
<details>
1226+
<summary>Added in <code>0.4.0</code></summary>
1227+
<table>
1228+
<thead>
1229+
<tr><th>version</th><th>changes</th></tr>
1230+
</thead>
1231+
<tbody>
1232+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setInt32`</td></tr>
1233+
</tbody>
1234+
</table>
12021235
</details>
12031236

12041237
```grain
@@ -1304,9 +1337,18 @@ assert Buffer.getUint32(0, buf) == 1ul
13041337

13051338
### Buffer.**setUint32**
13061339

1307-
<details disabled>
1308-
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
1309-
No other changes yet.
1340+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1341+
1342+
<details>
1343+
<summary>Added in <code>0.6.0</code></summary>
1344+
<table>
1345+
<thead>
1346+
<tr><th>version</th><th>changes</th></tr>
1347+
</thead>
1348+
<tbody>
1349+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setUint32`</td></tr>
1350+
</tbody>
1351+
</table>
13101352
</details>
13111353

13121354
```grain
@@ -1412,9 +1454,18 @@ assert Buffer.getFloat32(0, buf) == 1.0f
14121454

14131455
### Buffer.**setFloat32**
14141456

1415-
<details disabled>
1416-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
1417-
No other changes yet.
1457+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1458+
1459+
<details>
1460+
<summary>Added in <code>0.4.0</code></summary>
1461+
<table>
1462+
<thead>
1463+
<tr><th>version</th><th>changes</th></tr>
1464+
</thead>
1465+
<tbody>
1466+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setFloat32`</td></tr>
1467+
</tbody>
1468+
</table>
14181469
</details>
14191470

14201471
```grain
@@ -1520,9 +1571,18 @@ assert Buffer.getInt64(0, buf) == 1L
15201571

15211572
### Buffer.**setInt64**
15221573

1523-
<details disabled>
1524-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
1525-
No other changes yet.
1574+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1575+
1576+
<details>
1577+
<summary>Added in <code>0.4.0</code></summary>
1578+
<table>
1579+
<thead>
1580+
<tr><th>version</th><th>changes</th></tr>
1581+
</thead>
1582+
<tbody>
1583+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setInt64</td></tr>
1584+
</tbody>
1585+
</table>
15261586
</details>
15271587

15281588
```grain
@@ -1628,9 +1688,18 @@ assert Buffer.getUint64(0, buf) == 1uL
16281688

16291689
### Buffer.**setUint64**
16301690

1631-
<details disabled>
1632-
<summary tabindex="-1">Added in <code>0.6.0</code></summary>
1633-
No other changes yet.
1691+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1692+
1693+
<details>
1694+
<summary>Added in <code>0.6.0</code></summary>
1695+
<table>
1696+
<thead>
1697+
<tr><th>version</th><th>changes</th></tr>
1698+
</thead>
1699+
<tbody>
1700+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setUint64`</td></tr>
1701+
</tbody>
1702+
</table>
16341703
</details>
16351704

16361705
```grain
@@ -1736,9 +1805,18 @@ assert Buffer.getFloat64(0, buf) == 1.0F
17361805

17371806
### Buffer.**setFloat64**
17381807

1739-
<details disabled>
1740-
<summary tabindex="-1">Added in <code>0.4.0</code></summary>
1741-
No other changes yet.
1808+
> **Deprecated:** Use `Bytes` instead of `Buffer` for set operations.
1809+
1810+
<details>
1811+
<summary>Added in <code>0.4.0</code></summary>
1812+
<table>
1813+
<thead>
1814+
<tr><th>version</th><th>changes</th></tr>
1815+
</thead>
1816+
<tbody>
1817+
<tr><td><code>next</code></td><td>Deprecated in favor of `Bytes.setFloat64`</td></tr>
1818+
</tbody>
1819+
</table>
17421820
</details>
17431821

17441822
```grain

0 commit comments

Comments
 (0)