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

node-settings

Package Overview
Dependencies
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-settings - npm Package Compare versions

Comparing version 0.1.1 to 0.1.2

spec/integration/file_source.spec.coffee

81

lib/configurator.js
(function() {
var Configurator, argv, fs, merge,
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; };
__bind = function(fn, me){ return function(){ return fn.apply(me, arguments); }; },
_this = this;

@@ -12,3 +13,2 @@ fs = require('fs');

Configurator = (function() {
var _this = this;

@@ -26,41 +26,6 @@ function Configurator(source) {

Configurator.prototype.config_sources = {
file: {
get: function(options, callback) {
return fs.readFile(options.location, function(err, data) {
throw err(err ? process.nextTick(function() {
return callback(JSON.parse(data));
}) : void 0);
});
},
getSync: function(options) {
var data;
data = fs.readFileSync(options.location);
return JSON.parse(data);
}
},
json: {
get: function(options, callback) {
return process.nextTick(function() {
return callback(options.data);
});
},
getSync: function(options) {
return options.data;
}
},
string: {
get: function(options, callback) {
return callback(JSON.parse(options.data));
},
getSync: function(options) {
return JSON.parse(options.data);
}
}
};
Configurator.prototype.load = function(callback) {
var config_loader,
_this = this;
config_loader = this.config_sources[this.source.name];
config_loader = Configurator.config_sources[this.source.name];
return config_loader.get(this.source.options, function(data) {

@@ -79,3 +44,3 @@ var config, env_config;

var config, config_loader, data, env_config;
config_loader = this.config_sources[this.source.name];
config_loader = Configurator.config_sources[this.source.name];
data = config_loader.getSync(this.source.options);

@@ -90,6 +55,42 @@ config = data["default"] || {};

}).call(this);
})();
Configurator.config_sources = {
file: {
get: function(options, callback) {
return fs.readFile(options.location, options.encoding || 'ascii', function(err, data) {
if (err) throw err;
return process.nextTick(function() {
return callback(eval(data));
});
});
},
getSync: function(options) {
var data;
data = fs.readFileSync(options.location, options.encoding || 'utf8');
return eval(data);
}
},
json: {
get: function(options, callback) {
return process.nextTick(function() {
return callback(options.data);
});
},
getSync: function(options) {
return options.data;
}
},
string: {
get: function(options, callback) {
return callback(eval(options.data));
},
getSync: function(options) {
return eval(options.data);
}
}
};
module.exports = Configurator;
}).call(this);

@@ -5,3 +5,3 @@ {

"description": "Provides easy, multi-environment configuration",
"version": "0.1.1",
"version": "0.1.2",
"homepage": "",

@@ -8,0 +8,0 @@ "repository": {

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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