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

h5-utils

Package Overview
Dependencies
Maintainers
2
Versions
53
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

h5-utils - npm Package Compare versions

Comparing version 0.11.5 to 0.11.6

2

h5-utils.js

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

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Utils=t():e.Utils=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var r=n[o]={exports:{},id:o,loaded:!1};return e[o].call(r.exports,r,r.exports,t),r.loaded=!0,r.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(1),i=o(r),u=n(2),a=o(u),c=n(3),d=o(c),s=n(4),l=o(s),f=n(5),p=o(f),g=n(6),m=o(g),v=n(7),y=o(v),h=n(8),w=o(h);t.default={getLocation:a.default,getGeohash:i.default,compareVersion:d.default,paramToString:l.default,resolveFetch:p.default,checkoutByApp:m.default,getUrl:y.default,expiredLocalStorage:w.default}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),o=function(){var e=window.UParams?window.UParams().geohash||"":"";if(e)try{window.Geohash.decode(e)}catch(t){e=""}return e},r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=null,o=function(){clearInterval(n)};return new Promise(function(r,i){if(!window.hybridAPI)return i();var u=function(){window.hybridAPI.getGlobalGeohash().then(function(e){e&&(o(),r(e))})};n=setInterval(u,t),u(),setTimeout(function(){o(),i()},e)})},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(window.Geohash.encode(e.coords.latitude,e.coords.longitude))},n,{timeout:e,maximumAge:6e5})}):Promise.reject()},u=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,o=1800,r=e?ap.getLocation({timeout:t,cacheTimeout:o}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:o,requestType:0,bizType:n?"iOS-ele-position":"Android-ele-position"});return r.then(function(e){return window.Geohash.encode(e.latitude,e.longitude)})},a=function(){return window.wk?new Promise(function(e,t){wk.ready(function(){wk.getLocation({type:"wgs84",success:function(t){e(window.Geohash.encode(t.latitude,t.longitude))},fail:t})}),wk.error(t)}):Promise.reject()},c=function(){return window.dd?new Promise(function(e,t){dd.ready(function(){dd.device.geolocation.get({targetAccuracy:200,coordinate:0,withReGeocode:!1,useCache:!0,onSuccess:function(t){e(window.Geohash.encode(t.latitude,t.longitude))},onFail:t})}),dd.error(t)}):Promise.reject()},d=function(e,t){return r(2*e/3).catch(function(){return t?Promise.reject():i(1*e/3)})},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=o();if(n)return Promise.resolve(n);var r=void 0;return r=/Eleme/i.test(navigator.userAgent)?d(e,t):/AlipayClient/.test(navigator.userAgent)?u():/wkbrowser|WiFiKey|ZeusPro/i.test(navigator.userAgent)?a():/AliApp\(DingTalk/.test(navigator.userAgent)?c():i(e)};s.getParamHash=o,s.useApp=r,s.useGeoAPI=i,s.useAlipay=u,s.useWifikey=a,s.useDingding=c,t.default=s},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=function(){function e(e,t){var n=[],o=!0,r=!1,i=void 0;try{for(var u,a=e[Symbol.iterator]();!(o=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){r=!0,i=e}finally{try{!o&&a.return&&a.return()}finally{if(r)throw i}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),i=n(3),u=o(i),a=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return window.hybridAPI?new Promise(function(t,n){(0,u.default)("7.26")?hybridAPI.getGlobalGeohash().then(function(e){var n=Geohash.decode(e),o=r(n,2),i=o[0],u=o[1];t({latitude:i,longitude:u})}):hybridAPI.getSyncLocation().then(function(e){t({latitude:e.lat,longitude:e.lng})}),setTimeout(function(){n({name:"`getSyncLocation` method timeout"})},e)}):Promise.reject({name:"HYBRIDAPI_NOT_DEFINED"})},d=function(e){return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(e.coords)},n,{timeout:e,maximumAge:6e5}),setTimeout(n,e)}):Promise.reject()},s=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,n=1800,o=e?ap.getLocation({timeout:t,cacheTimeout:n}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:n,requestType:0,bizType:a?"iOS-ele-position":"Android-ele-position"});return o},l=function(){return window.wk?new Promise(function(e,t){wk.ready(function(){wk.getLocation({type:"wgs84",success:e,fail:t})}),wk.error(t)}):Promise.reject()},f=function(e,t){return c(2*e/3).catch(function(n){t?Promise.reject(n):getNavigatorHash(1*e/3)})},p=function(){return window.dd?new Promise(function(e,t){dd.ready(function(){dd.device.geolocation.get({targetAccuracy:200,coordinate:0,withReGeocode:!1,useCache:!0,onSuccess:e,onFail:t})}),dd.error(t)}):Promise.reject()},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=void 0;return n=/Eleme/i.test(navigator.userAgent)?f(e,t):/AlipayClient/.test(navigator.userAgent)?s():/wkbrowser|WiFiKey|ZeusPro/i.test(navigator.userAgent)?l():/AliApp\(DingTalk/.test(navigator.userAgent)?p():d(e)};t.default=g},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){if(!t&&(t=(window.navigator.userAgent.match(/Eleme\/([\d|\.]+)/i)||[])[1],!t))return!1;e=e.split("."),t=t.split(".");var n=void 0;return e.forEach(function(e,o){var r=t[o];if("undefined"==typeof r&&(r=0),"undefined"==typeof n){var i=Number(e)-Number(r);0!==i&&(n=i>0)}}),!!n};t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return Object.prototype.toString.call(e).slice(8,-1)},o=function(e){if("Object"!==n(e))throw"param 必须是一个 object";var t=[];return Object.keys(e).forEach(function(o){var r=e[o];Array.isArray(r)?t=t.concat(r.map(function(e){return encodeURIComponent(o)+"[]="+encodeURIComponent(e)})):"Object"===n(r)?(r=JSON.stringify(r),t.push(encodeURIComponent(o)+"="+encodeURIComponent(r))):"Undefined"!==n(r)&&"Null"!==n(r)&&t.push(encodeURIComponent(o)+"="+encodeURIComponent(r))}),t.join("&")};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){if(204===e.status)return Promise.resolve.bind(Promise);var t=e.json();return e.status>=200&&e.status<300?t:t.then(Promise.reject.bind(Promise))};t.default=n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var r=n(3),i=o(r);t.default=function(e){var t=e.id,n=e.entities,o=(e.callback,{clear_cart:!0});(0,i.default)("7.2")?o.add_foods=n.map(function(e){var t=e.id,n=e.quantity,o=e.specs;return{id:t,quantity:n,specs:o.map(function(e){return e.value})}}):o.add_foods=n.map(function(e){var t=e.id,n=e.sku_id,o=e.quantity,r=e.specs,i=e.attrs;return{id:t,sku_id:n||"",quantity:o,specs:r,attrs:i}}),location.href="eleme://checkout?restaurant_id="+t+"&cart_operations="+JSON.stringify(o)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hash",r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,i="";if("{}"!==JSON.stringify(t)){i="hash"===o?"#":"?";for(var u in t){var a=t[u];i+="object"===("undefined"==typeof a?"undefined":n(a))&&a?encodeURIComponent(u)+"="+encodeURIComponent(JSON.stringify(a))+"&":encodeURIComponent(u)+"="+encodeURIComponent(a)+"&"}}return i=""+e+i.replace(/&$/,""),/Eleme/.test(navigator.userAgent)&&(i="eleme://web?url="+encodeURIComponent(i)+"&animation_type="+r),i};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={set:function(e){var t=e.key,n=e.value,o=e.expiredDate,r=e.expiredDay,i={value:n,expired:""};return o&&(i.expired=o),r&&(i.expired=Date.now()+60*r*60*1e3),localStorage.setItem(t,JSON.stringify(i)),{key:t,value:JSON.stringify(i)}},get:function(e){var t=void 0;try{t=JSON.parse(localStorage.getItem(e))}catch(e){throw e}if(!t)throw"The key: "+e+" you want are not found in localStorage";var n=Date.now()>new Date(t.expired).getTime();return{value:t.value,expired:n}}}}])});
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.Utils=t():e.Utils=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(1),r=o(i),u=n(2),a=o(u),c=n(3),d=o(c),s=n(4),l=o(s),f=n(5),p=o(f),g=n(6),m=o(g),v=n(7),y=o(v),h=n(8),w=o(h);t.default={getLocation:a.default,getGeohash:r.default,compareVersion:d.default,paramToString:l.default,resolveFetch:p.default,checkoutByApp:m.default,getUrl:y.default,expiredLocalStorage:w.default}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),o=function(){var e=window.UParams?window.UParams():{},t=e.geohash,n=void 0===t?"":t,o=e.latitude,i=void 0===o?"":o,r=e.longitude,u=void 0===r?"":r;if(n)try{window.Geohash.decode(n)}catch(e){n=""}if(!n&&i&&u)try{n=window.Geohash.encode(i,u)}catch(e){n=""}return n},i=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100,n=null,o=function(){clearInterval(n)};return new Promise(function(i,r){if(!window.hybridAPI)return r();var u=function(){window.hybridAPI.getGlobalGeohash().then(function(e){e&&(o(),i(e))})};n=setInterval(u,t),u(),setTimeout(function(){o(),r()},e)})},r=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(window.Geohash.encode(e.coords.latitude,e.coords.longitude))},n,{timeout:e,maximumAge:6e5})}):Promise.reject()},u=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,o=1800,i=e?ap.getLocation({timeout:t,cacheTimeout:o}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:o,requestType:0,bizType:n?"iOS-ele-position":"Android-ele-position"});return i.then(function(e){return window.Geohash.encode(e.latitude,e.longitude)})},a=function(){return window.wk?new Promise(function(e,t){wk.ready(function(){wk.getLocation({type:"wgs84",success:function(t){e(window.Geohash.encode(t.latitude,t.longitude))},fail:t})}),wk.error(t)}):Promise.reject()},c=function(){return window.dd?new Promise(function(e,t){dd.ready(function(){dd.device.geolocation.get({targetAccuracy:200,coordinate:0,withReGeocode:!1,useCache:!0,onSuccess:function(t){e(window.Geohash.encode(t.latitude,t.longitude))},onFail:t})}),dd.error(t)}):Promise.reject()},d=function(e,t){return i(2*e/3).catch(function(){return t?Promise.reject():r(1*e/3)})},s=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=o();if(n)return Promise.resolve(n);var i=void 0;return i=/Eleme/i.test(navigator.userAgent)?d(e,t):/AlipayClient/.test(navigator.userAgent)?u():/wkbrowser|WiFiKey|ZeusPro/i.test(navigator.userAgent)?a():/AliApp\(DingTalk/.test(navigator.userAgent)?c():r(e)};s.getParamHash=o,s.useApp=i,s.useGeoAPI=r,s.useAlipay=u,s.useWifikey=a,s.useDingding=c,t.default=s},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=function(){function e(e,t){var n=[],o=!0,i=!1,r=void 0;try{for(var u,a=e[Symbol.iterator]();!(o=(u=a.next()).done)&&(n.push(u.value),!t||n.length!==t);o=!0);}catch(e){i=!0,r=e}finally{try{!o&&a.return&&a.return()}finally{if(i)throw r}}return n}return function(t,n){if(Array.isArray(t))return t;if(Symbol.iterator in Object(t))return e(t,n);throw new TypeError("Invalid attempt to destructure non-iterable instance")}}(),r=n(3),u=o(r),a=/iPhone|iPad|iPod|iOS/i.test(navigator.userAgent),c=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:5e3;return window.hybridAPI?new Promise(function(t,n){(0,u.default)("7.26")?hybridAPI.getGlobalGeohash().then(function(e){var n=Geohash.decode(e),o=i(n,2),r=o[0],u=o[1];t({latitude:r,longitude:u})}):hybridAPI.getSyncLocation().then(function(e){t({latitude:e.lat,longitude:e.lng})}),setTimeout(function(){n({name:"`getSyncLocation` method timeout"})},e)}):Promise.reject({name:"HYBRIDAPI_NOT_DEFINED"})},d=function(e){return navigator.geolocation?new Promise(function(t,n){navigator.geolocation.getCurrentPosition(function(e){e.coords.latitude||n({name:"BROWSER_MODE_PERMISSON_FAILED"}),t(e.coords)},n,{timeout:e,maximumAge:6e5}),setTimeout(n,e)}):Promise.reject()},s=function(){if(!window.ap)return Promise.reject();var e=ap.compareVersion("10.0.18")<0,t=10,n=1800,o=e?ap.getLocation({timeout:t,cacheTimeout:n}):ap.call("getCurrentLocation",{timeout:t,cacheTimeout:n,requestType:0,bizType:a?"iOS-ele-position":"Android-ele-position"});return o},l=function(){return window.wk?new Promise(function(e,t){wk.ready(function(){wk.getLocation({type:"wgs84",success:e,fail:t})}),wk.error(t)}):Promise.reject()},f=function(e,t){return c(2*e/3).catch(function(n){t?Promise.reject(n):getNavigatorHash(1*e/3)})},p=function(){return window.dd?new Promise(function(e,t){dd.ready(function(){dd.device.geolocation.get({targetAccuracy:200,coordinate:0,withReGeocode:!1,useCache:!0,onSuccess:e,onFail:t})}),dd.error(t)}):Promise.reject()},g=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:9e3,t=!(arguments.length>1&&void 0!==arguments[1])||arguments[1],n=void 0;return n=/Eleme/i.test(navigator.userAgent)?f(e,t):/AlipayClient/.test(navigator.userAgent)?s():/wkbrowser|WiFiKey|ZeusPro/i.test(navigator.userAgent)?l():/AliApp\(DingTalk/.test(navigator.userAgent)?p():d(e)};t.default=g},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e,t){if(!t&&(t=(window.navigator.userAgent.match(/Eleme\/([\d|\.]+)/i)||[])[1],!t))return!1;e=e.split("."),t=t.split(".");var n=void 0;return e.forEach(function(e,o){var i=t[o];if("undefined"==typeof i&&(i=0),"undefined"==typeof n){var r=Number(e)-Number(i);0!==r&&(n=r>0)}}),!!n};t.default=n},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){return Object.prototype.toString.call(e).slice(8,-1)},o=function(e){if("Object"!==n(e))throw"param 必须是一个 object";var t=[];return Object.keys(e).forEach(function(o){var i=e[o];Array.isArray(i)?t=t.concat(i.map(function(e){return encodeURIComponent(o)+"[]="+encodeURIComponent(e)})):"Object"===n(i)?(i=JSON.stringify(i),t.push(encodeURIComponent(o)+"="+encodeURIComponent(i))):"Undefined"!==n(i)&&"Null"!==n(i)&&t.push(encodeURIComponent(o)+"="+encodeURIComponent(i))}),t.join("&")};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n=function(e){if(204===e.status)return Promise.resolve.bind(Promise);var t=e.json();return e.status>=200&&e.status<300?t:t.then(Promise.reject.bind(Promise))};t.default=n},function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}Object.defineProperty(t,"__esModule",{value:!0});var i=n(3),r=o(i);t.default=function(e){var t=e.id,n=e.entities,o=(e.callback,{clear_cart:!0});(0,r.default)("7.2")?o.add_foods=n.map(function(e){var t=e.id,n=e.quantity,o=e.specs;return{id:t,quantity:n,specs:o.map(function(e){return e.value})}}):o.add_foods=n.map(function(e){var t=e.id,n=e.sku_id,o=e.quantity,i=e.specs,r=e.attrs;return{id:t,sku_id:n||"",quantity:o,specs:i,attrs:r}}),location.href="eleme://checkout?restaurant_id="+t+"&cart_operations="+JSON.stringify(o)}},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0});var n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},o=function(e){var t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:{},o=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"hash",i=arguments.length>3&&void 0!==arguments[3]?arguments[3]:1,r="";if("{}"!==JSON.stringify(t)){r="hash"===o?"#":"?";for(var u in t){var a=t[u];r+="object"===("undefined"==typeof a?"undefined":n(a))&&a?encodeURIComponent(u)+"="+encodeURIComponent(JSON.stringify(a))+"&":encodeURIComponent(u)+"="+encodeURIComponent(a)+"&"}}return r=""+e+r.replace(/&$/,""),/Eleme/.test(navigator.userAgent)&&(r="eleme://web?url="+encodeURIComponent(r)+"&animation_type="+i),r};t.default=o},function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.default={set:function(e){var t=e.key,n=e.value,o=e.expiredDate,i=e.expiredDay,r={value:n,expired:""};return o&&(r.expired=o),i&&(r.expired=Date.now()+60*i*60*1e3),localStorage.setItem(t,JSON.stringify(r)),{key:t,value:JSON.stringify(r)}},get:function(e){var t=void 0;try{t=JSON.parse(localStorage.getItem(e))}catch(e){throw e}if(!t)throw"The key: "+e+" you want are not found in localStorage";var n=Date.now()>new Date(t.expired).getTime();return{value:t.value,expired:n}}}}])});
{
"name": "h5-utils",
"version": "0.11.5",
"version": "0.11.6",
"description": "common methods for eleme h5 project.",

@@ -5,0 +5,0 @@ "main": "h5-utils.js",

@@ -9,11 +9,18 @@ /*

const getParamHash = () => {
let hash = window.UParams ? (window.UParams().geohash || '') : ''
if (hash) {
let { geohash = '', latitude = '', longitude = '' } = window.UParams ? window.UParams() : {}
if (geohash) {
try {
window.Geohash.decode(hash)
window.Geohash.decode(geohash)
} catch (err) {
hash = ''
geohash = ''
}
}
return hash
if (!geohash && latitude && longitude) {
try {
geohash = window.Geohash.encode(latitude, longitude)
} catch (err) {
geohash = ''
}
}
return geohash
}

@@ -20,0 +27,0 @@

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