(filepath: string, contents: string, encodingOrOptions?: any)
| 394 | }, |
| 395 | |
| 396 | writeFile(filepath: string, contents: string, encodingOrOptions?: any): Promise<void> { |
| 397 | var b64; |
| 398 | |
| 399 | var options = { |
| 400 | encoding: 'utf8' |
| 401 | }; |
| 402 | |
| 403 | if (encodingOrOptions) { |
| 404 | if (typeof encodingOrOptions === 'string') { |
| 405 | options.encoding = encodingOrOptions; |
| 406 | } else if (typeof encodingOrOptions === 'object') { |
| 407 | options = { |
| 408 | ...options, |
| 409 | ...encodingOrOptions |
| 410 | }; |
| 411 | } |
| 412 | } |
| 413 | |
| 414 | if (options.encoding === 'utf8') { |
| 415 | b64 = base64.encode(utf8.encode(contents)); |
| 416 | } else if (options.encoding === 'ascii') { |
| 417 | b64 = base64.encode(contents); |
| 418 | } else if (options.encoding === 'base64') { |
| 419 | b64 = contents; |
| 420 | } else { |
| 421 | throw new Error('Invalid encoding type "' + options.encoding + '"'); |
| 422 | } |
| 423 | |
| 424 | return RNFSManager.writeFile(normalizeFilePath(filepath), b64, options).then(() => void 0); |
| 425 | }, |
| 426 | |
| 427 | appendFile(filepath: string, contents: string, encodingOrOptions?: any): Promise<void> { |
| 428 | var b64; |
nothing calls this directly
no test coverage detected