repl.txt (1722B)
1 2 {{alias}}( file, data[, options], clbk ) 3 Asynchronously writes data to a file. 4 5 Parameters 6 ---------- 7 file: string|Buffer|integer 8 Filename or file descriptor. 9 10 data: string|Buffer 11 Data to write. 12 13 options: Object|string (optional) 14 Options. If a string, the value is the encoding. 15 16 options.encoding: string|null (optional) 17 Encoding. The encoding option is ignored if the data argument is a 18 buffer. Default: 'utf8'. 19 20 options.flag: string (optional) 21 Flag. Default: 'w'. 22 23 options.mode: integer (optional) 24 Mode. Default: 0o666. 25 26 clbk: Function 27 Callback to invoke upon writing data to a file. 28 29 Examples 30 -------- 31 > function onWrite( error ) { 32 ... if ( error ) { 33 ... console.error( error.message ); 34 ... } 35 ... }; 36 > {{alias}}( './beep/boop.txt', 'beep boop', onWrite ); 37 38 39 {{alias}}.sync( file, data[, options] ) 40 Synchronously writes data to a file. 41 42 Parameters 43 ---------- 44 file: string|Buffer|integer 45 Filename or file descriptor. 46 47 data: string|Buffer 48 Data to write. 49 50 options: Object|string (optional) 51 Options. If a string, the value is the encoding. 52 53 options.encoding: string|null (optional) 54 Encoding. The encoding option is ignored if the data argument is a 55 buffer. Default: 'utf8'. 56 57 options.flag: string (optional) 58 Flag. Default: 'w'. 59 60 options.mode: integer (optional) 61 Mode. Default: 0o666. 62 63 Returns 64 ------- 65 err: Error|null 66 Error object or null. 67 68 Examples 69 -------- 70 > var err = {{alias}}.sync( './beep/boop.txt', 'beep boop' ); 71 72 See Also 73 -------- 74