New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

beat

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

beat - npm Package Compare versions

Comparing version 0.1.1 to 0.2.0

29

lib/beat.js

@@ -9,6 +9,18 @@ var Beat = module.exports = function Beat(alias) {

Beat.prototype._error = function _error(msg) {
var stack = this._path.join(' -> ');
this._path.unshift(colorize(this._alias, 'blue'));
var stack = this._path.map(function(p){return colorize(p, 'blue');}).join(' -> ');
this._path = [];
return new Error((stack ? msg+' (Resolving: '+stack+')' : msg)+' at "'+this._alias+'".');
return new Error(colorize(msg, 'red')+' at '+stack);
};
Beat.prototype.load = function load(beat) {
if(!beat instanceof Beat)
throw this._error('Can not load Beat "'+beat+'". Expected a instance of Beat.');
for(var key in beat._properties)
this._properties[key] = beat._properties[key];
for(var key in beat._factories)
this._factories[key] = beat._factories[key];
for(var key in beat._factoryDependencies)
this._factoryDependencies[key] = beat._factoryDependencies[key];
return this;
};
Beat.prototype._getBlockInfo = function _getBlockInfo(block) {

@@ -61,2 +73,15 @@ if(block instanceof Array)

return this;
};
function colorize(str, color) {
var options = {
red: '\u001b[31m',
green: '\u001b[32m',
yellow: '\u001b[33m',
blue: '\u001b[34m',
magenta: '\u001b[35m',
cyan: '\u001b[36m',
gray: '\u001b[90m',
reset: '\u001b[0m'
};
return options[color]+str+options.reset;
};

2

package.json

@@ -6,3 +6,3 @@ {

"repository": "git://github.com/edinella/beat.git",
"version": "0.1.1",
"version": "0.2.0",
"license": "MIT",

@@ -9,0 +9,0 @@ "main": "lib/beat.js",

@@ -92,2 +92,28 @@ # beat

**load(beatInstance)**: import properies and factories from an Beat instance
Useful to bind different beats
```js
var config = new Beat('config');
config.value('port', 80);
myServer.load(config);
myServer.run(function(app, port){
app.listen(port);
});
```
or in different files
```js
var config = module.exports = new Beat('config');
config.value('port', 80);
```
```js
myServer.load(require('./config'));
myServer.run(function(app, port){
app.listen(port);
});
```
### Annotation

@@ -94,0 +120,0 @@

@@ -128,3 +128,40 @@ var Beat = require('../../');

});
it('.load method should import properties from a beat instance', function(done){
var x = {};
var y = {};
var anotherBeat = new Beat('another');
anotherBeat.value('myValueX', x);
anotherBeat.value('myValueY', y);
beat.load(anotherBeat);
beat.run(function(myValueX, myValueY){
expect(myValueX).to.be.equal(x);
expect(myValueY).to.be.equal(y);
done();
});
});
it('.load method should import factories from a beat instance', function(done){
var x = {};
var y = {};
var anotherBeat = new Beat('another');
anotherBeat.factory('myValueX', function(){return x;});
anotherBeat.factory('myValueY', function(){return y;});
beat.load(anotherBeat);
beat.run(function(myValueX, myValueY){
expect(myValueX).to.be.equal(x);
expect(myValueY).to.be.equal(y);
done();
});
});
it('.load method should import factories with dependencies from a beat instance', function(done){
var x = {};
var anotherBeat = new Beat('another');
anotherBeat.factory('generateX', function(X){return X;});
anotherBeat.value('X', x);
beat.load(anotherBeat);
beat.run(function(generateX){
expect(generateX).to.be.equal(x);
done();
});
});
});
});
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