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-operator

v1.0.6

Published

asgc-operator

Readme

欢迎使asgc-operator

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

  • 使用简单 :三行代码可完成运算符定义。
  • 例程丰富 :对于本工具的使用提供了详细的示例程序。

如何使用asgc-operator

1、安装模块

npm install asgc-operator

2、引入模块

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

3、使用内置运算符进行计算

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

//加
console.log($.parse('3+2'));

//中间可以加空格
//减
console.log($.parse('3 -2'));

//乘
console.log($.parse('3 * 2'));

//除
console.log($.parse('3/2'));

//运算符可以包含多个字符
//求余
console.log($.parse('3MOD2'));
console.log($.parse('3 % 2'));

//阶乘
console.log($.parse('5!'));

//取反
console.log($.parse('!true'));

//乘方
console.log($.parse('2 ^ 3'));

3.1、输出结果

5
1
6
1.5
1
1
120
false
8

4、变量赋值、引用

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

//方法名p是parse的简写

//赋值运算
$.p('a = hello');
$.p('b = 3');

//引用变量进行运算
console.log($.p('1 + {b}'));
console.log($.p('{b} ^ 2'));

//没有运算符直接输出
console.log($.p('{a} world'));

4.1、输出结果

4
9
hello world

5、使用上下文

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

//上下文对象
var o = {
	name: '张三'
};

//设置上下文
$.ctx(o);

//为上下文添加age变量,值为20
$.p('age=20');

//输出上下文
console.log(o);

//引用上下文变量
console.log($.p('姓名: {name} , 年龄: {age}'));

5.1、输出结果

{ name: '张三', age: [Number: 20] }
姓名: 张三 , 年龄: 20

6、自定义运算符

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

//双目运算符,o是operator的简写,都可使用
$.o('binary','吃',function(a,b){
	return $.p(a) + '吃了一个' + $.p(b);
});

//为上下文添加变量
$.p('me=傲世孤尘');
$.p('JT=鸡腿');

//调用运算符计算
//不用变量
console.log($.p('张三吃梨子'));
//使用变量
console.log($.p('张三吃{JT}'));
console.log($.p('{me}吃{JT}'));

//单目运算符,操作数后置
//定义平方根
$.o('unaryAfter','sqrt',function(a){
	return Math.sqrt(a);
});

console.log($.p('sqrt 9'));

//单目运算符,操作数前置
//定义hello
$.o('unaryBefore','hello',function(a){
	return a + ' 你好!';
});

console.log($.p('aoshiguchen hello'));

6.1、输出结果

张三吃了一个梨子
张三吃了一个鸡腿
傲世孤尘吃了一个鸡腿
3
aoshiguchen 你好!

asgc-operator相关

asgc-observer

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

asgc-lisen

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

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

联系我们

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