Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More

redbone

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redbone - npm Package Compare versions

Comparing version 1.0.0 to 1.0.1

@@ -0,5 +1,13 @@

const path = require('path');
const isArray = require('lodash/isArray');
const isString = require('lodash/isString');
const isFunction = require('lodash/isFunction');
const RedboneError = require('../Errors/RedboneError');
const dispatcher = require('./dispatcher');
const Socket = require('Socket');
const Socket = require('./Socket');
const scandir = require('./scandir');
const handleError = require('./handleError');
const intel = require('../middlewares/intel');
const handleError = require('./handleError');

@@ -50,3 +58,3 @@ /**

/**
* catch proxy to dispatcher.watch
* watch proxy to dispatcher.watch
* @param {String} type action.type of redux action object

@@ -61,3 +69,22 @@ * @param {Function} fn callback function to process watched data (socket, action, next)

/**
* Watchers autoloader
* Read files in the dir dirrectory, and add watchers from them to redbone watch
* @param {String} dir path to dir
* @return {Promise}
*/
redbone.readWatchers = function readWatchers(dir) {
return scandir(dir, function(file) {
const watchers = require(path.join(dir, file));
if (!isArray(watchers)) throw new RedboneError('Watchers is not an array');
watchers.forEach((watcher) => {
if (!(watcher.type && isString(watcher.type))) throw new RedboneError('Watcher type is not defined');
if (!(watcher.action && isFunction(watcher.action))) throw new RedboneError('Watcher action is not defined');
redbone.watch(watcher.type, watcher.action);
});
});
}
redbone.dispatcher = dispatcher;
redbone.Socket = Socket;
redbone.RedboneError = RedboneError;
{
"name": "redbone",
"version": "1.0.0",
"version": "1.0.1",
"description": "",

@@ -18,5 +18,4 @@ "main": "index.js",

"eslint": "^3.16.0",
"pre-commit": "^1.2.2",
"precommit": "^1.2.2"
"pre-commit": "^1.2.2"
}
}