Skip to content

Commit

Permalink
Merge a1e3d6b into 482fd63
Browse files Browse the repository at this point in the history
  • Loading branch information
m0rtadelo committed Jul 25, 2020
2 parents 482fd63 + a1e3d6b commit e261dcd
Show file tree
Hide file tree
Showing 9 changed files with 164 additions and 14 deletions.
1 change: 1 addition & 0 deletions .gitignore
Expand Up @@ -5,3 +5,4 @@ node_modules/*
test/test/*
coverage/*
module.min.js
build/
4 changes: 3 additions & 1 deletion .npmignore
Expand Up @@ -9,4 +9,6 @@ module.min.js
package*
.eslintignore
.eslintrc.json
docs/
docs/
module.js
rollup.config.js
4 changes: 3 additions & 1 deletion CHANGELOG
Expand Up @@ -39,4 +39,6 @@
1.1.6
fix npm vulnerabilities
1.1.7
fix issue 3 & 10 (are the same)
fix issue 3 & 10 (are the same)
1.1.8
add support to ES6 modules
16 changes: 10 additions & 6 deletions README.md
Expand Up @@ -5,36 +5,40 @@
![GitHub top language](https://img.shields.io/github/languages/top/m0rtadelo/recursive-readdir-async.svg)
[![npm version](https://badge.fury.io/js/recursive-readdir-async.svg)](https://badge.fury.io/js/recursive-readdir-async)
# recursive-readdir-async
NPM Module to recursive read directory async (non blocking). Returns Promise. Configurable, with callback for extended filtering and progress status. Quiet, NO dependencies.
As non blocking module it is perfect to be used in any javascript based Desktop applications.
NPM Module to recursive read directory async (non blocking). Returns Promise. Configurable, with callback for extended filtering and progress status. Quiet, NO dependencies. As non blocking module it is perfect to be used in any javascript based Desktop applications.
>This module uses Promises and can't be used in old javascript engines.
>Compatible with CommonJS (require key) and ES6 (import key).
## Installation
For normal usage into a project, you must install as a NPM dependency. The next command will do all the work:
```
npm install --save recursive-readdir-async
```
After install, you can use the module using the *require* key:
After install, you can use the module using the *require* key (CommonJS):
```javascript
// Assign recursive-readdir-async to constant
const rra = require('recursive-readdir-async')
// use it
```
or using the *import* key (ES6):
```typescript
// Import ES6 module
import * as rra from 'recursive-readdir-async'
// use it
```
## Usage
Example of basic usage:
```javascript
const rra = require('recursive-readdir-async');
const list = await rra.list('.');
console.log(list)
```
```javascript
const rra = require('recursive-readdir-async');
rra.list('.').then(function(list){
console.log(list)
})
```
Example with full features:
```javascript
const rra = require('recursive-readdir-async');
const options = {
mode: rra.LIST,
recursive: true,
Expand Down
6 changes: 3 additions & 3 deletions module.js
Expand Up @@ -109,7 +109,7 @@ module.exports.stat = stat
/**
* Returns a Promise with content (data) of the file
* @param {string} file the name of the file to read content from
* @param {string} encoding format for returned data (ascii, base64, binary, hex, ucs2/ucs-2/utf16le/utf-16le, utf8/utf-8, latin1). Default: base64
* @param {string=} encoding format for returned data (ascii, base64, binary, hex, ucs2/ucs-2/utf16le/utf-16le, utf8/utf-8, latin1). Default: base64
* @returns {Promise<any>} data content string (base64 format by default)
*/
async function readFile (file, encoding) {
Expand Down Expand Up @@ -327,8 +327,8 @@ async function statDirItem (list, i, settings, progress, deep) {
/**
* Returns a javascript object with directory items information (non blocking async with Promises)
* @param {string} path the path to start reading contents
* @param {Options} options options (mode, recursive, stats, ignoreFolders)
* @param {CallbackFunction} progress callback with item data and progress info for each item
* @param {Options=} options options (mode, recursive, stats, ignoreFolders)
* @param {CallbackFunction=} progress callback with item data and progress info for each item
* @returns {Promise<File[]|Folder[]>} promise array with file/folder information
* @async
*/
Expand Down
112 changes: 111 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 6 additions & 2 deletions package.json
@@ -1,13 +1,15 @@
{
"name": "recursive-readdir-async",
"version": "1.1.7",
"version": "1.1.8",
"description": "Module to recursive read directory async (non blocking). Must be used with Promises. Configurable, extended filtering. etc.",
"main": "module.js",
"main": "build/module.cjs.js",
"module": "build/module.esm.js",
"scripts": {
"test": "nyc mocha",
"coverage": "nyc --reporter=lcov --reporter=text-lcov npm test",
"coveralls": "jsdoc module.js -d ./docs -R ./README.md && nyc npm test && nyc report --reporter=text-lcov | coveralls",
"build": "uglifyjs --compress --mangle reserved=[file,path,options,progress] --comments -- module.js > module.min.js && jsdoc module.js -d ./docs -R ./README.md",
"release": "rollup -c",
"lint": "eslint ."
},
"engines": {
Expand Down Expand Up @@ -39,6 +41,7 @@
},
"license": "MIT",
"devDependencies": {
"@rollup/plugin-node-resolve": "^8.4.0",
"coveralls": "^3.1.0",
"eslint": "^5.16.0",
"eslint-config-standard": "^12.0.0",
Expand All @@ -50,6 +53,7 @@
"jsdoc": "^3.6.4",
"mocha": "^5.2.0",
"nyc": "^14.1.1",
"rollup": "^2.22.1",
"uglify-es": "^3.3.10"
}
}
20 changes: 20 additions & 0 deletions rollup.config.js
@@ -0,0 +1,20 @@
import resolve from '@rollup/plugin-node-resolve'

import pkg from './package.json'

export default {
input: 'module.js',
output: [
{
file: pkg.main,
format: 'cjs',
sourcemap: true
},
{
file: pkg.module,
format: 'es',
sourcemap: true
}
],
plugins: [resolve()]
}
7 changes: 7 additions & 0 deletions test.ts
@@ -0,0 +1,7 @@
import * as rra from './build/module.esm'

console.log('start')
rra.list('./test').then(data => {
console.log(data)
})
console.log('end')

0 comments on commit e261dcd

Please sign in to comment.