fs.write
fs.write
Function
Overwrite the contents of the written file.
Syntax
fs(path).write(content)
Parameters
| Parameters | Type | Required | Default value | Description |
|---|---|---|---|---|
| content | Any | No | '' | Content to write; arrays and objects write JSON strings. |
Return value
| Type | Description |
|---|---|
| Int | Returns the number of bytes written. |
Example
file = fs('docs-write.txt') result = file.write('BT') // Output: 2 print result
Notes
- Existing file contents will be overwritten.
- When the parent directory does not exist, the underlying file writing rules determine whether to report an error.