@bbk47/toolbox 1.0.5 → 1.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Binary file
package/lib/index.js CHANGED
@@ -3,3 +3,4 @@ exports.logger = require('./logger');
3
3
  exports.md5 = require('./md5');
4
4
  exports.socks5 = require('./socks5');
5
5
  exports.uuid = require('./uuid');
6
+ exports.progress = require('./progress');
package/lib/logger.js CHANGED
@@ -15,10 +15,13 @@ function getCustomLogger(label, level) {
15
15
  function getter(target, key, handler) {
16
16
  if (levelVal[key].piv <= setPiv) {
17
17
  const colour = levelVal[key].colour;
18
- return function (msg) {
18
+ return function () {
19
+ let args = [].slice.call(arguments);
19
20
  let date = dateFormat('yyyy/MM/dd hh:mm:ss', new Date());
20
21
  var prefix = `${date} [${key[0].toUpperCase()}] ${label} `;
21
- console.log(colour, prefix, msg);
22
+ // console.log(colour, prefix, msg);
23
+ args.unshift(colour,prefix);
24
+ console.log.apply(console, args);
22
25
  };
23
26
  } else {
24
27
  return noop;
@@ -0,0 +1,34 @@
1
+ // const chalk = require('chalk');
2
+
3
+ var print = {
4
+ setFormat: function(fn) {
5
+ this.format = fn || ((result) => 'complete.');
6
+ },
7
+ printStatus(result) {
8
+ if (!this.numOfLinesToClear) {
9
+ this.numOfLinesToClear = true;
10
+ } else {
11
+ process.stdout.moveCursor(0, -1);
12
+ }
13
+ process.stdout.clearLine();
14
+ process.stdout.cursorTo(0);
15
+ let output = this.format(result);
16
+ process.stdout.write(output || 'none');
17
+ },
18
+ };
19
+
20
+ function progress(formatfn) {
21
+ var printer = Object.create(print);
22
+ printer.setFormat(formatfn);
23
+ return printer;
24
+ }
25
+
26
+ // var printer = progress((result) => {
27
+ // return `fetch cve total: ${chalk.cyan(result.total)}, complete:${chalk.green(result.complete)}\n`;
28
+ // });
29
+
30
+ // for (var i = 0; i < 10000; i++) {
31
+ // printer.printStatus({ total: 10000, complete: i });
32
+ // }
33
+
34
+ module.exports = progress;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bbk47/toolbox",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "toolbox for bbk",
5
5
  "main": "lib/index.js",
6
6
  "scripts": {