Giter Club home page Giter Club logo

fileutil's Introduction

fileutil

File utility functions.

  • toBufferEncoding (encoding) ccnverts encoding names to Node's buffer encoding names.
  • detectEncoding (filePath) detects the encoding of some file contents.
  • detectContentsEncoding (buffer) detects the encoding of some contents.
  • ensureDirectoryOf (filePath) checks if a directory exists and, if not, creates it.
  • writeFile (filePath, contents, encoding) writes a file. If the file directory doesn't exit, it is created.
  • subDirs (fromDir): Promise<Dirent[] gets a list of subdirectories.
  • subDirsNames (fromDir): Promise<string[]> gets a list of subdirectories' names.
  • findDirs (fromDirs, excludedDirs): Promise<string[]> finds directories under a set of dirs.
  • findSubDirs (ofDir, excludedDirs = []): Promise<string[]> finds sub-directories of a dir.
  • copy (toDir, sourcePatterns, options): Promise<string[]> copies files to a destination directory.
  • copyFiles (sourceFiles, toDir) {): string[] copies multiple files to a directory.
  • copyFile (sourceFilePath, destDir): string copies a file to a directory.
  • FileContentsLang represents a file language and the detected file variants.
  • FileContents (name, encoding, contents, lastModified, lang): string represents a file with contents:
    • static read(fileName, declaredEncoding) creates FileContents from a file path.
    • static readOrNew(fileName, declaredEncoding) reads a file or instantiate a brand new SsgFile if it doesn't exist.
    • static getLang(filePath): SsgFileLang guesses a file language and its language file variants in the same directory.
    • static getContents(fileName, declaredEncoding) gets the text contents of a file, and how it is encoded.
    • write() writes the file contents according to its encoding.

fileutil's People

Contributors

javarome avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.