async-file

  • Version 2.0.2
  • Published
  • 1 dependency
  • MIT license

Install

npm i async-file
yarn add async-file
pnpm add async-file

Overview

Adapts the Node.js File System API (fs) for use with TypeScript async/await

Index

Functions

function access

access: (path: string, mode?: number | string) => Promise<void>;

    function appendFile

    appendFile: (
    file: string | number,
    data: any,
    options?: {
    encoding?:
    | 'ascii'
    | 'base64'
    | 'binary'
    | 'hex'
    | 'ucs2'
    | 'utf16le'
    | 'utf8';
    mode?: number | string;
    flag?:
    | 'r'
    | 'r+'
    | 'rs'
    | 'rs+'
    | 'w'
    | 'wx'
    | 'w+'
    | 'wx+'
    | 'a'
    | 'ax'
    | 'a+'
    | 'ax+';
    }
    ) => Promise<void>;

      function chmod

      chmod: (path: string, mode: number | string) => Promise<void>;

        function chown

        chown: (path: string, uid: number, gid: number) => Promise<void>;

          function close

          close: (fd: number) => Promise<void>;

            function createDirectory

            createDirectory: (path: string, mode?: number | string) => Promise<void>;

              function delete

              delete: (path: string) => Promise<void>

                function exists

                exists: (path: string) => Promise<boolean>;

                  function fchmod

                  fchmod: (fd: number, mode: number | string) => Promise<void>;

                    function fchown

                    fchown: (fd: number, uid: number, gid: number) => Promise<void>;

                      function fstat

                      fstat: (fd: number) => Promise<fs.Stats>;

                        function fsync

                        fsync: (fd: number) => Promise<void>;

                          function ftruncate

                          ftruncate: (fd: number, len?: number) => Promise<void>;

                            function futimes

                            futimes: (
                            fd: number,
                            atime: Date | number,
                            mtime: Date | number
                            ) => Promise<void>;

                              function lchmod

                              lchmod: (path: string, mode: number | string) => Promise<void>;

                                function lchown

                                lchown: (path: string, uid: number, gid: number) => Promise<void>;
                                  link: (srcpath: string, dstpath: string) => Promise<void>;

                                    function lstat

                                    lstat: (path: string) => Promise<fs.Stats>;

                                      function mkdir

                                      mkdir: (path: string, mode?: number | string) => Promise<void>;

                                        function mkdirp

                                        mkdirp: (path: string, mode?: number | string) => Promise<void>;

                                          function mkdtemp

                                          mkdtemp: (path: string) => Promise<string>;

                                            function open

                                            open: (
                                            path: string,
                                            flags:
                                            | 'r'
                                            | 'r+'
                                            | 'rs'
                                            | 'rs+'
                                            | 'w'
                                            | 'wx'
                                            | 'w+'
                                            | 'wx+'
                                            | 'a'
                                            | 'ax'
                                            | 'a+'
                                            | 'ax+',
                                            mode?: number | string
                                            ) => Promise<number>;

                                              function read

                                              read: (
                                              fd: number,
                                              buffer: Buffer,
                                              offset: number,
                                              length: number,
                                              position: number
                                              ) => Promise<{ bytesRead: number; buffer: Buffer }>;

                                                function readdir

                                                readdir: (path: string) => Promise<string[]>;

                                                  function readFile

                                                  readFile: (
                                                  file: string | number,
                                                  options?:
                                                  | {
                                                  encoding?:
                                                  | 'ascii'
                                                  | 'base64'
                                                  | 'binary'
                                                  | 'hex'
                                                  | 'ucs2'
                                                  | 'utf16le'
                                                  | 'utf8';
                                                  flag?:
                                                  | 'r'
                                                  | 'r+'
                                                  | 'rs'
                                                  | 'rs+'
                                                  | 'w'
                                                  | 'wx'
                                                  | 'w+'
                                                  | 'wx+'
                                                  | 'a'
                                                  | 'ax'
                                                  | 'a+'
                                                  | 'ax+';
                                                  }
                                                  | 'ascii'
                                                  | 'base64'
                                                  | 'binary'
                                                  | 'hex'
                                                  | 'ucs2'
                                                  | 'utf16le'
                                                  | 'utf8'
                                                  | 'r'
                                                  | 'r+'
                                                  | 'rs'
                                                  | 'rs+'
                                                  | 'w'
                                                  | 'wx'
                                                  | 'w+'
                                                  | 'wx+'
                                                  | 'a'
                                                  | 'ax'
                                                  | 'a+'
                                                  | 'ax+'
                                                  ) => Promise<any>;
                                                    readlink: (path: string) => Promise<string>;

                                                      function readTextFile

                                                      readTextFile: (
                                                      file: string | number,
                                                      encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf16le' | 'utf8',
                                                      flags?:
                                                      | 'r'
                                                      | 'r+'
                                                      | 'rs'
                                                      | 'rs+'
                                                      | 'w'
                                                      | 'wx'
                                                      | 'w+'
                                                      | 'wx+'
                                                      | 'a'
                                                      | 'ax'
                                                      | 'a+'
                                                      | 'ax+'
                                                      ) => Promise<string>;

                                                        function realpath

                                                        realpath: (path: string, cache?: { [path: string]: string }) => Promise<string>;

                                                          function rename

                                                          rename: (oldPath: string, newPath: string) => Promise<void>;

                                                            function rimraf

                                                            rimraf: (path: string) => Promise<void>;

                                                              function rmdir

                                                              rmdir: (path: string) => Promise<void>;

                                                                function stat

                                                                stat: (path: string) => Promise<fs.Stats>;
                                                                  symlink: (srcpath: string, dstpath: string, type?: string) => Promise<void>;

                                                                    function truncate

                                                                    truncate: (path: string, len?: number) => Promise<void>;
                                                                      unlink: (path: string) => Promise<void>;

                                                                        function utimes

                                                                        utimes: (
                                                                        path: string,
                                                                        atime: Date | number,
                                                                        mtime: Date | number
                                                                        ) => Promise<void>;

                                                                          function write

                                                                          write: {
                                                                          (
                                                                          fd: number,
                                                                          buffer: Buffer,
                                                                          offset: number,
                                                                          length: number,
                                                                          position?: number
                                                                          ): Promise<{ written: number; buffer: Buffer }>;
                                                                          (
                                                                          fd: number,
                                                                          data: any,
                                                                          offset?: number,
                                                                          encoding?:
                                                                          | 'ascii'
                                                                          | 'base64'
                                                                          | 'binary'
                                                                          | 'hex'
                                                                          | 'ucs2'
                                                                          | 'utf16le'
                                                                          | 'utf8'
                                                                          ): Promise<{ written: number; buffer: Buffer }>;
                                                                          };

                                                                            function writeFile

                                                                            writeFile: (
                                                                            file: string | number,
                                                                            data: string | any,
                                                                            options?:
                                                                            | {
                                                                            encoding?:
                                                                            | 'ascii'
                                                                            | 'base64'
                                                                            | 'binary'
                                                                            | 'hex'
                                                                            | 'ucs2'
                                                                            | 'utf16le'
                                                                            | 'utf8';
                                                                            flag?:
                                                                            | 'r'
                                                                            | 'r+'
                                                                            | 'rs'
                                                                            | 'rs+'
                                                                            | 'w'
                                                                            | 'wx'
                                                                            | 'w+'
                                                                            | 'wx+'
                                                                            | 'a'
                                                                            | 'ax'
                                                                            | 'a+'
                                                                            | 'ax+';
                                                                            mode?: number | string;
                                                                            }
                                                                            | 'ascii'
                                                                            | 'base64'
                                                                            | 'binary'
                                                                            | 'hex'
                                                                            | 'ucs2'
                                                                            | 'utf16le'
                                                                            | 'utf8'
                                                                            | 'r'
                                                                            | 'r+'
                                                                            | 'rs'
                                                                            | 'rs+'
                                                                            | 'w'
                                                                            | 'wx'
                                                                            | 'w+'
                                                                            | 'wx+'
                                                                            | 'a'
                                                                            | 'ax'
                                                                            | 'a+'
                                                                            | 'ax+'
                                                                            ) => Promise<void>;

                                                                              function writeTextFile

                                                                              writeTextFile: (
                                                                              file: string | number,
                                                                              data: string,
                                                                              encoding?: 'ascii' | 'base64' | 'binary' | 'hex' | 'ucs2' | 'utf16le' | 'utf8',
                                                                              flags?:
                                                                              | 'r'
                                                                              | 'r+'
                                                                              | 'rs'
                                                                              | 'rs+'
                                                                              | 'w'
                                                                              | 'wx'
                                                                              | 'w+'
                                                                              | 'wx+'
                                                                              | 'a'
                                                                              | 'ax'
                                                                              | 'a+'
                                                                              | 'ax+',
                                                                              mode?: number | string
                                                                              ) => Promise<void>;

                                                                                Package Files (1)

                                                                                Dependencies (1)

                                                                                Dev Dependencies (2)

                                                                                Peer Dependencies (0)

                                                                                No peer dependencies.

                                                                                Badge

                                                                                To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/async-file.

                                                                                • Markdown
                                                                                  [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/async-file)
                                                                                • HTML
                                                                                  <a href="https://www.jsdocs.io/package/async-file"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>