npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

monitor-rx

v0.0.6

Published

The rxjs workflow for Node.js monitor app

Readme

Monitor-RX Workflow

使用前需要了解 Rx.js 以及其 Observable

example | 解决的问题

基本使用:

const monitorRx = require('monitor-rx');

const RxModules = {/*你的 Observer 实例集合*/};

let monitorServer = new monitorRx.Server({ RxModules });

let queryItem = {
    id: 'ThisIsAnUniqueId',
    module: 'ModuleName',
    func: 'FuncName',
    args: ['arg1','arg2'],
    opts: {interval:1000},
};

monitorServer.sub(queryItem, {
    next: x => {
        // Handle the result: X
    },
});

setTimeout(() => {
    monitorServer.unSub(queryItem.id);
}, 2400);

Monitor-RX 是一个基于 Rx.js 的多用户监控系统解决方案,可以进行资源复用和管理。

Observer 生成器

上面的 RxModules 是一个 Observer 生成器集合对象,其每一个键名为 Observer 生成器名,而值为对应的 Observer 生成器函数,其可以返回一个 Observer 实例。

如果是一个无依赖的定时任务,我们可以通过 monitor-rx 提供的 convertToRxconvertToSimpleRx 转换成 Observable 生成函数,例如:

var os = require('os');
var process = require('process');
const monitorRx = require('monitor-rx');

function getMemoryInfo() {
    return process.memoryUsage();
}

const memory = monitorRx.Utils.convertToSimpleRx(getMemoryInfo)

// 或者
//const memory = monitorRx.Utils.convertToRx({
//    getMemoryInfo
//});

module.exports = memory;

convertToRx 相比于 convertToSimpleRx,可以支持函数配置注入(即下文中 opts 的 func 属性和 args 属性),可以在具体生成 Observable 实例的时候具体指定使用哪些函数以及其参数。

而如果我们自定义 Observable,我们可以参考我们例子中的 cpu监控函数,其接受三个参数:

function yourObservableCreator(RX, Operators, opts = {}) {
     return RX.Observable.create(function (observer) {
        // your Observable Creator logic
     });
}

RX 和 Operators 即 rxjs 以及其操作符,这里作为参数传入是为了方便使用,opts 中有两部分内容:

  • monitor-rx 会注入一个 funcs 属性,是一个函数名以及其参数的 Map 实例,
  • 其他调用端定义的 opts 属性会跟随传入。

queryItem

queryItem 包含了我们订阅一个 Observable 实例的信息,其 id 和 module 属性是必须的(一个用户应该只有一个 id,用于取消订阅的时候传入,以及进行用户管理),func 和 args 则是监控过程中需要调用的函数,我们也可以通过 agrs 传入用户个人信息。于没有内部子函数调用的监控,二者为空即可,opts 是一些其他可选项,比如定义请求间隔等,会传入到 Observable 生成函数的 opts 中。

更多内容

Monitor-RX 目前正在持续完善中,API 和 文档等正在进行完善,如果你遇到过和我相似的问题,欢迎你一起讨论或者参与 Monitor-RX 的建设中