2.0.7 • Published 8 years ago

co-file v2.0.7

Weekly downloads
2
License
ISC
Repository
github
Last release
8 years ago

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

2.0.7

8 years ago

2.0.6

8 years ago

2.0.5

8 years ago

2.0.4

8 years ago

2.0.3

8 years ago

2.0.2

8 years ago

2.0.0

8 years ago

1.0.3

8 years ago

1.0.2

8 years ago

1.0.1

8 years ago

1.0.0

8 years ago