Socket
Book a DemoInstallSign in
Socket

call-dir

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

call-dir - npm Package Compare versions

Comparing version

to
1.0.0

.eslintignore

12

dist/index.js

@@ -18,8 +18,9 @@ "use strict";

/**
* Loads files from a `directory` and executes a `callback` for each.
* Load files from a `directory` and execute a `callback` for each.
*
* @param {string} directory - directory to load files from
* @param {function} callback - callback to execute on each file
* @param {string} directory directory to load files from
* @param {function} callback callback to execute on each file
* @return {void}
*/
exports.default = function (directory, callback) {
function call(directory, callback) {
_fs2.default.readdirSync(_path2.default.resolve(process.cwd(), directory)).filter(function (file) {

@@ -30,4 +31,5 @@ return file.indexOf(".") !== 0;

});
};
}
exports.default = call;
module.exports = exports["default"];
{
"name": "call-dir",
"version": "0.0.2",
"version": "1.0.0",
"keywords": [
"callback",
"require",
"directory",
"require",
"load",
"multiple",
"files"
"filter",
"files",
"fs"
],

@@ -24,14 +23,24 @@ "description": "Loads files from a directory and executes a callback for each",

"devDependencies": {
"flow-bin": "^0.56.0",
"babel": "^6.23.0",
"babel-cli": "^6.26.0",
"babel-eslint": "^8.0.1",
"babel-preset-flow": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-stage-0": "^6.24.1",
"babel-plugin-add-module-exports": "^0.2.1"
"babel-plugin-add-module-exports": "^0.2.1",
"eslint": "^4.8.0",
"eslint-config-google": "^0.9.1",
"eslint-plugin-flowtype": "^2.35.0",
"eslint-plugin-import": "^2.7.0"
},
"scripts": {
"test": "npm run eslint && npm run flow",
"flow": "flow",
"clean": "rm -rf dist",
"build": "babel src -d dist",
"watch": "babel src -d dist -w",
"prepare": "npm run clean && npm run build"
"eslint": "node_modules/.bin/eslint --fix src",
"prepare": "npm run clean && npm run test && npm run build"
}
}

@@ -5,3 +5,3 @@ <div align="center">

[![Greenkeeper badge](https://badges.greenkeeper.io/Bartozzz/call-dir.svg)](https://greenkeeper.io/)
[![Build Status](https://img.shields.io/travis/Bartozzz/call-dir.svg)](https://travis-ci.org/Bartozzz/Qilin/)
[![Build Status](https://img.shields.io/travis/Bartozzz/call-dir.svg)](https://travis-ci.org/Bartozzz/call-dir/)
[![npm version](https://img.shields.io/npm/v/call-dir.svg)](https://www.npmjs.com/package/call-dir)

@@ -32,5 +32,5 @@ [![npm downloads](https://img.shields.io/npm/dt/call-dir.svg)](https://www.npmjs.com/package/call-dir)

// You can load multiple modules easily:
// You can initialize modules from a directory easily:
load( "./models", path => require( path )( some, variables, ...here ) );
load( "./routes", path => require( path )( some, variables, ...here ) );
```

@@ -1,14 +0,19 @@

import fs from "fs";
// @flow
import fs from "fs";
import path from "path";
/**
* Loads files from a `directory` and executes a `callback` for each.
* Load files from a `directory` and execute a `callback` for each.
*
* @param {string} directory - directory to load files from
* @param {function} callback - callback to execute on each file
* @param {string} directory directory to load files from
* @param {function} callback callback to execute on each file
* @return {void}
*/
export default ( directory, callback ) => {
fs.readdirSync( path.resolve( process.cwd(), directory ) )
.filter( file => file.indexOf( "." ) !== 0 )
.forEach( file => callback( path.join( directory, file ), file ) );
};
function call(directory: string, callback: (string, string) => any): void {
fs.readdirSync(path.resolve(process.cwd(), directory))
.filter((file) => file.indexOf(".") !== 0)
.forEach((file) => callback(path.join(directory, file), file));
}
export default call;

Sorry, the diff of this file is not supported yet