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

redbone

Package Overview
Dependencies
Maintainers
2
Versions
31
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

redbone - npm Package Compare versions

Comparing version 2.0.2 to 2.0.3

67

lib/classes/Redbone.js

@@ -7,2 +7,11 @@ const isFunction = require('lodash/isFunction');

/**
* Redbone main class
* @class Redbone
* @prop {Object} io socket.io instance
* @prop {Array} middlewares array of middlewares
* @prop {Map} watchers watchers map; keys — type for watcher fn
* @prop {Function} catcher function to process errors
* @prop {Object} types default redbone types for socket lifecicle actions
*/
class Redbone extends EventEmitter {

@@ -32,2 +41,7 @@ constructor(io) {

/**
* Check is middleware is a function
* @param {Function} middleware middleware function
* @return {Boolean} ttue, if middleware is valid
*/
isMiddleware(middleware) {

@@ -40,2 +54,7 @@ if (!isFunction(middleware)) {

/**
* use middleware
* @param {Function} middleware middleware function
* @return {Redbone} this
*/
use(middleware) {

@@ -47,2 +66,8 @@ this.isMiddleware(middleware);

/**
* watch some type
* @param {String} type action.type to watch
* @param {Function} middleware middleware function; it will process when action.type dispatch to server
* @return {Redbone} this
*/
watch(type, middleware) {

@@ -54,2 +79,7 @@ this.isMiddleware(middleware);

/**
* set catcher function
* @param {Function} middleware middleware function for error process
* @return {Redbone} this
*/
catch(middleware) {

@@ -59,4 +89,10 @@ this.isMiddleware(middleware);

this.catcher = middleware;
return this;
}
/**
* dispatch action to all clients
* @param {Object} action do dispatch
* @return {Redbone} this
*/
dispatch(action) {

@@ -67,2 +103,7 @@ this.io.emit('dispatch', action);

/**
* dispatch to client by id
* @param {Object} action to dispatch
* @return {Redbone} this
*/
dispatchTo(id, action) {

@@ -75,2 +116,7 @@ const socket = this.io.sockets.connected[id];

/**
* add watchers by array
* @param {Array} watchers
* @return {Redbone} this
*/
processWatchers(watchers) {

@@ -92,2 +138,8 @@ if (!Array.isArray(watchers)) {

/**
* run socket lifecicle with action
* @param {Socket} socket syntetic Socket
* @param {Object} action to dispatch
* @return {Promise<Redbone>} this
*/
async run(socket, action) {

@@ -107,2 +159,8 @@ try {

/**
* find and run watchers
* @param {Socket} socket syntetic Socket
* @param {Object} action to dispatch
* @return {Promise<Redbone>} this
*/
async runWatchers(socket, action) {

@@ -122,2 +180,7 @@ if (!(action && isString(action.type))) {

/**
* read watchers from dirrectory
* @param {String} dir path to dirrectory
* @return {Promise<Redbone>} this
*/
async readWatchers(dir) {

@@ -143,2 +206,6 @@ const scandir = require('../services/scandir');

/**
* use default redbone options
* @return {Redbone} this
*/
default() {

@@ -145,0 +212,0 @@ this.use(require('../middlewares/intel'));

2

package.json
{
"name": "redbone",
"version": "2.0.2",
"version": "2.0.3",
"description": "Polymorphic library for two way redux dispatching",

@@ -5,0 +5,0 @@ "main": "index.js",

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc