GithubHelp home page GithubHelp logo

file-js's Introduction

file-js

NPM downloads Build Status Coverage Status github-issues stars forks

Abstract representation of a pathname

Installation

npm install --save file-js

Demo

Features

  • File glob matching
  • File listings
  • Assert file permissions
  • Supports promises
  • Supports synchronous and asynchronous methods
  • Supports recursive operations (copy/delete)

Usage

const File = require('file-js');

const file = File.create('myDir');
const files = await file.getList();
files.forEach(console.log);

const file = File.create('myDirectory');
if (file.isDirectorySync()) {
  console.log('processing directory');
}

Documentation

For more examples and API details, see API documentation

Test

npm test

To generate a test coverage report:

npm run coverage

file-js's People

Contributors

dependabot[bot] avatar j-luong avatar nspragg avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

cejast

file-js's Issues

Delete recursively

Add support for deleteRecursively - delete file/dir and all of its children. Returns true if successful.

const dir = new File('dir');
dir.deleteRecursively();

Support deleteLine

Support deleteLine(number, string) for removing lines from a file:

const File = require("file-js");

new File("myFile")
  .deleteLine(1, "my line1")
  .deleteLine(10, "my line2")
  .save();
  • Should be chainable
  • .save() to commit changes.

Support setLine

Support setLine(number, string) for overriding a given line with text:

const File = require("file-js");

new File("myFile")
  .setLine(1, "my line1")
  .setLine(10, "my line2")
  .save();
  • Should be chainable
  • .save() to commit changes.

Copy Recursively

Add support for copyRecursively.

const source = new File('sourceDir');
const dest = new File('destination');
source.copyRecursively(dest, options);

Supported options:

  • overwrite (boolean, false by default)

Support `getLines`

Support get lines via getLines(...n):

Example:

const lines = new File('someFile').getLines(1, 5, 10);
console.log(lines) // lines 1, 5, 10

Support `asString`

const File = require("file-js");

const f = new File("someFile");
console.log(f.asString()); // prints file contents

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.