@firebase/util 1.6.1 → 1.6.2-canary.13550089f

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
@@ -1755,6 +1783,34 @@ var stringLength = function (str) {
1755
1783
  return p;
1756
1784
  };
1757
1785
 
1786
+ /**
1787
+ * @license
1788
+ * Copyright 2022 Google LLC
1789
+ *
1790
+ * Licensed under the Apache License, Version 2.0 (the "License");
1791
+ * you may not use this file except in compliance with the License.
1792
+ * You may obtain a copy of the License at
1793
+ *
1794
+ * http://www.apache.org/licenses/LICENSE-2.0
1795
+ *
1796
+ * Unless required by applicable law or agreed to in writing, software
1797
+ * distributed under the License is distributed on an "AS IS" BASIS,
1798
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1799
+ * See the License for the specific language governing permissions and
1800
+ * limitations under the License.
1801
+ */
1802
+ /**
1803
+ * Copied from https://stackoverflow.com/a/2117523
1804
+ * Generates a new uuid.
1805
+ * @public
1806
+ */
1807
+ var uuidv4 = function () {
1808
+ return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
1809
+ var r = (Math.random() * 16) | 0, v = c === 'x' ? r : (r & 0x3) | 0x8;
1810
+ return v.toString(16);
1811
+ });
1812
+ };
1813
+
1758
1814
  /**
1759
1815
  * @license
1760
1816
  * Copyright 2019 Google LLC
@@ -1957,12 +2013,14 @@ exports.issuedAtTime = issuedAtTime;
1957
2013
  exports.jsonEval = jsonEval;
1958
2014
  exports.map = map;
1959
2015
  exports.ordinal = ordinal;
2016
+ exports.promiseWithTimeout = promiseWithTimeout;
1960
2017
  exports.querystring = querystring;
1961
2018
  exports.querystringDecode = querystringDecode;
1962
2019
  exports.safeGet = safeGet;
1963
2020
  exports.stringLength = stringLength;
1964
2021
  exports.stringToByteArray = stringToByteArray;
1965
2022
  exports.stringify = stringify;
2023
+ exports.uuidv4 = uuidv4;
1966
2024
  exports.validateArgCount = validateArgCount;
1967
2025
  exports.validateCallback = validateCallback;
1968
2026
  exports.validateContextObject = validateContextObject;