@firebase/util 1.6.2-canary.b60cf76e1 → 1.6.2-canary.c187446a2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1031,6 +1031,34 @@ function isObject(thing) {
1031
1031
  return thing !== null && typeof thing === 'object';
1032
1032
  }
1033
1033
 
1034
+ /**
1035
+ * @license
1036
+ * Copyright 2022 Google LLC
1037
+ *
1038
+ * Licensed under the Apache License, Version 2.0 (the "License");
1039
+ * you may not use this file except in compliance with the License.
1040
+ * You may obtain a copy of the License at
1041
+ *
1042
+ * http://www.apache.org/licenses/LICENSE-2.0
1043
+ *
1044
+ * Unless required by applicable law or agreed to in writing, software
1045
+ * distributed under the License is distributed on an "AS IS" BASIS,
1046
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1047
+ * See the License for the specific language governing permissions and
1048
+ * limitations under the License.
1049
+ */
1050
+ /**
1051
+ * Rejects if the given promise doesn't resolve in timeInMS milliseconds.
1052
+ * @internal
1053
+ */
1054
+ function promiseWithTimeout(promise, timeInMS) {
1055
+ if (timeInMS === void 0) { timeInMS = 2000; }
1056
+ var deferredPromise = new Deferred();
1057
+ setTimeout(function () { return deferredPromise.reject('timeout!'); }, timeInMS);
1058
+ promise.then(deferredPromise.resolve, deferredPromise.reject);
1059
+ return deferredPromise.promise;
1060
+ }
1061
+
1034
1062
  /**
1035
1063
  * @license
1036
1064
  * Copyright 2017 Google LLC
@@ -1985,6 +2013,7 @@ exports.issuedAtTime = issuedAtTime;
1985
2013
  exports.jsonEval = jsonEval;
1986
2014
  exports.map = map;
1987
2015
  exports.ordinal = ordinal;
2016
+ exports.promiseWithTimeout = promiseWithTimeout;
1988
2017
  exports.querystring = querystring;
1989
2018
  exports.querystringDecode = querystringDecode;
1990
2019
  exports.safeGet = safeGet;