1.0.13 • Published 6 years ago

named-counter v1.0.13

Weekly downloads
3
License
MIT
Repository
github
Last release
6 years ago

du-node-utils

dueros node utils

NPM version npm download David deps

install

npm install named-counter -S

usage

const namedCounter = require('named-counter');
namedCounter.increase('all_cnt');
namedCounter.increaseOnce(req, 'req_cnt');
namedCounter.decrease('all_cnt');
namedCounter.decrease(req, 'req_cnt');
namedCounter.toString() // all_cnt:2  样式string

increaseOnce: an same object increase once decreaseOnce: an same object decrease once

example

express.use((req, res, next) => {
	namedCounter.increase('all_cnt');
	namedCounter.increaseOnce(req, 'req_cnt');
	onFinished(res, (err, res) => {
		namedCounter.decreaseOnce(req, 'req_cnt');
		namedCounter.decrease('all_cnt');
		if (err) {
			logger.warn('logid:%s onFinish error:%s', logid, err.stack);
		}
		console.log(namedCounter.toString());
	});
	next();
});
1.0.13

6 years ago

1.0.12

6 years ago

1.0.11

6 years ago

1.0.10

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.3

6 years ago