Skip to content

Commit

Permalink
Removed applyDefaults helper in favor of _.defaults
Browse files Browse the repository at this point in the history
  • Loading branch information
mdb committed Feb 14, 2013
1 parent 93f82ce commit dc6b243
Show file tree
Hide file tree
Showing 3 changed files with 1 addition and 34 deletions.
13 changes: 0 additions & 13 deletions lib/helpers.js
@@ -1,18 +1,5 @@
var _ = require('underscore');

exports.applyDefaults = function (obj, defaults) {
var mergedObj = obj || {};
var setting;

for (setting in defaults) {
if (defaults.hasOwnProperty(setting) && !obj[setting]) {
obj[setting] = defaults[setting];
}
}

return mergedObj;
};

exports.initialCap = function (str) {
return str.charAt(0).toUpperCase() + str.slice(1);
};
Expand Down
2 changes: 1 addition & 1 deletion lib/phl_pac_complaints.js
Expand Up @@ -17,7 +17,7 @@ function PhlPacComplaints(opts) {
}
};

this.settings = opts ? helpers.applyDefaults(opts, this.defaultSettings) : this.defaultSettings;
this.settings = opts ? _.defaults(opts, this.defaultSettings) : this.defaultSettings;
}

PhlPacComplaints.prototype.get = function (params, callback) {
Expand Down
20 changes: 0 additions & 20 deletions test/helpers.js
Expand Up @@ -2,26 +2,6 @@ var expect = require('expect.js');
var helpers = require('../lib/helpers');

describe("helpers", function() {
describe("#applyDefaults", function () {
it("it applies default properties to an object", function () {
expect(helpers.applyDefaults({}, {
a: 1,
b: 2
})).to.eql({a: 1, b: 2});
});

it("overrides default properties with specified new values", function () {
expect(helpers.applyDefaults({
a: 'a',
b: 'b'
}, {
a: 1,
b: 2,
c: 3
})).to.eql({a: 'a', b: 'b', c: 3});
});
});

describe("#initalCap", function () {
it("exists", function () {
expect(typeof helpers.initialCap).to.eql('function');
Expand Down

0 comments on commit dc6b243

Please sign in to comment.