google-maps-js-api-loader
Advanced tools
Comparing version
@@ -107,5 +107,9 @@ /// <reference types="google.maps" /> | ||
/** | ||
* @returns error for {@link google.maps} script or `undefined` | ||
*/ | ||
static getError(): Error | undefined; | ||
/** | ||
* @returns error for the provided {@link library} or `undefined` | ||
*/ | ||
static getError(library: GoogleMapsLibrary): google.maps.MapsServerError | google.maps.MapsNetworkError | google.maps.MapsRequestError | undefined; | ||
static getError(library: GoogleMapsLibrary): Error | google.maps.MapsServerError | google.maps.MapsNetworkError | google.maps.MapsRequestError | undefined; | ||
} | ||
@@ -112,0 +116,0 @@ interface GoogleMapsLoader extends Identity<typeof GoogleMapsLoader> { |
@@ -14,2 +14,3 @@ // src/index.ts | ||
let status = 0 /* NONE */; | ||
let error; | ||
const statuses = ["none", "loading", "loaded", "error"]; | ||
@@ -61,3 +62,3 @@ const store = /* @__PURE__ */ new Map(); | ||
GoogleMapsLoader.get = (key) => store.has(key) ? store.get(key)[2] : void 0; | ||
GoogleMapsLoader.getError = (key) => store.has(key) ? store.get(key)[3] : void 0; | ||
GoogleMapsLoader.getError = (key) => key ? store.has(key) ? store.get(key)[3] : void 0 : error; | ||
GoogleMapsLoader.getStatus = (key) => statuses[key ? store.has(key) ? store.get(key)[0] : 0 /* NONE */ : status]; | ||
@@ -83,3 +84,3 @@ GoogleMapsLoader.getCompletion = createCompletionGetter((key) => (store.get(key) || initData(key))[1]); | ||
status = 3 /* ERROR */; | ||
reject(new Error(errorMessage)); | ||
reject(error = new Error(errorMessage)); | ||
} else { | ||
@@ -98,3 +99,3 @@ status = 1 /* LOADING */; | ||
status = 3 /* ERROR */; | ||
reject(new Error("google.maps could not load")); | ||
reject(error = new Error("google.maps could not load")); | ||
}); | ||
@@ -101,0 +102,0 @@ }; |
{ | ||
"name": "google-maps-js-api-loader", | ||
"version": "4.0.1", | ||
"author": "Krombik", | ||
"version": "4.0.2", | ||
"author": "Andrii Dubetskyi", | ||
"description": "A lightweight JavaScript library for loading the Google Maps JavaScript API", | ||
@@ -6,0 +6,0 @@ "keywords": [ |
@@ -155,2 +155,4 @@ # google-maps-js-api-loader | ||
```ts | ||
static getError(): Error | undefined; | ||
static getError( | ||
@@ -171,2 +173,2 @@ library: GoogleMapsLibrary | ||
MIT © [Krombik](https://github.com/Krombik) | ||
MIT © [Andrii Dubetskyi](https://github.com/Krombik) |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
52933
1.83%363
1.68%173
1.17%