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

mini-owm

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

mini-owm - npm Package Compare versions

Comparing version 1.2.0 to 1.3.0

2

lib/index.js

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

!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("miniOwm",[],e):"object"==typeof exports?exports.miniOwm=e():t.miniOwm=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e){},function(t,e){},function(t,e){},function(t,e,n){"use strict";n.r(e),n.d(e,"coords",(function(){return r.a})),n.d(e,"getAtts",(function(){return o.a})),n.d(e,"IMiniOwm",(function(){return c.a})),n.d(e,"default",(function(){return f})),n.d(e,"Units",(function(){return s}));var i=n(0),r=n.n(i),u=n(1),o=n.n(u),a=n(2),c=n.n(a),s={Standard:"",Metric:"metric",Imperial:"imperial"};function l(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var f=function(){function t(e,n,i,r,u,o){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._apiKey=e||"",this._latitude=n||0,this._longitude=i||0,this._exclude=r||"",this._units=u&&u.trim()?u.trim().toLowerCase():s.Metric,this._units===s.Standard&&(this._units=""),this._language=o&&o.trim()?o.trim().toLowerCase():""}var e,n,i;return e=t,(n=[{key:"apiKey",value:function(t){return this._apiKey=t,this}},{key:"latitude",value:function(t){return this._latitude=t,this}},{key:"longitude",value:function(t){return this._longitude=t,this}},{key:"exclude",value:function(t){return this._exclude=t,this}},{key:"standard",value:function(){return this._units=s.Standard,this}},{key:"metric",value:function(){return this._units=s.Metric,this}},{key:"imperial",value:function(){return this._units=s.Imperial,this}},{key:"language",value:function(t){return this._language=t&&t.trim()?t.trim().toLowerCase():"",this}},{key:"get",value:function(t){var e=this._latitude,n=this._longitude,i=this._exclude,r=this._apiKey,u=this._units,o=this._language,a=t||{},c=a.apiKey||r,l=a.coords?a.coords.latitude:e,f=a.coords?a.coords.longitude:n,d=a.language&&a.language.trim()?a.language.trim().toLowerCase():o,p=a.units&&a.units.trim()?a.units.trim().toLowerCase():u,h=a.exclude||i;if(!c||!l||!f)throw new Error("Missing required parameters for Open Weather Map api call.");var m="https://api.openweathermap.org/data/2.5/onecall?lat=".concat(l,"&lon=").concat(f,"&exclude=").concat(h,"&appid=").concat(c);return p&&p!==s.Standard&&(m="".concat(m,"&units=").concat(p)),d&&(m="".concat(m,"&lang=").concat(d)),fetch(m).then((function(t){return t.json()}))}}])&&l(e.prototype,n),i&&l(e,i),t}()}]).default}));
!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define("miniOwm",[],e):"object"==typeof exports?exports.miniOwm=e():t.miniOwm=e()}(window,(function(){return function(t){var e={};function n(i){if(e[i])return e[i].exports;var r=e[i]={i:i,l:!1,exports:{}};return t[i].call(r.exports,r,r.exports,n),r.l=!0,r.exports}return n.m=t,n.c=e,n.d=function(t,e,i){n.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:i})},n.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},n.t=function(t,e){if(1&e&&(t=n(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var i=Object.create(null);if(n.r(i),Object.defineProperty(i,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var r in t)n.d(i,r,function(e){return t[e]}.bind(null,r));return i},n.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return n.d(e,"a",e),e},n.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},n.p="",n(n.s=3)}([function(t,e){},function(t,e){},function(t,e){},function(t,e,n){"use strict";n.r(e),n.d(e,"coords",(function(){return r.a})),n.d(e,"getAtts",(function(){return u.a})),n.d(e,"IMiniOwm",(function(){return c.a})),n.d(e,"default",(function(){return f})),n.d(e,"Units",(function(){return s}));var i=n(0),r=n.n(i),o=n(1),u=n.n(o),a=n(2),c=n.n(a),s={Standard:"",Metric:"metric",Imperial:"imperial"};function l(t,e){for(var n=0;n<e.length;n++){var i=e[n];i.enumerable=i.enumerable||!1,i.configurable=!0,"value"in i&&(i.writable=!0),Object.defineProperty(t,i.key,i)}}var f=function(){function t(e,n,i,r,o,u){!function(t,e){if(!(t instanceof e))throw new TypeError("Cannot call a class as a function")}(this,t),this._apiKey=e||"",this._latitude=n||0,this._longitude=i||0,this._exclude=r||"",this._units=o&&o.trim()?o.trim().toLowerCase():s.Metric,this._units===s.Standard&&(this._units=""),this._language=u&&u.trim()?u.trim().toLowerCase():""}var e,n,i;return e=t,(n=[{key:"apiKey",value:function(t){return this._apiKey=t,this}},{key:"latitude",value:function(t){return this._latitude=t,this}},{key:"longitude",value:function(t){return this._longitude=t,this}},{key:"exclude",value:function(t){return this._exclude=t,this}},{key:"standard",value:function(){return this._units=s.Standard,this}},{key:"metric",value:function(){return this._units=s.Metric,this}},{key:"imperial",value:function(){return this._units=s.Imperial,this}},{key:"language",value:function(t){return this._language=t&&t.trim()?t.trim().toLowerCase():"",this}},{key:"get",value:function(t){var e=this,n=this._latitude,i=this._longitude,r=this._exclude,o=this._apiKey,u=this._units,a=this._language,c=t||{},l=c.apiKey||o,f=c.coords?c.coords.latitude:n,d=c.coords?c.coords.longitude:i,p=c.language&&c.language.trim()?c.language.trim().toLowerCase():a,h=c.units&&c.units.trim()?c.units.trim().toLowerCase():u,y=c.exclude||r;if(!l||!f||!d)throw new Error("Missing required parameters for Open Weather Map api call.");var g="https://api.openweathermap.org/data/2.5/onecall?lat=".concat(f,"&lon=").concat(d,"&exclude=").concat(y,"&appid=").concat(l);return h&&h!==s.Standard&&(g="".concat(g,"&units=").concat(h)),p&&(g="".concat(g,"&lang=").concat(p)),fetch(g).then((function(t){return t.json()})).then((function(t){return t.current&&(t.current.rain=e.getPrecipitation(t.current.rain),t.current.snow=e.getPrecipitation(t.current.snow)),t.daily&&(t.daily=t.daily.map((function(t){return t.rain=e.getPrecipitation(t.rain),t.snow=e.getPrecipitation(t.snow),t}))),t.hourly&&(t.hourly=t.hourly.map((function(t){return t.rain=e.getPrecipitation(t.rain),t.snow=e.getPrecipitation(t.snow),t}))),t}))}},{key:"getPrecipitation",value:function(t){return t&&t["1h"]?t["1h"]:0}}])&&l(e.prototype,n),i&&l(e,i),t}()}]).default}));
//# sourceMappingURL=index.js.map

@@ -20,3 +20,4 @@ import getAtts from "./getAtts";

get(attributes?: getAtts): Promise<any>;
private getPrecipitation;
}
export default MiniOwm;

@@ -67,6 +67,35 @@ import Units from "./Units";

return fetch(uri)
.then(res => res.json());
.then(res => res.json())
.then(res => {
if (res.current) {
res.current.rain = this.getPrecipitation(res.current.rain);
res.current.snow = this.getPrecipitation(res.current.snow);
}
if (res.daily) {
res.daily = res.daily.map(item => {
item.rain = this.getPrecipitation(item.rain);
item.snow = this.getPrecipitation(item.snow);
return item;
});
}
if (res.hourly) {
res.hourly = res.hourly.map(item => {
item.rain = this.getPrecipitation(item.rain);
item.snow = this.getPrecipitation(item.snow);
return item;
});
}
return res;
});
}
// owm puts precip amount on a nested property
getPrecipitation(value) {
return !value
? 0
: (value['1h']
? value['1h']
: 0);
}
}
export default MiniOwm;
//# sourceMappingURL=MiniOwm.js.map
{
"name": "mini-owm",
"version": "1.2.0",
"version": "1.3.0",
"description": "Mini ES wrapper for OpenWeatherMap api",

@@ -5,0 +5,0 @@ "author": "Dean Verleger",

@@ -5,4 +5,10 @@ # mini-owm

mini-owm is simple but versatile. Use it in any of the following ways or mix and match. mini-owm defaults to metric - who uses kelvin?
Configure it via [initialization](#Constructor-parameters), [chainging](#Chaining), [individual calls](#Get-Parameters), or mix and match.
mini-owm also simplifies the Open Weather Api by:
- defaulting to metric - _who uses kelvin?_
- applying the nested `1h` property from `rain` and `snow` directly to those properties - _who starts a json property with a number?_
- defaulting empty` rain` or `snow` to `0` instead of omitting
### Install

@@ -9,0 +15,0 @@

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