MCPcopy Create free account
hub / github.com/itinance/react-native-fs / appendFile

Function appendFile

FS.common.js:427–453  ·  view source on GitHub ↗
(filepath: string, contents: string, encodingOrOptions?: any)

Source from the content-addressed store, hash-verified

425 },
426
427 appendFile(filepath: string, contents: string, encodingOrOptions?: any): Promise<void> {
428 var b64;
429
430 var options = {
431 encoding: 'utf8'
432 };
433
434 if (encodingOrOptions) {
435 if (typeof encodingOrOptions === 'string') {
436 options.encoding = encodingOrOptions;
437 } else if (typeof encodingOrOptions === 'object') {
438 options = encodingOrOptions;
439 }
440 }
441
442 if (options.encoding === 'utf8') {
443 b64 = base64.encode(utf8.encode(contents));
444 } else if (options.encoding === 'ascii') {
445 b64 = base64.encode(contents);
446 } else if (options.encoding === 'base64') {
447 b64 = contents;
448 } else {
449 throw new Error('Invalid encoding type "' + options.encoding + '"');
450 }
451
452 return RNFSManager.appendFile(normalizeFilePath(filepath), b64);
453 },
454
455 write(filepath: string, contents: string, position?: number, encodingOrOptions?: any): Promise<void> {
456 var b64;

Callers

nothing calls this directly

Calls 2

normalizeFilePathFunction · 0.85
appendFileMethod · 0.45

Tested by

no test coverage detected