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

function-bootstrapper

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

function-bootstrapper

A bootstrapper library

1.3.0
latest
npm
Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

Bootstrapper

Travis npm
A bootstrapper library

Example ES6:

import Bootstrapper from 'function-bootstrapper';
import Promise from 'bluebird';

const bootstrap = new Bootstrapper({
    ignoreError: true,
    chain: [
        {
            promise: true,
            payload: {
                "importantData": "Hello"  
            },
            function: function(payload) {
                return new Promise((resolve, reject) => {
                    doSomething(payload, (error) => {
                        if (error){
                            reject(error);
                        } else {
                            resolve();
                        }
                    });
                });
            }
        },
        {
            payload: '{"json":true}',
            function: function(payload){
                return JSON.parse(payload);
            }
        }
    ]
});

bootstrap.on('progress',console.log);
bootstrap.promise.then(() => {
    console.log("Finished bootstrap");
}).catch(console.error);

Example normal:

const Bootstrapper = require('function-bootstrapper');
const Promise = require('bluebird');

const bootstrap = new Bootstrapper({
    ignoreError: true,
    chain: [
        {
            promise: true,
            payload: {
                "importantData": "Hello"  
            },
            function: function(payload) {
                return new Promise(function (resolve, reject) {
                    doSomething(payload, (error) => {
                        if (error){
                            reject(error);
                        } else {
                            resolve();
                        }
                    });
                });
            }
        },
        {
            payload: '{"json":true}',
            function: function(payload){
                return JSON.parse(payload);
            }
        }
    ]
});

bootstrap.on('progress',console.log);
bootstrap.promise.then(function () {
    console.log("Finished bootstrap");
}).catch(console.error);

Typedefs

BootChainFragment : Object
BootstrapperConfig : Object

BootChainFragment : Object

Kind: global typedef
Properties

NameTypeDescription
promiseBooleanIf false, it needs to be sync
functionfunction
payload*The payload is the first arguement for the function
ignoreErrorBooleanDon't reject if a error occurs, but only for this fragment
pipeTofunctionThis function will be executed after the main function finished. The first argument is the result of the function.

BootstrapperConfig : Object

Kind: global typedef
Properties

NameTypeDescription
ignoreErrorBooleanDon't reject if a error occurs
parallelBooleanRun Bootchain parallel, how much operation parallel is defined with limit. You only need to define one property, parallel or limit. If not limit is set and parallel is true, cpu core count will be used.
limitintHow much operation parallel. You only need to define one property, parallel or limit. If not limit is set and parallel is true, cpu core count will be used.
chainBootChainFragment[]

FAQs

Package last updated on 26 Feb 2017

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