co-file

2.0.7 • Public • Published

Abandoned...till 2.0.7

co-file provides some file handlers in node.

What

It provides:

  • create file/folder
  • remove file/folder
  • copy file/folder
  • read file/folder

How

const coFile = require('co-file');
  • create file
co(function*() {
    yield coFile.create(srcFileOrFolderPath);
});

srcFileOrFolderPath should be an absolute path.

  • remove file/folder
co(function*() {
    yield coFile.remove(srcFileOrFolderPath);
});

srcFileOrFolderPath should be an absolute path.

  • copy file/folder
co(function*() {
    yield coFile.copy(srcFileOrFolderPath, targetFolderPath);
});

srcFileOrFolderPath and targetFolderPath should be absolute paths.

  • read file/folder
co(function*() {
    yield coFile.read(srcFileOrFolderPath, function(dirPath, files) {
    
        // callback when read dir.
        // dirPath: absolute dir path
        // files: array of filename
        
    }, function (filePath, fileContentBuffer) {
    
        // callback when read file.
        // filePath: absolute file path
        // fileContentBuffer: file content buffer, you can use `fileContentBuffer.toString()` to make it to string.
        
    });
});

srcFileOrFolderPath should be an absolute path.

Test

npm run test

Readme

Keywords

Package Sidebar

Install

npm i co-file

Weekly Downloads

0

Version

2.0.7

License

ISC

Last publish

Collaborators

  • antfoot