Huge News!Announcing our $40M Series B led by Abstract Ventures.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.3.3 to 0.3.4

60

lib/beat.js

@@ -12,5 +12,11 @@ var Beat = module.exports = function Beat(alias, beats) {

for(var alias in item) {
if(typeof item == 'string') alias = item;
else item = item[alias];
if(item[0]=='/') item = rootPath+item;
if(typeof item === 'string') {
alias = item;
}
else {
item = item[alias];
}
if(item[0] === '/') {
item = rootPath+item;
}
this._map[alias] = item;

@@ -28,12 +34,17 @@ break;

Beat.prototype.load = function load(beat) {
if(!beat instanceof Beat)
if(!beat instanceof Beat) {
throw this._error('Can not load Beat "'+beat+'". Expected a instance of Beat.');
for(var key in beat._properties)
}
for(var key in beat._properties) {
this._properties[key] = beat._properties[key];
for(var key in beat._factories)
}
for(var key in beat._factories) {
this._factories[key] = beat._factories[key];
for(var key in beat._factoryDependencies)
}
for(var key in beat._factoryDependencies) {
this._factoryDependencies[key] = beat._factoryDependencies[key];
for(var key in beat._map)
}
for(var key in beat._map) {
this._map[key] = beat._map[key];
}
return this;

@@ -45,6 +56,8 @@ };

Beat.prototype._getBlockInfo = function _getBlockInfo(block) {
if(block instanceof Array)
if(block instanceof Array) {
return {fn:block.pop(), deps:block};
if(typeof block !== 'function')
}
if(typeof block !== 'function') {
throw this._error('Can not get arguments from "'+block+'". Expected a function.');
}
var match = block.toString().match(/^function\s*[^\(]*\(\s*([^\)]*)\)/m);

@@ -58,4 +71,5 @@ var deps = match && match[1] && match[1].split(',').map(function(arg) {

Beat.prototype.value = function value(alias, value) {
if(typeof alias != 'string' && typeof alias != 'number')
if(typeof alias !== 'string' && typeof alias !== 'number') {
throw this._error('Invalid key "'+alias+'" for value "'+value+'"');
}
this._properties[alias] = value;

@@ -70,5 +84,9 @@ return this;

for(var a in this._map) {
var module = typeof this._map[a] == 'string'? this._require(this._map[a]): this._map[a];
if(module instanceof Beat) this.load(module);
else this._properties[a.replace(/(\-\w)/g, function(match){return match[1].toUpperCase();})] = module;
var module = typeof this._map[a] === 'string'? this._require(this._map[a]): this._map[a];
if(module instanceof Beat) {
this.load(module);
}
else {
this._properties[a.replace(/(\-\w)/g, function(match){return match[1].toUpperCase();})] = module;
}
delete this._map[a];

@@ -78,10 +96,13 @@ }

this._path.push(alias);
if(alreadyResolving)
if(alreadyResolving) {
throw this._error('Can not resolve circular dependency for "'+alias+'".');
}
if(typeof this._properties[alias] === 'undefined') {
if(typeof this._factories[alias] === 'undefined')
if(typeof this._factories[alias] === 'undefined') {
throw this._error('No provider for "'+alias+'".');
}
var resolvedDependencies = [];
for(var i=0;i<this._factories[alias].deps.length;i++)
for(var i=0;i<this._factories[alias].deps.length;i++) {
resolvedDependencies.push(this.get(this._factories[alias].deps[i]));
}
this._properties[alias] = this._factories[alias].fn.apply(this, resolvedDependencies);

@@ -97,4 +118,5 @@ delete this._factories[alias];

var resolvedDependencies = [];
for(var i=0;i<info.deps.length;i++)
for(var i=0;i<info.deps.length;i++) {
resolvedDependencies.push(this.get(info.deps[i]));
}
info.fn.apply(this, resolvedDependencies);

@@ -115,2 +137,2 @@ return this;

return options[color]+str+options.reset;
};
}

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

"repository": "git://github.com/edinella/beat.git",
"version": "0.3.3",
"version": "0.3.4",
"license": "MIT",

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

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

# beat [![Build Status](https://travis-ci.org/edinella/beat.png?branch=master)](https://travis-ci.org/edinella/beat)
# beat [![Build Status](https://travis-ci.org/edinella/beat.png?branch=master)](https://travis-ci.org/edinella/beat) [![Code Climate](https://codeclimate.com/github/edinella/beat.png)](https://codeclimate.com/github/edinella/beat)
Simple dependency injection for node

@@ -198,1 +198,7 @@

```
[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/edinella/beat/trend.png)](https://bitdeli.com/free "Bitdeli Badge")
[![githalytics.com alpha](https://cruel-carlota.pagodabox.com/b05323c0f01a424058eff9ee1e6cce63 "githalytics.com")](http://githalytics.com/edinella/beat)
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