40
edits
(Fix cases where "bit" should have been "byte") |
No edit summary |
||
| Line 90: | Line 90: | ||
;blob.byteAt(index); | ;blob.byteAt(index); | ||
;blob.valueAt(index); | ;blob.valueAt(index); | ||
::@showofhands (ashb suggests .byteAt could return Number (byte) instead of a single unit blob; .valueAt would still return blob so that abstract code still works) | |||
:Extracts a single byte from the blob and returns a new blob object containing only it. Note that the blob[i] form is optional, implementations may chose to exclude support for it. This should be ideally be relevant to support for string[i], thus if the interpreter being used supports string[i] it is expected that an implementation should attempt to support it as well. | :Extracts a single byte from the blob and returns a new blob object containing only it. Note that the blob[i] form is optional, implementations may chose to exclude support for it. This should be ideally be relevant to support for string[i], thus if the interpreter being used supports string[i] it is expected that an implementation should attempt to support it as well. | ||
| Line 105: | Line 106: | ||
;blob.split(separator); | ;blob.split(separator); | ||
;blob.split(separator, limit); | ;blob.split(separator, limit); | ||
:Splits the blob based on a sequence of bytes ({0 0 0 255 0 0} split by 255 would become [{0 0 0}, {0 0}]) and returns an array of blobs. This is the same as string.split except it does not support regular expressions. | :Splits the blob based on a sequence of bytes ({0 0 0 255 0 0} split by 255 would become [{0 0 0}, {0 0}]) and returns an array of blobs. This is the same as string.split except it does not support regular expressions. Like string.split this supports sequences of more than one unit (ie: You may split {0 0 255 0 0 255 3 0} by the blob {255 0} and get [{0 0}, {0 255 3 0}]) | ||
;blob.toBlob([fromCharset, toCharset]); | ;blob.toBlob([fromCharset, toCharset]); | ||
| Line 191: | Line 192: | ||
;buf.split(separator); | ;buf.split(separator); | ||
;buf.split(separator, limit); | ;buf.split(separator, limit); | ||
:Splits the buffer based on a sequence and returns an array of strings or blobs. ( | :Splits the buffer based on a sequence and returns an array of strings or blobs. (When used on text buffers this may or may not chose to support regular expressions) | ||
;buf.indexOf(sequence, offset=0); | ;buf.indexOf(sequence, offset=0); | ||
| Line 230: | Line 231: | ||
* Some experimentation with .valueOf needs to be done. .valueOf has type hinting (the first argument is a string hint of what type may be converted to, operators like > and < make use of it as well as a few other cases). It would be nice to see if it's possible to use the native < and > operators to compare blobs on their binary order. | * Some experimentation with .valueOf needs to be done. .valueOf has type hinting (the first argument is a string hint of what type may be converted to, operators like > and < make use of it as well as a few other cases). It would be nice to see if it's possible to use the native < and > operators to compare blobs on their binary order. | ||
* For now I've ignored things like .eq/equals, .lt, gt, etc... do note that Rhino actually implements .equals on String already. Also if we do add these things to blob we should probably implement the same on string. | * For now I've ignored things like .eq/equals, .lt, gt, etc... do note that Rhino actually implements .equals on String already. Also if we do add these things to blob we should probably implement the same on string. | ||
* Aristid Breitkreuz notes Buffer could be moved to IO. | |||
edits