ServerJS/API/file: Difference between revisions

Jump to navigation Jump to search
m
no edit summary
(New draft.)
mNo edit summary
Line 66: Line 66:
* open(path, mode, {options}) or open({options})
* open(path, mode, {options}) or open({options})
*# options may include {path, mode, charset, recordSeparator, fieldSeparator} and more in a later, more detailed specification.
*# options may include {path, mode, charset, recordSeparator, fieldSeparator} and more in a later, more detailed specification.
*# The mode is a String and may contain:
*# The mode is a String and may additionally contain:
*## "b" for ByteArray and ByteString streams.
*## "b" for ByteArray and ByteString streams.
*## "t" for String and Array streams (default)
*## "t" for String and Array streams (default)
Line 81: Line 81:
** read(max:Number) -> actual:Number
** read(max:Number) -> actual:Number
** readInto(buffer:Array|ByteArray, [begin:Number, [end:Number]]) -> actual:Number
** readInto(buffer:Array|ByteArray, [begin:Number, [end:Number]]) -> actual:Number
** available() -> Number -- how many bytes are ready to be read (buffered) without blocking.
** skip(n:Number) -> advance the read head past these bytes.
* BinaryWriteStream
* BinaryWriteStream
** write(buffer:Array|ByteArray|ByteString)
** write(buffer:Array|ByteArray|ByteString)
** truncate(length:Number=0)
** flush()
** flush()
* BinaryRandomStream < BinaryReadStream < BinaryWriteStream
* BinaryRandomStream < BinaryReadStream < BinaryWriteStream
Line 93: Line 96:
** next() -> String -- throws a StopIteration if no data is available before EOF.
** next() -> String -- throws a StopIteration if no data is available before EOF.
** input() -> returns "readLine" without the "recordSeparator".
** input() -> returns "readLine" without the "recordSeparator".
** available() -> Number -- how many characters are ready to be read (buffered) without blocking.
** skip(n:Number) -> advance the read head past these characters.
* TextWriteStream
* TextWriteStream
** raw -> a BinaryWriteStream
** raw -> a BinaryWriteStream
Line 159: Line 164:
*# stat() -> stat:Object {mtime:Date, size:Number}
*# stat() -> stat:Object {mtime:Date, size:Number}
*# to(path:String|Path) -> path:Path -- an alias for "relative" that finds the relative path from this path to the given one.
*# to(path:String|Path) -> path:Path -- an alias for "relative" that finds the relative path from this path to the given one.
*# toString() -> String
*# touch([mtime:Date])
*# touch([mtime:Date])
*# write(data:ByteString|ByteArray|Array|String, [mode, [options]])
*# write(data:ByteString|ByteArray|Array|String, [mode, [options]])
171

edits

Navigation menu