Skip to content
This repository has been archived by the owner on May 3, 2023. It is now read-only.

Commit

Permalink
Remove dependency on lodash
Browse files Browse the repository at this point in the history
Node has Object.assign since 4.0.0
  • Loading branch information
jameswyse committed Sep 30, 2016
1 parent 7adfb1a commit a09f2af
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 16 deletions.
11 changes: 6 additions & 5 deletions examples/forecast.io.js → examples/darksky.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
//
// Forecast example
// Darksky / Forecast.io example
//

// Require the forecast module
var Forecast = require('../');

// Initialize with custom settings
var forecast = new Forecast({
service: 'forecast.io',
service: 'darksky.net',
key: 'your-api-key',
units: 'celcius',
cache: true,
Expand All @@ -17,8 +17,10 @@ var forecast = new Forecast({
});

// Retrieve weather information using coordinates (Sydney, Australia)
forecast.get([-33.8683, 151.2086], function(err, result) {
if(err) return console.dir(err);
forecast.get([-33.8683, 151.2086], function (err, result) {
if (err) {
return console.dir(err);
}

console.log('Latitude: %s', result.latitude);
console.log('Longitude: %s', result.longitude);
Expand All @@ -32,5 +34,4 @@ forecast.get([-33.8683, 151.2086], function(err, result) {
Math.round(parseFloat(result.currently.temperature, 10)),
result.currently.humidity * 100
);

});
17 changes: 9 additions & 8 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
* https://github.com/jameswyse/forecast/
*/

var defaults = require('lodash-node/modern/objects/defaults');
var crypto = require('crypto');
var moment = require('moment');
var providers = require('./providers');
Expand All @@ -18,13 +17,15 @@ var providers = require('./providers');
var Forecast = module.exports = function(options) {
this.options = options || {};
this.providers = providers;
this.cache = {};

defaults(this.options, {
service: 'forecast.io',
units: 'celcius',
cache: true,
ttl: { minutes: 30 }
this.cache = {};

this.options = Object.assign({}, options || {}, {
service: 'darksky',
units: 'celcius',
cache: true,
ttl: {
minutes: 30
}
});

if(this.options.key === 'your-api-key') {
Expand Down
5 changes: 2 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,8 @@
],
"main": "index.js",
"dependencies": {
"lodash-node": "2.4.x",
"moment": "^2.8.3",
"request-json": "^0.5.0"
"moment": "^2.15.1",
"request-json": "^0.6.1"
},
"license": "MIT",
"engines": {
Expand Down

0 comments on commit a09f2af

Please sign in to comment.