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

asgc-lisen

v1.1.3

Published

asgc-lisen

Readme

欢迎使asgc-lisen

asgc-lisen是傲世孤尘开源的一个监听变量值、表达式变化的库。基于这个库,笔者已实现一个前段双向绑定的工具。类似于vue、angularjs。特点概述:

  • 使用简单 :三行代码可完成变量的监听。
  • 例程丰富 :对于本工具的使用提供了详细的示例程序。

如何使用asgc-lisen

1、安装模块

npm install asgc-lisen

2、引入模块

var $ = require('asgc-lisen');

3、初识asgc-lisen

var $ = require('asgc-lisen'); 

//监听对象
var obj = {
    a: 12,
    x: 2
};

//获取对象监听器
var listener = lisen(obj);

//每次给obj.x进行赋值操作时就会执行回调
listener.change('x',function(v){
    console.log('set1:',v);
});

//同一个对象的同一个属性支持多个监听
listener.change('x',function(v){
    console.log('set2:',v);
});

//每次获取obj.x的值时就会执行回调
listener.watch('x',function(v){
    console.log('get:',v);
});

obj.x = 1;
obj.x = 2;
obj.x = 3;

console.log(obj.x);

3.1、输出结果

set1: 1
set2: 1
set1: 2
set2: 2
set1: 3
set2: 3
get

4、链式调用

var $ = require('asgc-lisen');

//监听对象
var obj = {
    a: 12,
    x: 2
};

//链式调用
lisen(obj).change('x',function(v){
    console.log('x set1:',v);
}).change('x',function(v){
    console.log('x set2:',v);
}).watch('x',function(v){
    console.log('x get:',v);
}).change('a',function(v){
	console.log('a set:',v);
});

obj.x = 1;
obj.x = 2;
obj.x = 3;
obj.a = 'hello';

console.log(obj.x);

4.1、输出结果

x set1: 1
x set2: 1
x set1: 2
x set2: 2
x set1: 3
x set2: 3
a set: hello
x get: 3
3

5、表达式监听

var $ = require('asgc-lisen');

var obj = {
	name: '张三'
};

/**
 * 表达式监听
 * 1、变量用{{}}括起来
 * 2、绑定监听时,会首先触发一次回调
 * 3、表达式中任何一个变量的改变都会触发表达式回调
 * 4、触发表达式回调时,会将变量的值对变量进行替换,作为监听函数的第一个参数
 * 5、对应的变量如果没有定义,则替换为空串
 * 6、不包含任何变量的表达式,在绑定时触发一次回调,后续不再触发
 */

lisen(obj).el('hello',function(v){
	console.log(v);
});

lisen(obj).el('姓名: {{name}},年龄: {{ age }},性别: {{ sex }}',function(v){
	console.log(v);
});

obj.name = '李四';
obj.age = 20;
obj.sex = '女';

5.1、输出结果

hello
姓名: 张三,年龄: ,性别: 
姓名: 李四,年龄: ,性别: 
姓名: 李四,年龄: 20,性别: 
姓名: 李四,年龄: 20,性别: 女

asgc-lisen相关

asgc-operator

asgc-lisen是傲世孤尘开源的一个运算符定义工具,它内置了一些常见的数学运算(+、-、*、/、...),并且通过接口可以扩展我们自己的运算符,带来前所未有的编程体验。

asgc-observer

asgc-observer是傲世孤尘开源的一个面向事件、消息编程的库。

###asgc-web asgc-web是傲世孤尘开源的一个nodejs web容器,mvc框架。实现了后端路由、请求分发、参数解析、前端模板渲染等等。

联系我们

笔者QQ 1052045476 nodejs交流群 527393872 java交流群 527393872 c/c++语言交流群 251975693