Bytes
Bytes operations.
Functions
indexOf
Forward search for s in buffer
If s is present in the buffer, returns the index of the first instance
If s is not present in the buffer, returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's Array.indexOf]
function indexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256);
indexOf
Forward search for s in buffer starting at position pos
If s is present in the buffer (at or after pos), returns the index of the next instance
If s is not present in the buffer (at or after pos), returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/indexOf[Javascript's Array.indexOf]
function indexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256);
lastIndexOf
Backward search for s in buffer
If s is present in the buffer, returns the index of the last instance
If s is not present in the buffer, returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's Array.lastIndexOf]
function lastIndexOf(bytes memory buffer, bytes1 s) internal pure returns (uint256);
lastIndexOf
Backward search for s in buffer starting at position pos
If s is present in the buffer (at or before pos), returns the index of the previous instance
If s is not present in the buffer (at or before pos), returns type(uint256).max
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/lastIndexOf[Javascript's Array.lastIndexOf]
function lastIndexOf(bytes memory buffer, bytes1 s, uint256 pos) internal pure returns (uint256);
slice
Copies the content of buffer, from start (included) to the end of buffer into a new bytes object in
memory.
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's Array.slice]
function slice(bytes memory buffer, uint256 start) internal pure returns (bytes memory);
slice
Copies the content of buffer, from start (included) to end (excluded) into a new bytes object in
memory.
NOTE: replicates the behavior of https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/slice[Javascript's Array.slice]
function slice(bytes memory buffer, uint256 start, uint256 end) internal pure returns (bytes memory);
_unsafeReadBytesOffset
Reads a bytes32 from a bytes array without bounds checking. NOTE: making this function internal would mean it could be used with memory unsafe offset, and marking the assembly block as such would prevent some optimizations.
function _unsafeReadBytesOffset(bytes memory buffer, uint256 offset) private pure returns (bytes32 value);