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

console-dot

Package Overview
Dependencies
Maintainers
1
Versions
4
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

console-dot - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

13

build/index.js

@@ -10,5 +10,10 @@ "use strict";

ConsoleDot.__proto__ = console.__proto__;
ConsoleDot.__proto__.constants = Object.freeze({
DELIMETER: 'console.callback --------',
MESSAGE: 'callback fired',
SHOW_ARGS_MESSAGE: 'showing arguments received --------'
});
ConsoleDot.__proto__.callback = function consoleCallback() {
var showArgs = arguments[0] !== (void 0) ? arguments[0] : true;
var message = arguments[1] !== (void 0) ? arguments[1] : 'callback fired';
var message = arguments[1] !== (void 0) ? arguments[1] : this.constants.MESSAGE;
for (var logMessages = [],

@@ -20,5 +25,9 @@ $__0 = 2; $__0 < arguments.length; $__0++)

return function logCallback() {
self.log.call(self, self.constants.DELIMETER);
self.log.apply(self, logMessages);
if (showArgs)
if (showArgs) {
self.log.call(self, self.constants.SHOW_ARGS_MESSAGE);
self.log.apply(self, arguments);
}
self.log.call(self, self.constants.DELIMETER);
};

@@ -25,0 +34,0 @@ };

@@ -10,2 +10,8 @@

ConsoleDot.__proto__.constants = Object.freeze({
DELIMETER: 'console.callback --------',
MESSAGE: 'callback fired',
SHOW_ARGS_MESSAGE: 'showing arguments received --------'
});
// Provides a callback style curry function that accepts `showArgs` and `...logMessage`

@@ -16,3 +22,3 @@ // `showArgs` can be any truthy/falsy value, and if truthy will additionally output

// defaults: { showArgs: true, logMessage: 'callback fired'}
ConsoleDot.__proto__.callback = function consoleCallback(showArgs = true, message = 'callback fired', ...logMessages) {
ConsoleDot.__proto__.callback = function consoleCallback(showArgs = true, message = this.constants.MESSAGE, ...logMessages) {
var self = this;

@@ -23,5 +29,11 @@

return function logCallback() {
self.log.call(self, self.constants.DELIMETER);
self.log.apply(self, logMessages);
if (showArgs) self.log.apply(self, arguments);
if (showArgs) {
self.log.call(self, self.constants.SHOW_ARGS_MESSAGE);
self.log.apply(self, arguments);
}
self.log.call(self, self.constants.DELIMETER);
}

@@ -28,0 +40,0 @@ };

9

package.json
{
"author": "Stephen Rivas Jr <me@stephenrivasjr.com> (http://stephenrivasjr.com)",
"dependencies" : {},
"dependencies": {},
"devDependencies": {
"lodash": "^2.4.1",
"mocha": "*",

@@ -9,3 +10,3 @@ "should": "4.1.0"

"description": "Lazy debugging console syntax for callbacks & promises.",
"homepage" : "https://github.com/sprjr/console-dot",
"homepage": "https://github.com/sprjr/console-dot",
"keywords": [

@@ -18,3 +19,3 @@ "console",

"name": "console-dot",
"repository" : {
"repository": {
"type": "git",

@@ -27,3 +28,3 @@ "url": "http://github.com/npm/npm.git"

},
"version": "0.1.1"
"version": "0.1.2"
}

@@ -35,3 +35,3 @@ # ConsoleDot

# Usage (More)
## Usage (More)

@@ -43,3 +43,7 @@ `// TODO`

## v0.1.2
Updated test coverage for default behavior, README tweaks, patch version bump.
## v0.1.0
Essentially does the above basic implementation modifying `console` to to provide a `callback()` method that returns a curried function with your message. Keystroke savers, etc.
var ConsoleDot = require('../.'),
Should = require('should');
var _ = require('lodash'),
ConsoleDot = require('../.'),
Should = require('should');

@@ -9,13 +10,72 @@ describe('ConsoleDot Test Suite', function () {

console = ConsoleDot();
})
});
describe('#callback()', function () {
it('should expose a .callback() function', function (done) {
it('should expose a .callback() function', function (passed) {
Should(console).have.property('callback');
Should(console.callback).be.a.Function;
done();
passed();
});
it('should do callbacky console.logs');
describe('should produce desired output', function () {
// http://stackoverflow.com/a/9624028
var hook_stream = function(_stream, fn) {
var old_write = _stream.write;
_stream.write = fn;
return function() {
_stream.write = old_write;
};
},
trim_newline = function (collection) {
return _.map(collection, function (item) {
item = item.replace(/\n$/, '');
return item;
});
},
logs, unhook_stdout;
beforeEach(function () {
logs = [];
});
before(function () {
unhook_stdout = hook_stream(process.stdout, function(string, encoding, fd) {
logs.push(string);
});
});
after(function () {
unhook_stdout();
});
it('should fire with the defaults', function (passed) {
var cb = console.callback();
cb();
unhook_stdout();
logs = trim_newline(logs);
// well this is super tedious feeling
logs.should.have.a.length(5);
logs[0].should.eql(ConsoleDot.constants.DELIMETER);
logs[1].should.eql(ConsoleDot.constants.MESSAGE);
logs[2].should.eql(ConsoleDot.constants.SHOW_ARGS_MESSAGE);
logs[3].should.eql('');
logs[4].should.eql(ConsoleDot.constants.DELIMETER);
passed();
});
it('2 should fire with the defaults', function (passed) {
var cb = console.callback();
cb();
passed();
});
});
});
});
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