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

react-google-geocoding

Package Overview
Dependencies
Maintainers
0
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

react-google-geocoding - npm Package Compare versions

Comparing version 0.2.3 to 0.2.7

2

dist/index.cjs.js

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

"use strict";Object.defineProperty(exports,"__esModule",{value:!0}),require("tslib").__exportStar(require("./use-place-predictions"),exports);
"use strict";Object.defineProperty(exports,"__esModule",{value:!0});var e=require("react");function t(e){return e&&"object"==typeof e&&"default"in e?e:{default:e}}var n,o,i=t(e),r="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function u(e){return e&&e.__esModule&&Object.prototype.hasOwnProperty.call(e,"default")?e.default:e}var f=u(function(){if(o)return n;o=1;var e=/^\s+|\s+$/g,t=/^[-+]0x[0-9a-f]+$/i,i=/^0b[01]+$/i,u=/^0o[0-7]+$/i,f=parseInt,c="object"==typeof r&&r&&r.Object===Object&&r,a="object"==typeof self&&self&&self.Object===Object&&self,s=c||a||Function("return this")(),l=Object.prototype.toString,d=Math.max,p=Math.min,v=function(){return s.Date.now()};function g(e){var t=typeof e;return!!e&&("object"==t||"function"==t)}function y(n){if("number"==typeof n)return n;if(function(e){return"symbol"==typeof e||function(e){return!!e&&"object"==typeof e}(e)&&"[object Symbol]"==l.call(e)}(n))return NaN;if(g(n)){var o="function"==typeof n.valueOf?n.valueOf():n;n=g(o)?o+"":o}if("string"!=typeof n)return 0===n?n:+n;n=n.replace(e,"");var r=i.test(n);return r||u.test(n)?f(n.slice(2),r?2:8):t.test(n)?NaN:+n}return n=function(e,t,n){var o,i,r,u,f,c,a=0,s=!1,l=!1,b=!0;if("function"!=typeof e)throw new TypeError("Expected a function");function m(t){var n=o,r=i;return o=i=void 0,a=t,u=e.apply(r,n)}function w(e){var n=e-c;return void 0===c||n>=t||n<0||l&&e-a>=r}function h(){var e=v();if(w(e))return j(e);f=setTimeout(h,function(e){var n=t-(e-c);return l?p(n,r-(e-a)):n}(e))}function j(e){return f=void 0,b&&o?m(e):(o=i=void 0,u)}function O(){var e=v(),n=w(e);if(o=arguments,i=this,c=e,n){if(void 0===f)return function(e){return a=e,f=setTimeout(h,t),s?m(e):u}(c);if(l)return f=setTimeout(h,t),m(c)}return void 0===f&&(f=setTimeout(h,t)),u}return t=y(t)||0,g(n)&&(s=!!n.leading,r=(l="maxWait"in n)?d(y(n.maxWait)||0,t):r,b="trailing"in n?!!n.trailing:b),O.cancel=function(){void 0!==f&&clearTimeout(f),a=0,o=c=i=f=void 0},O.flush=function(){return void 0===f?u:j(v())},O}}());function c(t,n,o){void 0===n&&(n=500);var i=e.useRef();!function(t){var n=e.useRef(t);n.current=t,e.useEffect((function(){return function(){n.current()}}),[])}((function(){i.current&&i.current.cancel()}));var r=e.useMemo((function(){var e=f(t,n,o),r=function(){for(var t=[],n=0;n<arguments.length;n++)t[n]=arguments[n];return e.apply(void 0,t)};return r.cancel=function(){e.cancel()},r.isPending=function(){return!!i.current},r.flush=function(){return e.flush()},r}),[t,n,o]);return e.useEffect((function(){i.current=f(t,n,o)}),[t,n,o]),r}exports.usePlacePredictions=function(t){var n=t.input,o=t.debounceMs,r=void 0===o?300:o,u=t.sessionToken,f=t.locationBias,a=t.locationRestriction,s=t.language,l=t.types,d=t.componentRestrictions,p=t.offset,v=t.origin,g=t.region,y=t.location,b=t.radius,m=t.bounds,w=i.default.useRef(null),h=i.default.useState([]),j=h[0],O=h[1],T=i.default.useState(!1),R=T[0],S=T[1],x=i.default.useState(null),E=x[0],P=x[1],M=function(t,n,o){var i,r=null!==(i=null==o?void 0:o.equalityFn)&&void 0!==i?i:function(e,t){return e===t},u=t instanceof Function?t():t,f=e.useState(u),a=f[0],s=f[1],l=e.useRef(u),d=c(s,n,o);return r(l.current,u)||(d(u),l.current=u),[a,d]}(n,r)[0];return i.default.useEffect((function(){void 0!==window&&window.google&&(w.current=new window.google.maps.places.AutocompleteService)}),[]),i.default.useEffect((function(){if(n){if(!w.current)throw new Error("Autocomplete Service not initialized");S(!0),w.current.getPlacePredictions({input:M,language:s,locationBias:f,region:g,offset:p,origin:v,locationRestriction:a,sessionToken:u,types:l,componentRestrictions:d,location:y,radius:b,bounds:m},(function(e,t){O(e||[]),P(t),S(!1)}))}}),[M]),{predictions:j,isLoading:R,status:E}};

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

Object.defineProperty(exports,"__esModule",{value:!0}),require("tslib").__exportStar(require("./use-place-predictions"),exports);
import n,{useRef as t,useEffect as e,useMemo as o,useState as i}from"react";var r,u,c="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof window?window:"undefined"!=typeof global?global:"undefined"!=typeof self?self:{};function f(n){return n&&n.__esModule&&Object.prototype.hasOwnProperty.call(n,"default")?n.default:n}var a=f(function(){if(u)return r;u=1;var n=/^\s+|\s+$/g,t=/^[-+]0x[0-9a-f]+$/i,e=/^0b[01]+$/i,o=/^0o[0-7]+$/i,i=parseInt,f="object"==typeof c&&c&&c.Object===Object&&c,a="object"==typeof self&&self&&self.Object===Object&&self,s=f||a||Function("return this")(),l=Object.prototype.toString,d=Math.max,p=Math.min,v=function(){return s.Date.now()};function g(n){var t=typeof n;return!!n&&("object"==t||"function"==t)}function y(r){if("number"==typeof r)return r;if(function(n){return"symbol"==typeof n||function(n){return!!n&&"object"==typeof n}(n)&&"[object Symbol]"==l.call(n)}(r))return NaN;if(g(r)){var u="function"==typeof r.valueOf?r.valueOf():r;r=g(u)?u+"":u}if("string"!=typeof r)return 0===r?r:+r;r=r.replace(n,"");var c=e.test(r);return c||o.test(r)?i(r.slice(2),c?2:8):t.test(r)?NaN:+r}return r=function(n,t,e){var o,i,r,u,c,f,a=0,s=!1,l=!1,b=!0;if("function"!=typeof n)throw new TypeError("Expected a function");function m(t){var e=o,r=i;return o=i=void 0,a=t,u=n.apply(r,e)}function w(n){var e=n-f;return void 0===f||e>=t||e<0||l&&n-a>=r}function h(){var n=v();if(w(n))return j(n);c=setTimeout(h,function(n){var e=t-(n-f);return l?p(e,r-(n-a)):e}(n))}function j(n){return c=void 0,b&&o?m(n):(o=i=void 0,u)}function T(){var n=v(),e=w(n);if(o=arguments,i=this,f=n,e){if(void 0===c)return function(n){return a=n,c=setTimeout(h,t),s?m(n):u}(f);if(l)return c=setTimeout(h,t),m(f)}return void 0===c&&(c=setTimeout(h,t)),u}return t=y(t)||0,g(e)&&(s=!!e.leading,r=(l="maxWait"in e)?d(y(e.maxWait)||0,t):r,b="trailing"in e?!!e.trailing:b),T.cancel=function(){void 0!==c&&clearTimeout(c),a=0,o=f=i=c=void 0},T.flush=function(){return void 0===c?u:j(v())},T}}());function s(n,i,r){void 0===i&&(i=500);var u=t();!function(n){var o=t(n);o.current=n,e((function(){return function(){o.current()}}),[])}((function(){u.current&&u.current.cancel()}));var c=o((function(){var t=a(n,i,r),e=function(){for(var n=[],e=0;e<arguments.length;e++)n[e]=arguments[e];return t.apply(void 0,n)};return e.cancel=function(){t.cancel()},e.isPending=function(){return!!u.current},e.flush=function(){return t.flush()},e}),[n,i,r]);return e((function(){u.current=a(n,i,r)}),[n,i,r]),c}var l=function(e){var o=e.input,r=e.debounceMs,u=void 0===r?300:r,c=e.sessionToken,f=e.locationBias,a=e.locationRestriction,l=e.language,d=e.types,p=e.componentRestrictions,v=e.offset,g=e.origin,y=e.region,b=e.location,m=e.radius,w=e.bounds,h=n.useRef(null),j=n.useState([]),T=j[0],O=j[1],S=n.useState(!1),x=S[0],E=S[1],R=n.useState(null),M=R[0],N=R[1],P=function(n,e,o){var r,u=null!==(r=null==o?void 0:o.equalityFn)&&void 0!==r?r:function(n,t){return n===t},c=n instanceof Function?n():n,f=i(c),a=f[0],l=f[1],d=t(c),p=s(l,e,o);return u(d.current,c)||(p(c),d.current=c),[a,p]}(o,u)[0];return n.useEffect((function(){void 0!==window&&window.google&&(h.current=new window.google.maps.places.AutocompleteService)}),[]),n.useEffect((function(){if(o){if(!h.current)throw new Error("Autocomplete Service not initialized");E(!0),h.current.getPlacePredictions({input:P,language:l,locationBias:f,region:y,offset:v,origin:g,locationRestriction:a,sessionToken:c,types:d,componentRestrictions:p,location:b,radius:m,bounds:w},(function(n,t){O(n||[]),N(t),E(!1)}))}}),[P]),{predictions:T,isLoading:x,status:M}};export{l as usePlacePredictions};
{
"name": "react-google-geocoding",
"version": "0.2.3",
"version": "0.2.7",
"main": "dist/index.cjs.js",

@@ -54,5 +54,4 @@ "module": "dist/index.esm.js",

"dependencies": {
"lodash.debounce": "^4.0.8",
"react-google-hooks": "^0.2.2"
"lodash.debounce": "^4.0.8"
}
}

@@ -71,3 +71,3 @@ # react-google-hooks

Below is a basic implementation example using the `usePlacesAutocomplete` hook:
Below is a basic implementation example using the `usePlacesPredictions` hook:

@@ -74,0 +74,0 @@ ```jsx

@@ -18,4 +18,13 @@ import resolve from "@rollup/plugin-node-resolve";

],
plugins: [resolve(), commonjs(), typescript(), terser()],
plugins: [
resolve(),
commonjs(),
typescript({
jsx: "react",
include: ["**/*.ts", "**/*.tsx"],
}),
terser(),
],
external: ["react", "react-dom"],
};
{
"compilerOptions": {
"target": "ES5", // This ensures compatibility with older JS versions.
"module": "CommonJS", // CommonJS is widely supported in Node.js and bundlers like Webpack.
"declaration": true, // Generates .d.ts files for TypeScript support.
"outDir": "dist", // Output directory for compiled files.
"strict": true, // Enable strict type-checking options.
"jsx": "react", // JSX support for React.
"esModuleInterop": true, // Ensures compatibility with CommonJS and ES modules.
"moduleResolution": "Node", // Use Node.js-style module resolution.
"skipLibCheck": true, // Skips type-checking of declaration files for faster builds.
"forceConsistentCasingInFileNames": true, // Enforces consistent file casing.
"lib": ["ES5", "DOM"], // Target ES5 features and browser DOM APIs.
"allowJs": true, // Allows compilation of JS files.
"resolveJsonModule": true // Allows import of JSON files.
"target": "ES5",
"module": "ESNext",
"declaration": true,
"outDir": "dist",
"strict": true,
"jsx": "react",
"esModuleInterop": true,
"moduleResolution": "Node"
},
"include": ["src"],
"include": ["src/**/*.ts", "src/**/*.tsx"],
"exclude": ["node_modules", "dist"]
}
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