Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

akuku

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

akuku - npm Package Compare versions

Comparing version 1.0.0 to 1.1.0

lib/dummy.js

6

History.md
1.1.0 / 2018-05-24
==================
* improve output formatting
* add support for enabling by setting AKUKU env variable
1.0.0 / 2018-05-23

@@ -3,0 +9,0 @@ ==================

19

index.js

@@ -1,1 +0,18 @@

module.exports = require('./lib/akuku');
const akuku = require('./lib/akuku');
const dummy = require('./lib/dummy');
module.exports = checkEnvironment() ? akuku : dummy;
function checkEnvironment() {
let env = process.env.AKUKU;
if (!env) {
return false;
}
switch (env.toLowerCase()) {
case '1':
case 'on':
case 'true':
return true;
}
return false;
}

15

lib/akuku.js

@@ -1,2 +0,2 @@

const { addNanos, toHuman } = require('./tools');
const { addNanos, formatTiming, formatCounters } = require('./tools');
const makeCounters = require('./counters');

@@ -22,5 +22,4 @@

function toString() {
let activeStr = toHuman(active);
return `${counter} ${name}: ${activeStr}`;
function toString(prefix = '') {
return formatTiming(counter, name, active, prefix);
}

@@ -39,3 +38,5 @@

console.log(toString());
console.log(counters.toString());
if (!counters.empty()) {
console.log(formatCounters(counters.toObject()));
}
}

@@ -45,4 +46,4 @@

process.on('SIGUSR2', function() {
let active = activeFrom ? '+++ active' : '--- inactive';
console.log(active + '\t' + toString());
let active = activeFrom ? '+++ active ' : '--- inactive';
console.log(toString(active));
});

@@ -49,0 +50,0 @@ }

@@ -0,1 +1,3 @@

const { formatCounters } = require('./tools');
module.exports = makeCounter;

@@ -18,7 +20,3 @@

function toString() {
let strings = new Array(counters.length);
for(let i = 0; i < strings.length; i++) {
strings[i] = `${counters[i]} ${labels[i]}`;
}
return strings.join('\n');
return formatCounters(toObject());
}

@@ -34,4 +32,9 @@

function empty() {
return counters.length === 0;
}
return {
add,
empty,
toString,

@@ -38,0 +41,0 @@ toObject

module.exports = {
addNanos,
toHuman
toHuman,
formatCounters,
formatTiming
};

@@ -38,1 +40,18 @@

}
const NUMBER_LEN = Number.MAX_SAFE_INTEGER.toString().length;
const NAME_LEN = 25;
function formatCounters(counters, prefix = '') {
let strings = Object.entries(counters)
.map(([n, v]) => `${prefix}${v.toString().padStart(NUMBER_LEN)} ${n}`);
return strings.join('\n');
}
function formatTiming(counter, name, nanos, prefix = '') {
let nanosStr = toHuman(nanos);
let counterStr = counter.toString().padStart(NUMBER_LEN);
let nameStr = name.padEnd(NAME_LEN);
return `${prefix}${counterStr} ${nameStr} ${nanosStr}`;
}
{
"name": "akuku",
"version": "1.0.0",
"version": "1.1.0",
"description": "Small timing counter utility.",

@@ -5,0 +5,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc