larvitutils
Advanced tools
Comparing version 2.3.0 to 2.3.1
17
index.js
@@ -161,2 +161,19 @@ 'use strict'; | ||
/** | ||
* Genereates a string into an unsigned int | ||
* | ||
* @param {string} str The string to convert | ||
* @return {number} the hashed value | ||
*/ | ||
Utils.prototype.hashUnsignedIntFromString = function hashUnsignedIntFromString(str) { | ||
let hash = 0; | ||
if (str.length === 0) return hash; | ||
for (let i = 0; i < str.length; i++) { | ||
hash += (1 << str.charCodeAt(i)) >>> 0; | ||
} | ||
return hash; | ||
}; | ||
Utils.prototype.Log.prototype.stdout = function stdout(lvl, msg) { | ||
@@ -163,0 +180,0 @@ console.log((new Date()).toISOString().substring(0, 19) + 'Z [' + lvl + '] ' + msg); |
{ | ||
"name": "larvitutils", | ||
"version": "2.3.0", | ||
"version": "2.3.1", | ||
"description": "Misc utils", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -1,2 +0,4 @@ | ||
[![Build Status](https://travis-ci.org/larvit/larvitutils.svg)](https://travis-ci.org/larvit/larvitutils) [![Dependencies](https://david-dm.org/larvit/larvitutils.svg)](https://david-dm.org/larvit/larvitutils.svg) | ||
[![Build Status](https://travis-ci.org/larvit/larvitutils.svg)](https://travis-ci.org/larvit/larvitutils) | ||
[![Dependencies](https://david-dm.org/larvit/larvitutils.svg)](https://david-dm.org/larvit/larvitutils.svg) | ||
[![Coverage Status](https://coveralls.io/repos/github/larvit/larvitutils/badge.svg)](https://coveralls.io/github/larvit/larvitutils) | ||
@@ -3,0 +5,0 @@ # larvitutils |
@@ -95,1 +95,78 @@ 'use strict'; | ||
}); | ||
test('log - Print nothing, even on error, when no valid lvl is set', t => { | ||
const oldStderr = process.stderr.write; | ||
let outputMsg = 'SOMETHING'; | ||
const log = new utils.Log('none'); | ||
process.stderr.write = msg => outputMsg = msg; | ||
log.error('kattbajs'); | ||
process.stderr.write = oldStderr; | ||
t.equal(outputMsg.substring(19), ''); | ||
t.end(); | ||
}); | ||
test('log - Test silly', t => { | ||
const oldStdout = process.stdout.write; | ||
let outputMsg = ''; | ||
const log = new utils.Log('silly'); | ||
process.stdout.write = msg => outputMsg = msg; | ||
log.silly('kattbajs'); | ||
process.stdout.write = oldStdout; | ||
t.equal(outputMsg.substring(19), 'Z [\x1b[1;37msil\x1b[0m] kattbajs\n'); | ||
t.end(); | ||
}); | ||
test('log - Test debug', t => { | ||
const oldStdout = process.stdout.write; | ||
let outputMsg = ''; | ||
const log = new utils.Log('debug'); | ||
process.stdout.write = msg => outputMsg = msg; | ||
log.debug('kattbajs'); | ||
process.stdout.write = oldStdout; | ||
t.equal(outputMsg.substring(19), 'Z [\x1b[1;35mdeb\x1b[0m] kattbajs\n'); | ||
t.end(); | ||
}); | ||
test('log - Test verbose', t => { | ||
const oldStdout = process.stdout.write; | ||
let outputMsg = ''; | ||
const log = new utils.Log('verbose'); | ||
process.stdout.write = msg => outputMsg = msg; | ||
log.verbose('kattbajs'); | ||
process.stdout.write = oldStdout; | ||
t.equal(outputMsg.substring(19), 'Z [\x1b[1;34mver\x1b[0m] kattbajs\n'); | ||
t.end(); | ||
}); | ||
test('log - Test info', t => { | ||
const oldStdout = process.stdout.write; | ||
let outputMsg = ''; | ||
const log = new utils.Log('info'); | ||
process.stdout.write = msg => outputMsg = msg; | ||
log.info('kattbajs'); | ||
process.stdout.write = oldStdout; | ||
t.equal(outputMsg.substring(19), 'Z [\x1b[1;32minf\x1b[0m] kattbajs\n'); | ||
t.end(); | ||
}); | ||
test('log - Test warn', t => { | ||
const oldStderr = process.stderr.write; | ||
let outputMsg = ''; | ||
const log = new utils.Log('warn'); | ||
process.stderr.write = msg => outputMsg = msg; | ||
log.warn('kattbajs'); | ||
process.stderr.write = oldStderr; | ||
t.equal(outputMsg.substring(19), 'Z [\x1b[1;33mwar\x1b[0m] kattbajs\n'); | ||
t.end(); | ||
}); | ||
test('log - Test error', t => { | ||
const oldStderr = process.stderr.write; | ||
let outputMsg = ''; | ||
const log = new utils.Log('silly'); | ||
process.stderr.write = msg => outputMsg = msg; | ||
log.error('kattbajs'); | ||
process.stderr.write = oldStderr; | ||
t.equal(outputMsg.substring(19), 'Z [\x1b[1;31merr\x1b[0m] kattbajs\n'); | ||
t.end(); | ||
}); |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
26856
16
481
147
11
1