Big News: Socket raises $60M Series C at a $1B valuation to secure software supply chains for AI-driven development.Announcement
Sign In

status-manager

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

status-manager

simple status manager

latest
npmnpm
Version
1.0.0
Version published
Maintainers
1
Created
Source

#简单状态管理

某些任务的执行需要依赖其他基础配置的正确,例如数据库连接, 可以在数据库连接成功时,设置连接状态为true,失败时设为false, 可以在执行任务前使用whether对依赖的状态进行判断。

##方法 set(key,value); get(key) return value; switch(key) set value=!value , return value; whether(keys..) return whether the keys are all true;

##示例

var sm = require('status-manager');

sm.set('mysql',true);
sm.set('redis',true);
sm.set('mongodb',false);
sm.set('net',false);

if(sm.whether('mysql','redis')){
    console.log('mysql and redis has ready!')
}else{
    console.log('mysql and redis has not ready!')
}

if(sm.whether('mysql','mongodb')){
    console.log('mysql and mongodb has ready!')
}else{
    console.log('mysql and mongodb has not ready!')
}

if(sm.whether('mongodb','net')){
    console.log('mongodb and net has ready!')
}else{
    console.log('mongodb and net has not ready!')
}

FAQs

Package last updated on 11 Jul 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