New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

horpyna

Package Overview
Dependencies
Maintainers
1
Versions
80
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

horpyna

promised modules flow control core library

  • 0.7.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
3
decreased by-40%
Maintainers
1
Weekly downloads
 
Created
Source

HORPYNA

Build Status Downloads Downloads NPM version

SHORT DESCRIPTION

This module is for better organizing multiple async processes. If you have:

  • big amount async functions
  • some of them run only if some conditions meet
  • some of them run multiple times
  • you are bored of long promise chains with inner conditional sub chains
  • you want to reuse some parts of promise chains

Then this library is for your project!

It helps with modularity, reusability and testify of your code.

HOW DOES IT WORKS

You split your code into smaller independent parts. Each of them you wrap into Horpyna Component. You customize each component. And then it is funniest part. You can join components together, then built new components from joined components. You can decorate components with other components to modify it functionality.

For example you can have component which consist of 5 other components. You can reuse it, and remove some inner components and replace them with other components.

It is also easy to test. Each component have input and output. In test you set different input data and test output values.

INSTALLATION

npm install horpyna

USAGE

in ES6 syntax but you can use it with ES5 too

EXTENDING COMPONENT

You have to separate your code into smallest code blocks, then create new classes which extending from Horpyna.Component and put in each class your code block

import Horpyna from "horpyna"; 

class CustomComponent1 extends Horpyna.Component {

  onInit() {
    //custom configuration, for example creation of additional channels
  }
  onProcess(request, response) {
    //input data is available from request.input
    //when component finish calculating response send it via response.send(componentResponse)
  }
  
}

export default CustomCOmponent1;

YOU SHOULD BUILD COMPONENTS WITH OPTIONS WHICH SHOULD ALLOW YOUR COMPONENTS TO BE FLEXIBLE

if you wish create your components inline :

let CustomComponent1 = class extends Horpyna.Component {
  onInit() { ... }
  onProcess(request, response) { ... }
}

or even create instances from inline classes

let customComponent1 = new class extends Horpyna.Component {
  onInit() { ... }
  onProcess(request, response) { ... }
}

BUILDING COMPONENT CHAINS

*Your work consists of two parts: create components, create components chains based on your components (or external)

Let assume that we have components in files (components looks like above):

validateParams.js sendErrorMessage.js getEnityFromDb.js calculateSomething.js sendResponse.js

import ValidateParams from "validateParams";
import SendErrorMessage from "sendErrorMessage";
import getEnityFromDb from "GetEnityFromDb";
import CalculateSomething from "calculateSomething";
import SendResponse from "sendResponse";

let validateParams = new ValidateParams();
let 
let validateParams = new SendErrorMessage();

API

LICENSE

MIT

Keywords

FAQs

Package last updated on 22 Jun 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

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