Skip to content

Commit

Permalink
docs: expand some api descriptions
Browse files Browse the repository at this point in the history
  • Loading branch information
alpha0010 committed Apr 29, 2021
1 parent 025e39d commit b0527ec
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 0 deletions.
9 changes: 9 additions & 0 deletions src/native.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,9 @@ type FileAccessType = {
path?: string;
}
): Promise<FetchResult>;
/**
* Only defined on iOS.
*/
getAppGroupDir(groupName: string): Promise<string>;
hash(path: string, algorithm: HashAlgorithm): Promise<string>;
isDir(path: string): Promise<boolean>;
Expand All @@ -45,4 +48,10 @@ type FileAccessType = {
writeFile(path: string, data: string, encoding: Encoding): Promise<void>;
};

/**
* Native module API.
*
* Most functions are the same as the JS wrapper. However native calls do
* not support default parameters.
*/
export const FileAccessNative: FileAccessType = NativeModules.RNFileAccess;
35 changes: 35 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,29 +9,64 @@ export type Encoding = 'utf8' | 'base64';
export type ExternalDir = 'audio' | 'downloads' | 'images' | 'video';

export type FetchResult = {
/**
* Response HTTP headers.
*/
headers: { [key: string]: string };

/**
* True if the response is a 2XX HTTP status.
*/
ok: boolean;

/**
* Note: this value may not be accurate.
*/
redirected: boolean;

/**
* HTTP response status code.
*/
status: number;

/**
* Associated text for HTTP status code.
*/
statusText: string;

/**
* Final URL provided by the HTTP response.
*/
url: string;
};

export type FileStat = {
/**
* Filename does not include the path.
*/
filename: string;
lastModified: number;
path: string;
/**
* File size in bytes.
*/
size: number;
type: 'directory' | 'file';
};

/**
* Values are in bytes.
*/
export type FsStat = {
internal_free: number;
internal_total: number;
external_free?: number;
external_total?: number;
};

/**
* MD5 and SHA-1 are insecure. Avoid when possible.
*/
export type HashAlgorithm =
| 'MD5'
| 'SHA-1'
Expand Down

0 comments on commit b0527ec

Please sign in to comment.