@esri/solution-common 3.0.0 → 3.1.0

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.
Files changed (261) hide show
  1. package/dist/esm/featureServiceHelpers.js +20 -2
  2. package/dist/esm/featureServiceHelpers.js.map +1 -1
  3. package/dist/esm/resourceHelpers.d.ts +3 -2
  4. package/dist/esm/resourceHelpers.js +4 -3
  5. package/dist/esm/resourceHelpers.js.map +1 -1
  6. package/dist/esm/resources/copyAssociatedFiles.d.ts +17 -2
  7. package/dist/esm/resources/copyAssociatedFiles.js +106 -42
  8. package/dist/esm/resources/copyAssociatedFiles.js.map +1 -1
  9. package/dist/esm/resources/copyResourceIntoZip.js +8 -1
  10. package/dist/esm/resources/copyResourceIntoZip.js.map +1 -1
  11. package/dist/esm/resources/getItemResourcesPaths.js +9 -2
  12. package/dist/esm/resources/getItemResourcesPaths.js.map +1 -1
  13. package/package.json +3 -3
  14. package/dist/node/completeItem.d.ts +0 -29
  15. package/dist/node/completeItem.js +0 -82
  16. package/dist/node/completeItem.js.map +0 -1
  17. package/dist/node/create-hub-request-options.d.ts +0 -29
  18. package/dist/node/create-hub-request-options.js +0 -64
  19. package/dist/node/create-hub-request-options.js.map +0 -1
  20. package/dist/node/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  21. package/dist/node/deleteHelpers/deleteEmptyGroups.js +0 -42
  22. package/dist/node/deleteHelpers/deleteEmptyGroups.js.map +0 -1
  23. package/dist/node/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  24. package/dist/node/deleteHelpers/deleteGroupIfEmpty.js +0 -97
  25. package/dist/node/deleteHelpers/deleteGroupIfEmpty.js.map +0 -1
  26. package/dist/node/deleteHelpers/deleteSolutionContents.d.ts +0 -38
  27. package/dist/node/deleteHelpers/deleteSolutionContents.js +0 -130
  28. package/dist/node/deleteHelpers/deleteSolutionContents.js.map +0 -1
  29. package/dist/node/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  30. package/dist/node/deleteHelpers/deleteSolutionFolder.js +0 -79
  31. package/dist/node/deleteHelpers/deleteSolutionFolder.js.map +0 -1
  32. package/dist/node/deleteHelpers/deleteSolutionItem.d.ts +0 -30
  33. package/dist/node/deleteHelpers/deleteSolutionItem.js +0 -54
  34. package/dist/node/deleteHelpers/deleteSolutionItem.js.map +0 -1
  35. package/dist/node/deleteHelpers/index.d.ts +0 -22
  36. package/dist/node/deleteHelpers/index.js +0 -26
  37. package/dist/node/deleteHelpers/index.js.map +0 -1
  38. package/dist/node/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  39. package/dist/node/deleteHelpers/reconstructBuildOrderIds.js +0 -34
  40. package/dist/node/deleteHelpers/reconstructBuildOrderIds.js.map +0 -1
  41. package/dist/node/deleteHelpers/removeItems.d.ts +0 -34
  42. package/dist/node/deleteHelpers/removeItems.js +0 -112
  43. package/dist/node/deleteHelpers/removeItems.js.map +0 -1
  44. package/dist/node/deleteHelpers/reportProgress.d.ts +0 -27
  45. package/dist/node/deleteHelpers/reportProgress.js +0 -46
  46. package/dist/node/deleteHelpers/reportProgress.js.map +0 -1
  47. package/dist/node/deleteSolution.d.ts +0 -55
  48. package/dist/node/deleteSolution.js +0 -107
  49. package/dist/node/deleteSolution.js.map +0 -1
  50. package/dist/node/dependencies.d.ts +0 -26
  51. package/dist/node/dependencies.js +0 -171
  52. package/dist/node/dependencies.js.map +0 -1
  53. package/dist/node/featureServiceHelpers.d.ts +0 -791
  54. package/dist/node/featureServiceHelpers.js +0 -2403
  55. package/dist/node/featureServiceHelpers.js.map +0 -1
  56. package/dist/node/generalHelpers.d.ts +0 -372
  57. package/dist/node/generalHelpers.js +0 -842
  58. package/dist/node/generalHelpers.js.map +0 -1
  59. package/dist/node/get-subscription-info.d.ts +0 -27
  60. package/dist/node/get-subscription-info.js +0 -39
  61. package/dist/node/get-subscription-info.js.map +0 -1
  62. package/dist/node/getDeletableSolutionInfo.d.ts +0 -29
  63. package/dist/node/getDeletableSolutionInfo.js +0 -53
  64. package/dist/node/getDeletableSolutionInfo.js.map +0 -1
  65. package/dist/node/getItemTypeAbbrev.d.ts +0 -19
  66. package/dist/node/getItemTypeAbbrev.js +0 -184
  67. package/dist/node/getItemTypeAbbrev.js.map +0 -1
  68. package/dist/node/getSolutionSummary.d.ts +0 -27
  69. package/dist/node/getSolutionSummary.js +0 -101
  70. package/dist/node/getSolutionSummary.js.map +0 -1
  71. package/dist/node/index.d.ts +0 -44
  72. package/dist/node/index.js +0 -48
  73. package/dist/node/index.js.map +0 -1
  74. package/dist/node/interfaces.d.ts +0 -1321
  75. package/dist/node/interfaces.js +0 -75
  76. package/dist/node/interfaces.js.map +0 -1
  77. package/dist/node/libConnectors.d.ts +0 -73
  78. package/dist/node/libConnectors.js +0 -115
  79. package/dist/node/libConnectors.js.map +0 -1
  80. package/dist/node/migrations/apply-schema.d.ts +0 -24
  81. package/dist/node/migrations/apply-schema.js +0 -36
  82. package/dist/node/migrations/apply-schema.js.map +0 -1
  83. package/dist/node/migrations/is-legacy-solution.d.ts +0 -24
  84. package/dist/node/migrations/is-legacy-solution.js +0 -40
  85. package/dist/node/migrations/is-legacy-solution.js.map +0 -1
  86. package/dist/node/migrations/upgrade-three-dot-one.d.ts +0 -27
  87. package/dist/node/migrations/upgrade-three-dot-one.js +0 -49
  88. package/dist/node/migrations/upgrade-three-dot-one.js.map +0 -1
  89. package/dist/node/migrations/upgrade-three-dot-zero.d.ts +0 -27
  90. package/dist/node/migrations/upgrade-three-dot-zero.js +0 -43
  91. package/dist/node/migrations/upgrade-three-dot-zero.js.map +0 -1
  92. package/dist/node/migrations/upgrade-two-dot-five.d.ts +0 -24
  93. package/dist/node/migrations/upgrade-two-dot-five.js +0 -73
  94. package/dist/node/migrations/upgrade-two-dot-five.js.map +0 -1
  95. package/dist/node/migrations/upgrade-two-dot-four.d.ts +0 -24
  96. package/dist/node/migrations/upgrade-two-dot-four.js +0 -72
  97. package/dist/node/migrations/upgrade-two-dot-four.js.map +0 -1
  98. package/dist/node/migrations/upgrade-two-dot-one.d.ts +0 -7
  99. package/dist/node/migrations/upgrade-two-dot-one.js +0 -39
  100. package/dist/node/migrations/upgrade-two-dot-one.js.map +0 -1
  101. package/dist/node/migrations/upgrade-two-dot-seven.d.ts +0 -23
  102. package/dist/node/migrations/upgrade-two-dot-seven.js +0 -58
  103. package/dist/node/migrations/upgrade-two-dot-seven.js.map +0 -1
  104. package/dist/node/migrations/upgrade-two-dot-six.d.ts +0 -27
  105. package/dist/node/migrations/upgrade-two-dot-six.js +0 -61
  106. package/dist/node/migrations/upgrade-two-dot-six.js.map +0 -1
  107. package/dist/node/migrations/upgrade-two-dot-three.d.ts +0 -23
  108. package/dist/node/migrations/upgrade-two-dot-three.js +0 -55
  109. package/dist/node/migrations/upgrade-two-dot-three.js.map +0 -1
  110. package/dist/node/migrations/upgrade-two-dot-two.d.ts +0 -23
  111. package/dist/node/migrations/upgrade-two-dot-two.js +0 -58
  112. package/dist/node/migrations/upgrade-two-dot-two.js.map +0 -1
  113. package/dist/node/migrations/upgrade-two-dot-zero.d.ts +0 -44
  114. package/dist/node/migrations/upgrade-two-dot-zero.js +0 -95
  115. package/dist/node/migrations/upgrade-two-dot-zero.js.map +0 -1
  116. package/dist/node/migrator.d.ts +0 -25
  117. package/dist/node/migrator.js +0 -77
  118. package/dist/node/migrator.js.map +0 -1
  119. package/dist/node/polyfills.d.ts +0 -40
  120. package/dist/node/polyfills.js +0 -98
  121. package/dist/node/polyfills.js.map +0 -1
  122. package/dist/node/resourceHelpers.d.ts +0 -190
  123. package/dist/node/resourceHelpers.js +0 -390
  124. package/dist/node/resourceHelpers.js.map +0 -1
  125. package/dist/node/resources/add-resource-from-blob.d.ts +0 -26
  126. package/dist/node/resources/add-resource-from-blob.js +0 -52
  127. package/dist/node/resources/add-resource-from-blob.js.map +0 -1
  128. package/dist/node/resources/addMetadataFromBlob.d.ts +0 -25
  129. package/dist/node/resources/addMetadataFromBlob.js +0 -43
  130. package/dist/node/resources/addMetadataFromBlob.js.map +0 -1
  131. package/dist/node/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  132. package/dist/node/resources/convert-item-resource-to-storage-resource.js +0 -70
  133. package/dist/node/resources/convert-item-resource-to-storage-resource.js.map +0 -1
  134. package/dist/node/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  135. package/dist/node/resources/convert-storage-resource-to-item-resource.js +0 -70
  136. package/dist/node/resources/convert-storage-resource-to-item-resource.js.map +0 -1
  137. package/dist/node/resources/copyAssociatedFiles.d.ts +0 -52
  138. package/dist/node/resources/copyAssociatedFiles.js +0 -237
  139. package/dist/node/resources/copyAssociatedFiles.js.map +0 -1
  140. package/dist/node/resources/copyDataIntoItem.d.ts +0 -33
  141. package/dist/node/resources/copyDataIntoItem.js +0 -63
  142. package/dist/node/resources/copyDataIntoItem.js.map +0 -1
  143. package/dist/node/resources/copyMetadataIntoItem.d.ts +0 -26
  144. package/dist/node/resources/copyMetadataIntoItem.js +0 -46
  145. package/dist/node/resources/copyMetadataIntoItem.js.map +0 -1
  146. package/dist/node/resources/copyResourceIntoZip.d.ts +0 -33
  147. package/dist/node/resources/copyResourceIntoZip.js +0 -71
  148. package/dist/node/resources/copyResourceIntoZip.js.map +0 -1
  149. package/dist/node/resources/copyZipIntoItem.d.ts +0 -25
  150. package/dist/node/resources/copyZipIntoItem.js +0 -54
  151. package/dist/node/resources/copyZipIntoItem.js.map +0 -1
  152. package/dist/node/resources/createCopyResults.d.ts +0 -25
  153. package/dist/node/resources/createCopyResults.js +0 -36
  154. package/dist/node/resources/createCopyResults.js.map +0 -1
  155. package/dist/node/resources/get-blob.d.ts +0 -26
  156. package/dist/node/resources/get-blob.js +0 -27
  157. package/dist/node/resources/get-blob.js.map +0 -1
  158. package/dist/node/resources/getItemResourcesFilesFromPaths.d.ts +0 -24
  159. package/dist/node/resources/getItemResourcesFilesFromPaths.js +0 -49
  160. package/dist/node/resources/getItemResourcesFilesFromPaths.js.map +0 -1
  161. package/dist/node/resources/getItemResourcesPaths.d.ts +0 -26
  162. package/dist/node/resources/getItemResourcesPaths.js +0 -66
  163. package/dist/node/resources/getItemResourcesPaths.js.map +0 -1
  164. package/dist/node/resources/index.d.ts +0 -29
  165. package/dist/node/resources/index.js +0 -33
  166. package/dist/node/resources/index.js.map +0 -1
  167. package/dist/node/resources/solution-resource.d.ts +0 -35
  168. package/dist/node/resources/solution-resource.js +0 -31
  169. package/dist/node/resources/solution-resource.js.map +0 -1
  170. package/dist/node/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  171. package/dist/node/resources/transform-resource-paths-to-solution-resources.js +0 -146
  172. package/dist/node/resources/transform-resource-paths-to-solution-resources.js.map +0 -1
  173. package/dist/node/restHelpers.d.ts +0 -585
  174. package/dist/node/restHelpers.js +0 -1887
  175. package/dist/node/restHelpers.js.map +0 -1
  176. package/dist/node/restHelpersGet.d.ts +0 -288
  177. package/dist/node/restHelpersGet.js +0 -804
  178. package/dist/node/restHelpersGet.js.map +0 -1
  179. package/dist/node/sharing/index.d.ts +0 -16
  180. package/dist/node/sharing/index.js +0 -20
  181. package/dist/node/sharing/index.js.map +0 -1
  182. package/dist/node/sharing/share-item-to-groups.d.ts +0 -26
  183. package/dist/node/sharing/share-item-to-groups.js +0 -44
  184. package/dist/node/sharing/share-item-to-groups.js.map +0 -1
  185. package/dist/node/templatization.d.ts +0 -139
  186. package/dist/node/templatization.js +0 -314
  187. package/dist/node/templatization.js.map +0 -1
  188. package/dist/node/trackingHelpers.d.ts +0 -116
  189. package/dist/node/trackingHelpers.js +0 -217
  190. package/dist/node/trackingHelpers.js.map +0 -1
  191. package/dist/node/velocityHelpers.d.ts +0 -57
  192. package/dist/node/velocityHelpers.js +0 -135
  193. package/dist/node/velocityHelpers.js.map +0 -1
  194. package/dist/node/workforceHelpers.d.ts +0 -115
  195. package/dist/node/workforceHelpers.js +0 -747
  196. package/dist/node/workforceHelpers.js.map +0 -1
  197. package/dist/umd/common.umd.js +0 -15471
  198. package/dist/umd/common.umd.js.map +0 -1
  199. package/dist/umd/common.umd.min.js +0 -19
  200. package/dist/umd/common.umd.min.js.map +0 -1
  201. package/dist/umd/src/completeItem.d.ts +0 -29
  202. package/dist/umd/src/create-hub-request-options.d.ts +0 -29
  203. package/dist/umd/src/deleteHelpers/deleteEmptyGroups.d.ts +0 -24
  204. package/dist/umd/src/deleteHelpers/deleteGroupIfEmpty.d.ts +0 -27
  205. package/dist/umd/src/deleteHelpers/deleteSolutionContents.d.ts +0 -38
  206. package/dist/umd/src/deleteHelpers/deleteSolutionFolder.d.ts +0 -29
  207. package/dist/umd/src/deleteHelpers/deleteSolutionItem.d.ts +0 -30
  208. package/dist/umd/src/deleteHelpers/index.d.ts +0 -22
  209. package/dist/umd/src/deleteHelpers/reconstructBuildOrderIds.d.ts +0 -27
  210. package/dist/umd/src/deleteHelpers/removeItems.d.ts +0 -34
  211. package/dist/umd/src/deleteHelpers/reportProgress.d.ts +0 -27
  212. package/dist/umd/src/deleteSolution.d.ts +0 -55
  213. package/dist/umd/src/dependencies.d.ts +0 -26
  214. package/dist/umd/src/featureServiceHelpers.d.ts +0 -791
  215. package/dist/umd/src/generalHelpers.d.ts +0 -372
  216. package/dist/umd/src/get-subscription-info.d.ts +0 -27
  217. package/dist/umd/src/getDeletableSolutionInfo.d.ts +0 -29
  218. package/dist/umd/src/getItemTypeAbbrev.d.ts +0 -19
  219. package/dist/umd/src/getSolutionSummary.d.ts +0 -27
  220. package/dist/umd/src/index.d.ts +0 -44
  221. package/dist/umd/src/interfaces.d.ts +0 -1321
  222. package/dist/umd/src/libConnectors.d.ts +0 -73
  223. package/dist/umd/src/migrations/apply-schema.d.ts +0 -24
  224. package/dist/umd/src/migrations/is-legacy-solution.d.ts +0 -24
  225. package/dist/umd/src/migrations/upgrade-three-dot-one.d.ts +0 -27
  226. package/dist/umd/src/migrations/upgrade-three-dot-zero.d.ts +0 -27
  227. package/dist/umd/src/migrations/upgrade-two-dot-five.d.ts +0 -24
  228. package/dist/umd/src/migrations/upgrade-two-dot-four.d.ts +0 -24
  229. package/dist/umd/src/migrations/upgrade-two-dot-one.d.ts +0 -7
  230. package/dist/umd/src/migrations/upgrade-two-dot-seven.d.ts +0 -23
  231. package/dist/umd/src/migrations/upgrade-two-dot-six.d.ts +0 -27
  232. package/dist/umd/src/migrations/upgrade-two-dot-three.d.ts +0 -23
  233. package/dist/umd/src/migrations/upgrade-two-dot-two.d.ts +0 -23
  234. package/dist/umd/src/migrations/upgrade-two-dot-zero.d.ts +0 -44
  235. package/dist/umd/src/migrator.d.ts +0 -25
  236. package/dist/umd/src/polyfills.d.ts +0 -40
  237. package/dist/umd/src/resourceHelpers.d.ts +0 -190
  238. package/dist/umd/src/resources/add-resource-from-blob.d.ts +0 -26
  239. package/dist/umd/src/resources/addMetadataFromBlob.d.ts +0 -25
  240. package/dist/umd/src/resources/convert-item-resource-to-storage-resource.d.ts +0 -32
  241. package/dist/umd/src/resources/convert-storage-resource-to-item-resource.d.ts +0 -29
  242. package/dist/umd/src/resources/copyAssociatedFiles.d.ts +0 -52
  243. package/dist/umd/src/resources/copyDataIntoItem.d.ts +0 -33
  244. package/dist/umd/src/resources/copyMetadataIntoItem.d.ts +0 -26
  245. package/dist/umd/src/resources/copyResourceIntoZip.d.ts +0 -33
  246. package/dist/umd/src/resources/copyZipIntoItem.d.ts +0 -25
  247. package/dist/umd/src/resources/createCopyResults.d.ts +0 -25
  248. package/dist/umd/src/resources/get-blob.d.ts +0 -26
  249. package/dist/umd/src/resources/getItemResourcesFilesFromPaths.d.ts +0 -24
  250. package/dist/umd/src/resources/getItemResourcesPaths.d.ts +0 -26
  251. package/dist/umd/src/resources/index.d.ts +0 -29
  252. package/dist/umd/src/resources/solution-resource.d.ts +0 -35
  253. package/dist/umd/src/resources/transform-resource-paths-to-solution-resources.d.ts +0 -56
  254. package/dist/umd/src/restHelpers.d.ts +0 -585
  255. package/dist/umd/src/restHelpersGet.d.ts +0 -288
  256. package/dist/umd/src/sharing/index.d.ts +0 -16
  257. package/dist/umd/src/sharing/share-item-to-groups.d.ts +0 -26
  258. package/dist/umd/src/templatization.d.ts +0 -139
  259. package/dist/umd/src/trackingHelpers.d.ts +0 -116
  260. package/dist/umd/src/velocityHelpers.d.ts +0 -57
  261. package/dist/umd/src/workforceHelpers.d.ts +0 -115
@@ -1,842 +0,0 @@
1
- "use strict";
2
- /** @license
3
- * Copyright 2018 Esri
4
- *
5
- * Licensed under the Apache License, Version 2.0 (the "License");
6
- * you may not use this file except in compliance with the License.
7
- * You may obtain a copy of the License at
8
- *
9
- * http://www.apache.org/licenses/LICENSE-2.0
10
- *
11
- * Unless required by applicable law or agreed to in writing, software
12
- * distributed under the License is distributed on an "AS IS" BASIS,
13
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- * See the License for the specific language governing permissions and
15
- * limitations under the License.
16
- */
17
- Object.defineProperty(exports, "__esModule", { value: true });
18
- exports._padPositiveNum = exports._getRandomNumberInRange = exports.regExTest = exports.getTemplateById = exports.cleanLayerId = exports.cleanLayerBasedItemId = exports.cleanItemId = exports.hasDatasource = exports.globalStringReplace = exports.getUniqueTitle = exports.hasTypeKeyword = exports.hasAnyKeyword = exports.getUTCTimestamp = exports.setProp = exports.setCreateProp = exports.idTest = exports.getPropWithDefault = exports.getProps = exports.getProp = exports.getIDs = exports.failWithIds = exports.fail = exports.deleteProps = exports.deleteProp = exports.deleteItemProps = exports.sanitizeJSONAndReportChanges = exports.compareJSONProperties = exports.compareJSONNoEmptyStrings = exports.compareJSON = exports.cloneObject = exports.saveBlobAsFile = exports.jsonToFile = exports.jsonToBlob = exports.generateEmptyCreationResponse = exports.dedupe = exports.createShortId = exports.createLongId = exports.checkUrlPathTermination = exports.blobToText = exports.blobToFile = exports.blobToJson = exports.appendQueryParam = void 0;
19
- /**
20
- * Provides general helper functions.
21
- *
22
- * @module generalHelpers
23
- */
24
- const hub_common_1 = require("@esri/hub-common");
25
- const libConnectors_1 = require("./libConnectors");
26
- const polyfills_1 = require("./polyfills");
27
- // ------------------------------------------------------------------------------------------------------------------ //
28
- /**
29
- * Returns a URL with a query parameter appended
30
- *
31
- * @param url URL to append to
32
- * @param parameter Query parameter to append, prefixed with "?" or "&" as appropriate to what url already has
33
- * @returns New URL combining url and parameter
34
- */
35
- function appendQueryParam(url, parameter) {
36
- return url + (url.indexOf("?") === -1 ? "?" : "&") + parameter;
37
- }
38
- exports.appendQueryParam = appendQueryParam;
39
- /**
40
- * Extracts JSON from a Blob.
41
- *
42
- * @param blob Blob to use as source
43
- * @returns A promise that will resolve with JSON or null
44
- */
45
- function blobToJson(blob) {
46
- return new Promise(resolve => {
47
- blobToText(blob).then(blobContents => {
48
- try {
49
- resolve(JSON.parse(blobContents));
50
- }
51
- catch (err) {
52
- resolve(null);
53
- }
54
- }, () => resolve(null));
55
- });
56
- }
57
- exports.blobToJson = blobToJson;
58
- /**
59
- * Converts a Blob to a File.
60
- *
61
- * @param blob Blob to use as source
62
- * @param filename Name to use for file
63
- * @param mimeType MIME type to override blob's MIME type
64
- * @returns File created out of Blob and filename
65
- */
66
- function blobToFile(blob, filename, mimeType) {
67
- return blob
68
- ? (0, polyfills_1.new_File)([blob], filename ? filename : "", {
69
- type: mimeType || blob.type
70
- })
71
- : null;
72
- }
73
- exports.blobToFile = blobToFile;
74
- /**
75
- * Extracts text from a Blob.
76
- *
77
- * @param blob Blob to use as source
78
- * @returns A promise that will resolve with text read from blob
79
- */
80
- function blobToText(blob) {
81
- return new Promise(resolve => {
82
- const reader = new FileReader();
83
- reader.onload = function (evt) {
84
- // Disable needed because Node requires cast
85
- // tslint:disable-next-line: no-unnecessary-type-assertion
86
- const blobContents = evt.target.result;
87
- resolve(blobContents ? blobContents : ""); // not handling ArrayContents variant
88
- };
89
- reader.readAsText(blob);
90
- });
91
- }
92
- exports.blobToText = blobToText;
93
- /**
94
- * Checks that a URL path ends with a slash.
95
- *
96
- * @param url URL to check
97
- * @returns URL, appended with slash if missing
98
- */
99
- function checkUrlPathTermination(url) {
100
- return url ? (url.endsWith("/") ? url : url + "/") : url;
101
- }
102
- exports.checkUrlPathTermination = checkUrlPathTermination;
103
- /**
104
- * Creates a random 32-character alphanumeric string.
105
- *
106
- * @returns A lowercase 32-char alphanumeric string
107
- * @internal
108
- */
109
- function createLongId() {
110
- // createId gets a random number, converts it to base 36 representation, then grabs chars 2-8
111
- return (0, hub_common_1.createId)("") + (0, hub_common_1.createId)("") + (0, hub_common_1.createId)("") + (0, hub_common_1.createId)("");
112
- }
113
- exports.createLongId = createLongId;
114
- /**
115
- * Creates a random 8-character alphanumeric string that begins with an alphabetic character.
116
- *
117
- * @returns An alphanumeric string in the range [a0000000..zzzzzzzz]
118
- */
119
- function createShortId() {
120
- // Return a random number, but beginning with an alphabetic character so that it can be used as a valid
121
- // dotable property name. Used for unique identifiers that do not require the rigor of a full UUID -
122
- // i.e. node ids, process ids, etc.
123
- const min = 0.2777777777777778; // 0.a in base 36
124
- const max = 0.9999999999996456; // 0.zzzzzzzz in base 36
125
- return (_getRandomNumberInRange(min, max).toString(36) + "0000000").substr(2, 8);
126
- }
127
- exports.createShortId = createShortId;
128
- /**
129
- * Copies an input list removing duplicates.
130
- *
131
- * @param input List to be deduped
132
- * @returns Deduped list; order of items in input is not maintained
133
- */
134
- function dedupe(input = []) {
135
- if (input.length === 0) {
136
- return [];
137
- }
138
- const dedupedList = new Set(input);
139
- const output = [];
140
- dedupedList.forEach((value) => output.push(value));
141
- return output;
142
- }
143
- exports.dedupe = dedupe;
144
- /**
145
- * Flags a failure to create an item from a template.
146
- *
147
- * @param itemType The AGO item type
148
- * @param id Item id to include in response
149
- * @returns Empty creation response
150
- */
151
- function generateEmptyCreationResponse(itemType, id = "") {
152
- return {
153
- item: null,
154
- id,
155
- type: itemType,
156
- postProcess: false
157
- };
158
- }
159
- exports.generateEmptyCreationResponse = generateEmptyCreationResponse;
160
- /**
161
- * Converts JSON to a Blob.
162
- *
163
- * @param json JSON to use as source
164
- * @returns A blob from the source JSON
165
- */
166
- function jsonToBlob(json) {
167
- const _json = JSON.stringify(json);
168
- const blobOptions = { type: "application/octet-stream" };
169
- const charArray = [];
170
- for (let i = 0; i < _json.length; i++) {
171
- charArray[i] = _json.charCodeAt(i);
172
- }
173
- return new Blob([new Uint8Array(charArray)], blobOptions);
174
- }
175
- exports.jsonToBlob = jsonToBlob;
176
- /**
177
- * Converts JSON to a File.
178
- *
179
- * @param json JSON to use as source
180
- * @param filename Name to use for file
181
- * @param mimeType MIME type to override blob's MIME type
182
- * @returns File created out of JSON and filename
183
- */
184
- function jsonToFile(json, filename, mimeType = "application/json") {
185
- return blobToFile(jsonToBlob(json), filename, mimeType);
186
- }
187
- exports.jsonToFile = jsonToFile;
188
- /**
189
- * Saves a blob to a file.
190
- *
191
- * @param filename Name to give file
192
- * @param blob Blob to save
193
- * @returns Promise resolving when operation is complete
194
- */
195
- // Function is only used for live testing, so excluding it from coverage for now
196
- /* istanbul ignore next */
197
- function saveBlobAsFile(filename, blob) {
198
- return new Promise(resolve => {
199
- const dataUrl = URL.createObjectURL(blob);
200
- const linkElement = document.createElement("a");
201
- linkElement.setAttribute("href", dataUrl);
202
- linkElement.setAttribute("download", filename);
203
- linkElement.style.display = "none";
204
- document.body.appendChild(linkElement);
205
- linkElement.click();
206
- document.body.removeChild(linkElement);
207
- setTimeout(() => {
208
- URL.revokeObjectURL(dataUrl);
209
- resolve(null);
210
- }, 500);
211
- });
212
- }
213
- exports.saveBlobAsFile = saveBlobAsFile;
214
- /**
215
- * Makes a deep clone, including arrays but not functions.
216
- *
217
- * @param obj Object to be cloned
218
- * @returns Clone of obj
219
- * @example
220
- * ```js
221
- * import { cloneObject } from "utils/object-helpers";
222
- * const original = { foo: "bar" }
223
- * const copy = cloneObject(original)
224
- * copy.foo // "bar"
225
- * copy === original // false
226
- * ```
227
- */
228
- function cloneObject(obj) {
229
- let clone = {};
230
- // first check array
231
- if (Array.isArray(obj)) {
232
- clone = obj.map(cloneObject);
233
- }
234
- else if (typeof obj === "object") {
235
- if (obj instanceof File) {
236
- const fileOptions = obj.type ? { type: obj.type } : undefined;
237
- clone = new File([obj], obj.name, fileOptions);
238
- }
239
- else {
240
- for (const i in obj) {
241
- if (obj[i] != null && typeof obj[i] === "object") {
242
- clone[i] = cloneObject(obj[i]);
243
- }
244
- else {
245
- clone[i] = obj[i];
246
- }
247
- }
248
- }
249
- }
250
- else {
251
- clone = obj;
252
- }
253
- return clone;
254
- }
255
- exports.cloneObject = cloneObject;
256
- /**
257
- * Compares two JSON objects using JSON.stringify.
258
- *
259
- * @param json1 First object
260
- * @param json2 Second object
261
- * @returns True if objects are the same
262
- */
263
- function compareJSON(json1, json2) {
264
- return JSON.stringify(json1) === JSON.stringify(json2);
265
- }
266
- exports.compareJSON = compareJSON;
267
- /**
268
- * Compares two JSON objects using JSON.stringify, converting empty strings to nulls.
269
- *
270
- * @param json1 First object
271
- * @param json2 Second object
272
- * @returns True if objects are the same
273
- */
274
- function compareJSONNoEmptyStrings(json1, json2) {
275
- const jsonStr1 = JSON.stringify(json1).replace(/":""/g, '":null');
276
- const jsonStr2 = JSON.stringify(json2).replace(/":""/g, '":null');
277
- return jsonStr1 === jsonStr2;
278
- }
279
- exports.compareJSONNoEmptyStrings = compareJSONNoEmptyStrings;
280
- /**
281
- * Compares two JSON objects property by property and reports each mismatch.
282
- *
283
- * @param json1 First object
284
- * @param json2 Second object
285
- * @returns A list of mismatch report strings
286
- */
287
- function compareJSONProperties(json1, json2) {
288
- let mismatches = [];
289
- const type1 = _typeof_null(json1);
290
- const type2 = _typeof_null(json2);
291
- if (type1 !== type2) {
292
- // Ignore "undefined" vs. "null" and vice versa
293
- /* istanbul ignore else */
294
- if ((type1 !== "undefined" && type1 !== "null") ||
295
- (type2 !== "null" && type2 !== "undefined")) {
296
- mismatches.push("Type difference: " + type1 + " vs. " + type2);
297
- }
298
- }
299
- else {
300
- if (json1 !== json2) {
301
- switch (type1) {
302
- case "boolean":
303
- mismatches.push("Value difference: " + json1 + " vs. " + json2);
304
- break;
305
- case "number":
306
- mismatches.push("Value difference: " + json1 + " vs. " + json2);
307
- break;
308
- case "string":
309
- mismatches.push('String difference: "' + json1 + '" vs. "' + json2 + '"');
310
- break;
311
- case "object":
312
- const keys1 = Object.keys(json1);
313
- const keys2 = Object.keys(json2);
314
- if (keys1.length !== keys2.length ||
315
- JSON.stringify(keys1) !== JSON.stringify(keys2)) {
316
- if (Array.isArray(json1) && Array.isArray(json2)) {
317
- mismatches.push("Array length difference: [" +
318
- keys1.length +
319
- "] vs. [" +
320
- keys2.length +
321
- "]");
322
- }
323
- else {
324
- mismatches.push("Props difference: " +
325
- JSON.stringify(keys1) +
326
- " vs. " +
327
- JSON.stringify(keys2));
328
- }
329
- }
330
- else {
331
- for (let k = 0; k < keys1.length; ++k) {
332
- const submismatches = compareJSONProperties(json1[keys1[k]], json2[keys2[k]]);
333
- if (submismatches.length > 0) {
334
- mismatches = mismatches.concat(submismatches);
335
- }
336
- }
337
- }
338
- break;
339
- }
340
- }
341
- }
342
- return mismatches;
343
- }
344
- exports.compareJSONProperties = compareJSONProperties;
345
- /**
346
- * Sanitizes JSON and echoes changes to console.
347
- *
348
- * @param json JSON to sanitize
349
- * @param sanitizer Instance of Sanitizer class
350
- * @returns Sanitized version of `json`
351
- * @see https://github.com/esri/arcgis-html-sanitizer#sanitize-json
352
- */
353
- function sanitizeJSONAndReportChanges(json, sanitizer) {
354
- const sanitizedJSON = (0, libConnectors_1.sanitizeJSON)(json, sanitizer);
355
- const mismatches = compareJSONProperties(json, sanitizedJSON);
356
- if (mismatches.length > 0) {
357
- console.warn("Changed " +
358
- mismatches.length +
359
- (mismatches.length === 1 ? " property" : " properties"));
360
- mismatches.forEach(mismatch => console.warn(" " + mismatch));
361
- }
362
- return sanitizedJSON;
363
- }
364
- exports.sanitizeJSONAndReportChanges = sanitizeJSONAndReportChanges;
365
- function deleteItemProps(itemTemplate) {
366
- const propsToRetain = [
367
- "accessInformation",
368
- "appCategories",
369
- "banner",
370
- "categories",
371
- "culture",
372
- "description",
373
- "documentation",
374
- "extent",
375
- "groupDesignations",
376
- "industries",
377
- "languages",
378
- "licenseInfo",
379
- "listed",
380
- "name",
381
- "properties",
382
- "proxyFilter",
383
- "screenshots",
384
- "size",
385
- "snippet",
386
- "spatialReference",
387
- "tags",
388
- "title",
389
- "type",
390
- "typeKeywords",
391
- "url"
392
- ];
393
- const propsToDelete = Object.keys(itemTemplate).filter(k => propsToRetain.indexOf(k) < 0);
394
- deleteProps(itemTemplate, propsToDelete);
395
- return itemTemplate;
396
- }
397
- exports.deleteItemProps = deleteItemProps;
398
- /**
399
- * Deletes a property from an object.
400
- *
401
- * @param obj Object with property to delete
402
- * @param path Path into an object to property, e.g., "data.values.webmap", where "data" is a top-level property
403
- * in obj
404
- */
405
- function deleteProp(obj, path) {
406
- const pathParts = path.split(".");
407
- if (Array.isArray(obj)) {
408
- obj.forEach((child) => deleteProp(child, path));
409
- }
410
- else {
411
- const subpath = pathParts.slice(1).join(".");
412
- if (typeof obj[pathParts[0]] !== "undefined") {
413
- if (pathParts.length === 1) {
414
- delete obj[path];
415
- }
416
- else {
417
- deleteProp(obj[pathParts[0]], subpath);
418
- }
419
- }
420
- }
421
- }
422
- exports.deleteProp = deleteProp;
423
- /**
424
- * Deletes properties from an object.
425
- *
426
- * @param obj Object with properties to delete
427
- * @param props Array of properties on object that should be deleted
428
- */
429
- function deleteProps(obj, props) {
430
- props.forEach(prop => {
431
- deleteProp(obj, prop);
432
- });
433
- }
434
- exports.deleteProps = deleteProps;
435
- /**
436
- * Creates an AGO-style JSON failure response with success property.
437
- *
438
- * @param e Optional error information
439
- * @returns JSON structure with property success set to false and optionally including `e`
440
- */
441
- function fail(e) {
442
- if (e) {
443
- return { success: false, error: e.response?.error || e.error || e };
444
- }
445
- else {
446
- return { success: false };
447
- }
448
- }
449
- exports.fail = fail;
450
- /**
451
- * Creates an AGO-style JSON failure response with success property and extended with ids list.
452
- *
453
- * @param ids List of ids
454
- * @param e Optional error information
455
- * @returns JSON structure with property success set to false and optionally including `e`
456
- */
457
- function failWithIds(itemIds, e) {
458
- if (e) {
459
- return { success: false, itemIds, error: e.error || e };
460
- }
461
- else {
462
- return { success: false, itemIds };
463
- }
464
- }
465
- exports.failWithIds = failWithIds;
466
- /**
467
- * Extracts the ids from a string
468
- *
469
- * @param v String to examine
470
- * @returns List of id strings found
471
- * @example
472
- * get id from
473
- * bad3483e025c47338d43df308c117308
474
- * {bad3483e025c47338d43df308c117308
475
- * =bad3483e025c47338d43df308c117308
476
- * do not get id from
477
- * http: *something/name_bad3483e025c47338d43df308c117308
478
- * {{bad3483e025c47338d43df308c117308.itemId}}
479
- * bad3483e025c47338d43df308c117308bad3483e025c47338d43df308c117308
480
- */
481
- function getIDs(v) {
482
- // lookbehind is not supported in safari
483
- // cannot use /(?<!_)(?<!{{)\b[0-9A-F]{32}/gi
484
- // use groups and filter out the ids that start with {{
485
- return regExTest(v, /({*)(\b[0-9A-F]{32}\b)/gi).reduce(function (acc, _v) {
486
- /* istanbul ignore else */
487
- if (_v.indexOf("{{") < 0) {
488
- acc.push(_v.replace("{", ""));
489
- }
490
- return acc;
491
- }, []);
492
- }
493
- exports.getIDs = getIDs;
494
- /**
495
- * Gets a property out of a deeply nested object.
496
- * Does not handle anything but nested object graph
497
- *
498
- * @param obj Object to retrieve value from
499
- * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property
500
- * in obj
501
- * @returns Value at end of path
502
- */
503
- function getProp(obj, path) {
504
- return path.split(".").reduce(function (prev, curr) {
505
- /* istanbul ignore next no need to test undefined scenario */
506
- return prev ? prev[curr] : undefined;
507
- }, obj);
508
- }
509
- exports.getProp = getProp;
510
- /**
511
- * Returns an array of values from an object based on an array of property paths.
512
- *
513
- * @param obj Object to retrieve values from
514
- * @param props Array of paths into the object e.g., "data.values.webmap", where "data" is a top-level property
515
- * @returns Array of the values plucked from the object; only defined values are returned
516
- */
517
- function getProps(obj, props) {
518
- return props.reduce((a, p) => {
519
- const v = getProp(obj, p);
520
- if (v) {
521
- a.push(v);
522
- }
523
- return a;
524
- }, []);
525
- }
526
- exports.getProps = getProps;
527
- /**
528
- * Get a property out of a deeply nested object
529
- * Does not handle anything but nested object graph
530
- *
531
- * @param obj Object to retrieve value from
532
- * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property
533
- * in obj
534
- * @param defaultV Optional value to use if any part of path--including final value--is undefined
535
- * @returns Value at end of path
536
- */
537
- function getPropWithDefault(obj, path, defaultV) {
538
- const value = path.split(".").reduce(function (prev, curr) {
539
- /* istanbul ignore next no need to test undefined scenario */
540
- return prev ? prev[curr] : undefined;
541
- }, obj);
542
- if (typeof value === "undefined") {
543
- return defaultV;
544
- }
545
- else {
546
- return value;
547
- }
548
- }
549
- exports.getPropWithDefault = getPropWithDefault;
550
- /**
551
- * Updates a list of the items dependencies if more are found in the
552
- * provided value.
553
- *
554
- * @param v a string value to check for ids
555
- * @param deps a list of the items dependencies
556
- */
557
- function idTest(v, deps) {
558
- const ids = getIDs(v);
559
- ids.forEach(id => {
560
- /* istanbul ignore else */
561
- if (deps.indexOf(id) === -1) {
562
- deps.push(id);
563
- }
564
- });
565
- }
566
- exports.idTest = idTest;
567
- /**
568
- * Sets a deeply nested property of an object.
569
- * Creates the full path if it does not exist.
570
- *
571
- * @param obj Object to set value of
572
- * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property in obj
573
- * @param value The value to set at the end of the path
574
- */
575
- function setCreateProp(obj, path, value) {
576
- const pathParts = path.split(".");
577
- pathParts.reduce((a, b, c) => {
578
- if (c === pathParts.length - 1) {
579
- a[b] = value;
580
- return value;
581
- }
582
- else {
583
- if (!a[b]) {
584
- a[b] = {};
585
- }
586
- return a[b];
587
- }
588
- }, obj);
589
- }
590
- exports.setCreateProp = setCreateProp;
591
- /**
592
- * Sets a deeply nested property of an object.
593
- * Does nothing if the full path does not exist.
594
- *
595
- * @param obj Object to set value of
596
- * @param path Path into an object, e.g., "data.values.webmap", where "data" is a top-level property in obj
597
- * @param value The value to set at the end of the path
598
- */
599
- function setProp(obj, path, value) {
600
- if (getProp(obj, path)) {
601
- const pathParts = path.split(".");
602
- pathParts.reduce((a, b, c) => {
603
- if (c === pathParts.length - 1) {
604
- a[b] = value;
605
- return value;
606
- }
607
- else {
608
- return a[b];
609
- }
610
- }, obj);
611
- }
612
- }
613
- exports.setProp = setProp;
614
- /**
615
- * Creates a timestamp string using the current UTC date and time.
616
- *
617
- * @returns Timestamp formatted as YYYYMMDD_hhmm_ssmmm, with month one-based and all values padded with zeroes on the
618
- * left as needed (`ssmmm` stands for seconds from 0..59 and milliseconds from 0..999)
619
- * @private
620
- */
621
- function getUTCTimestamp() {
622
- const now = new Date();
623
- return (_padPositiveNum(now.getUTCFullYear(), 4) +
624
- _padPositiveNum(now.getUTCMonth() + 1, 2) +
625
- _padPositiveNum(now.getUTCDate(), 2) +
626
- "_" +
627
- _padPositiveNum(now.getUTCHours(), 2) +
628
- _padPositiveNum(now.getUTCMinutes(), 2) +
629
- "_" +
630
- _padPositiveNum(now.getUTCSeconds(), 2) +
631
- _padPositiveNum(now.getUTCMilliseconds(), 3));
632
- }
633
- exports.getUTCTimestamp = getUTCTimestamp;
634
- /**
635
- * Tests if an object's `item.typeKeywords` or `typeKeywords` properties has any of a set of keywords.
636
- *
637
- * @param jsonObj Object to test
638
- * @param keywords List of keywords to look for in jsonObj
639
- * @returns Boolean indicating result
640
- */
641
- function hasAnyKeyword(jsonObj, keywords) {
642
- const typeKeywords = getProp(jsonObj, "item.typeKeywords") || jsonObj.typeKeywords || [];
643
- return keywords.reduce((a, kw) => {
644
- if (!a) {
645
- a = typeKeywords.includes(kw);
646
- }
647
- return a;
648
- }, false);
649
- }
650
- exports.hasAnyKeyword = hasAnyKeyword;
651
- /**
652
- * Tests if an object's `item.typeKeywords` or `typeKeywords` properties has a specific keyword.
653
- *
654
- * @param jsonObj Object to test
655
- * @param keyword Keyword to look for in jsonObj
656
- * @returns Boolean indicating result
657
- */
658
- function hasTypeKeyword(jsonObj, keyword) {
659
- const typeKeywords = getProp(jsonObj, "item.typeKeywords") || jsonObj.typeKeywords || [];
660
- return typeKeywords.includes(keyword);
661
- }
662
- exports.hasTypeKeyword = hasTypeKeyword;
663
- /**
664
- * Will return the provided title if it does not exist as a property
665
- * in one of the objects at the defined path. Otherwise the title will
666
- * have a numerical value attached.
667
- *
668
- * @param title The root title to test
669
- * @param templateDictionary Hash of the facts
670
- * @param path to the objects to evaluate for potantial name clashes
671
- * @returns string The unique title to use
672
- */
673
- function getUniqueTitle(title, templateDictionary, path) {
674
- title = title ? title.trim() : "_";
675
- const objs = getProp(templateDictionary, path) || [];
676
- const titles = objs.map(obj => {
677
- return obj.title;
678
- });
679
- let newTitle = title;
680
- let i = 0;
681
- while (titles.indexOf(newTitle) > -1) {
682
- i++;
683
- newTitle = title + " " + i;
684
- }
685
- return newTitle;
686
- }
687
- exports.getUniqueTitle = getUniqueTitle;
688
- /**
689
- * Performs string replacement on every string in an object.
690
- *
691
- * @param obj Object to scan and to modify
692
- * @param pattern Search pattern in each string
693
- * @param replacement Replacement for matches to search pattern
694
- * @returns Modified obj is returned
695
- */
696
- function globalStringReplace(obj, pattern, replacement) {
697
- if (obj) {
698
- Object.keys(obj).forEach(prop => {
699
- const propObj = obj[prop];
700
- if (propObj) {
701
- /* istanbul ignore else */
702
- if (typeof propObj === "object") {
703
- globalStringReplace(propObj, pattern, replacement);
704
- }
705
- else if (typeof propObj === "string") {
706
- obj[prop] = obj[prop].replace(pattern, replacement);
707
- }
708
- }
709
- });
710
- }
711
- return obj;
712
- }
713
- exports.globalStringReplace = globalStringReplace;
714
- /**
715
- * Tests if an array of DatasourceInfos has a given item and layer id already.
716
- *
717
- * @param datasourceInfos Array of DatasourceInfos to evaluate
718
- * @param itemId The items id to check for
719
- * @param layerId The layers id to check for
720
- * @returns Boolean indicating result
721
- */
722
- function hasDatasource(datasourceInfos, itemId, layerId) {
723
- return datasourceInfos.some(ds => ds.itemId === itemId && ds.layerId === layerId);
724
- }
725
- exports.hasDatasource = hasDatasource;
726
- /**
727
- * remove templatization from item id to compare
728
- *
729
- * @example
730
- * \{\{934a9ef8efa7448fa8ddf7b13cef0240.itemId\}\}
731
- * returns 934a9ef8efa7448fa8ddf7b13cef0240
732
- */
733
- function cleanItemId(id) {
734
- return id ? id.replace("{{", "").replace(".itemId}}", "") : id;
735
- }
736
- exports.cleanItemId = cleanItemId;
737
- /**
738
- * remove templatization from layer based item id to compare
739
- *
740
- * @example
741
- * \{\{934a9ef8efa7448fa8ddf7b13cef0240.layer0.itemId\}\}
742
- * returns 934a9ef8efa7448fa8ddf7b13cef0240
743
- */
744
- function cleanLayerBasedItemId(id) {
745
- return id
746
- ? id
747
- .replace("{{", "")
748
- .replace(/([.]layer([0-9]|[1-9][0-9])[.](item|layer)Id)[}]{2}/, "")
749
- : id;
750
- }
751
- exports.cleanLayerBasedItemId = cleanLayerBasedItemId;
752
- /**
753
- * remove templatization from layer id to compare
754
- *
755
- * @example
756
- * \{\{934a9ef8efa7448fa8ddf7b13cef0240.layer0.layerId\}\}
757
- * returns 0
758
- */
759
- function cleanLayerId(id) {
760
- return id?.toString()
761
- ? parseInt(id
762
- .toString()
763
- .replace(/[{]{2}.{32}[.]layer/, "")
764
- .replace(/[.]layerId[}]{2}/, ""), 10)
765
- : id;
766
- }
767
- exports.cleanLayerId = cleanLayerId;
768
- /**
769
- * Get template from list of templates by ID
770
- *
771
- * @param templates Array of item templates to search
772
- * @param id of template we are searching for
773
- *
774
- * @returns Template associated with the user provided id argument
775
- */
776
- function getTemplateById(templates, id) {
777
- let template;
778
- (templates || []).some(_template => {
779
- if (_template.itemId === id) {
780
- template = _template;
781
- return true;
782
- }
783
- return false;
784
- });
785
- return template;
786
- }
787
- exports.getTemplateById = getTemplateById;
788
- /**
789
- * Evaluates a value with a regular expression
790
- *
791
- * @param v a string value to test with the expression
792
- * @param ex the regular expresion to test with
793
- * @returns an array of matches
794
- */
795
- function regExTest(v, ex) {
796
- return v && ex.test(v) ? v.match(ex) : [];
797
- }
798
- exports.regExTest = regExTest;
799
- // ------------------------------------------------------------------------------------------------------------------ //
800
- /**
801
- * Creates a random number between two values.
802
- *
803
- * @param min Inclusive minimum desired value
804
- * @param max Non-inclusive maximum desired value
805
- * @returns Random number in the range [min, max)
806
- */
807
- function _getRandomNumberInRange(min, max) {
808
- // https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Math/random#Getting_a_random_number_between_two_values
809
- // © 2006 IvanWills
810
- // MIT license https://opensource.org/licenses/mit-license.php
811
- return Math.random() * (max - min) + min;
812
- }
813
- exports._getRandomNumberInRange = _getRandomNumberInRange;
814
- /**
815
- * Pads the string representation of a number to a minimum width. Requires modern browser.
816
- *
817
- * @param n Number to pad
818
- * @param totalSize Desired *minimum* width of number after padding with zeroes
819
- * @returns Number converted to string and padded on the left as needed
820
- * @private
821
- */
822
- function _padPositiveNum(n, totalSize) {
823
- let numStr = n.toString();
824
- const numPads = totalSize - numStr.length;
825
- if (numPads > 0) {
826
- numStr = "0".repeat(numPads) + numStr; // TODO IE11 does not support repeat()
827
- }
828
- return numStr;
829
- }
830
- exports._padPositiveNum = _padPositiveNum;
831
- /**
832
- * Implements rejected ECMA proposal to change `typeof null` from "object" to "null".
833
- *
834
- * @param value Value whose type is sought
835
- * @returns "null" if `value` is null; `typeof value` otherwise
836
- * @see https://web.archive.org/web/20160331031419/http://wiki.ecmascript.org:80/doku.php?id=harmony:typeof_null
837
- * @private
838
- */
839
- function _typeof_null(value) {
840
- return value === null ? "null" : typeof value;
841
- }
842
- //# sourceMappingURL=generalHelpers.js.map