@8ms/helpers 2.0.0 → 2.0.2

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 (345) hide show
  1. package/.github/workflows/deploy_npmjs.yml +7 -0
  2. package/.yarn/install-state.gz +0 -0
  3. package/_class/BaseClass.d.ts +18 -0
  4. package/_class/BaseClass.js +53 -0
  5. package/_class/BaseNamespace.d.ts +9 -0
  6. package/_class/BaseNamespace.js +27 -0
  7. package/_class/index.d.ts +2 -0
  8. package/_class/index.js +7 -0
  9. package/adverity/getJobs.d.ts +15 -0
  10. package/adverity/getJobs.js +30 -0
  11. package/adverity/index.d.ts +112 -0
  12. package/adverity/index.js +61 -0
  13. package/api/ApiResponseClass.d.ts +35 -0
  14. package/api/ApiResponseClass.js +97 -0
  15. package/api/index.d.ts +22 -0
  16. package/api/index.js +44 -0
  17. package/array/index.d.ts +8 -0
  18. package/array/index.js +17 -0
  19. package/atInternet/index.d.ts +16 -0
  20. package/atInternet/index.js +18 -0
  21. package/aws/athenaExpress/AwsAthenaNamespace.d.ts +8 -0
  22. package/aws/athenaExpress/AwsAthenaNamespace.js +82 -0
  23. package/aws/athenaExpress/index.d.ts +10 -0
  24. package/aws/athenaExpress/index.js +40 -0
  25. package/aws/ec2/AwsEc2Namespace.d.ts +10 -0
  26. package/aws/ec2/AwsEc2Namespace.js +78 -0
  27. package/aws/ec2/index.d.ts +3 -0
  28. package/aws/ec2/index.js +16 -0
  29. package/aws/ecs/AwsEcsNamespace.d.ts +53 -0
  30. package/aws/ecs/AwsEcsNamespace.js +159 -0
  31. package/aws/ecs/index.d.ts +3 -0
  32. package/aws/ecs/index.js +16 -0
  33. package/aws/glue/AwsGlueNamespace.d.ts +12 -0
  34. package/aws/glue/AwsGlueNamespace.js +70 -0
  35. package/aws/glue/index.d.ts +3 -0
  36. package/aws/glue/index.js +16 -0
  37. package/aws/index.d.ts +9 -0
  38. package/aws/index.js +34 -0
  39. package/aws/isResponse200.d.ts +4 -0
  40. package/aws/isResponse200.js +16 -0
  41. package/aws/lambda/AwsLambdaNamespace.d.ts +21 -0
  42. package/aws/lambda/AwsLambdaNamespace.js +110 -0
  43. package/aws/lambda/index.d.ts +4 -0
  44. package/aws/lambda/index.js +21 -0
  45. package/aws/s3/AwsS3Namespace.d.ts +60 -0
  46. package/aws/s3/AwsS3Namespace.js +401 -0
  47. package/aws/s3/index.d.ts +25 -0
  48. package/aws/s3/index.js +36 -0
  49. package/aws/s3/payload.d.ts +42 -0
  50. package/aws/s3/payload.js +46 -0
  51. package/aws/ses/AwsSesNamespace.d.ts +18 -0
  52. package/aws/ses/AwsSesNamespace.js +69 -0
  53. package/aws/ses/SimpleEmail.d.ts +56 -0
  54. package/aws/ses/SimpleEmail.js +106 -0
  55. package/aws/ses/index.d.ts +4 -0
  56. package/aws/ses/index.js +18 -0
  57. package/aws/sqs/AwsSqsNamespace.d.ts +34 -0
  58. package/aws/sqs/AwsSqsNamespace.js +96 -0
  59. package/aws/sqs/index.d.ts +3 -0
  60. package/aws/sqs/index.js +16 -0
  61. package/aws/ssm/AwsSsmNamespace.d.ts +11 -0
  62. package/aws/ssm/AwsSsmNamespace.js +89 -0
  63. package/aws/ssm/index.d.ts +3 -0
  64. package/aws/ssm/index.js +16 -0
  65. package/axios/deleteRequest.d.ts +6 -0
  66. package/axios/deleteRequest.js +33 -0
  67. package/axios/get.d.ts +5 -0
  68. package/axios/get.js +31 -0
  69. package/axios/index.d.ts +3 -0
  70. package/axios/index.js +9 -0
  71. package/axios/post.d.ts +5 -0
  72. package/axios/post.js +32 -0
  73. package/boolean/getBoolean.d.ts +4 -0
  74. package/boolean/getBoolean.js +23 -0
  75. package/boolean/index.d.ts +1 -0
  76. package/boolean/index.js +5 -0
  77. package/brightData/index.d.ts +15 -0
  78. package/brightData/index.js +20 -0
  79. package/brightData/serpApi/buildGoogleSerpUrl.d.ts +32 -0
  80. package/brightData/serpApi/buildGoogleSerpUrl.js +116 -0
  81. package/brightData/serpApi/buildGoogleTrendsUrl.d.ts +22 -0
  82. package/brightData/serpApi/buildGoogleTrendsUrl.js +61 -0
  83. package/brightData/serpApi/getAsyncRequestId.d.ts +8 -0
  84. package/brightData/serpApi/getAsyncRequestId.js +36 -0
  85. package/brightData/serpApi/getAsyncResults.d.ts +7 -0
  86. package/brightData/serpApi/getAsyncResults.js +35 -0
  87. package/brightData/serpApi/getRealtime.d.ts +5 -0
  88. package/brightData/serpApi/getRealtime.js +30 -0
  89. package/brightData/serpApi/index.d.ts +14 -0
  90. package/brightData/serpApi/index.js +23 -0
  91. package/brightData/webScraperIde/getBatch.d.ts +7 -0
  92. package/brightData/webScraperIde/getBatch.js +28 -0
  93. package/brightData/webScraperIde/getRealtime.d.ts +7 -0
  94. package/brightData/webScraperIde/getRealtime.js +49 -0
  95. package/brightData/webScraperIde/index.d.ts +2 -0
  96. package/brightData/webScraperIde/index.js +7 -0
  97. package/cache/index.d.ts +2 -0
  98. package/cache/index.js +48 -0
  99. package/cache/test/cache.test.d.ts +1 -0
  100. package/cache/test/cache.test.js +10 -0
  101. package/crud/index.d.ts +6 -0
  102. package/crud/index.js +10 -0
  103. package/crypto/getDecrypt.d.ts +5 -0
  104. package/crypto/getDecrypt.js +47 -0
  105. package/crypto/getEncrypt.d.ts +5 -0
  106. package/crypto/getEncrypt.js +47 -0
  107. package/crypto/getRandom.d.ts +4 -0
  108. package/crypto/getRandom.js +12 -0
  109. package/crypto/getSha256.d.ts +5 -0
  110. package/crypto/getSha256.js +48 -0
  111. package/crypto/index.d.ts +4 -0
  112. package/crypto/index.js +11 -0
  113. package/date/calculation.d.ts +75 -0
  114. package/date/calculation.js +207 -0
  115. package/date/financialYear.d.ts +19 -0
  116. package/date/financialYear.js +85 -0
  117. package/date/format.d.ts +68 -0
  118. package/date/format.js +150 -0
  119. package/date/index.d.ts +35 -0
  120. package/date/index.js +57 -0
  121. package/environment/index.d.ts +32 -0
  122. package/environment/index.js +92 -0
  123. package/eskimi/getAgeGroup.d.ts +4 -0
  124. package/eskimi/getAgeGroup.js +15 -0
  125. package/eskimi/getData.d.ts +4 -0
  126. package/eskimi/getData.js +17 -0
  127. package/eskimi/getDevice.d.ts +4 -0
  128. package/eskimi/getDevice.js +15 -0
  129. package/eskimi/getGender.d.ts +4 -0
  130. package/eskimi/getGender.js +15 -0
  131. package/eskimi/index.d.ts +49 -0
  132. package/eskimi/index.js +96 -0
  133. package/file/createDirectory.d.ts +5 -0
  134. package/file/createDirectory.js +50 -0
  135. package/file/index.d.ts +1 -0
  136. package/file/index.js +5 -0
  137. package/geo/countries.d.ts +12 -0
  138. package/geo/countries.js +222 -0
  139. package/geo/index.d.ts +2 -0
  140. package/geo/index.js +7 -0
  141. package/geo/languages.d.ts +9 -0
  142. package/geo/languages.js +58 -0
  143. package/google/bigQuery/GoogleBigQueryNamespace.d.ts +51 -0
  144. package/google/bigQuery/GoogleBigQueryNamespace.js +165 -0
  145. package/google/bigQuery/index.d.ts +5 -0
  146. package/google/bigQuery/index.js +37 -0
  147. package/google/bigQuery/loadData.d.ts +19 -0
  148. package/google/bigQuery/loadData.js +18 -0
  149. package/google/index.d.ts +27 -0
  150. package/google/index.js +24 -0
  151. package/google/sheets/GoogleSheetsNamespace.d.ts +16 -0
  152. package/google/sheets/GoogleSheetsNamespace.js +81 -0
  153. package/google/sheets/getAssociatedData.d.ts +10 -0
  154. package/google/sheets/getAssociatedData.js +43 -0
  155. package/google/sheets/index.d.ts +8 -0
  156. package/google/sheets/index.js +37 -0
  157. package/google/storage/GoogleCloudStorageNamespace.d.ts +20 -0
  158. package/google/storage/GoogleCloudStorageNamespace.js +108 -0
  159. package/google/storage/index.d.ts +3 -0
  160. package/google/storage/index.js +30 -0
  161. package/googleAds/GoogleAdsNamespace.d.ts +11 -0
  162. package/googleAds/GoogleAdsNamespace.js +73 -0
  163. package/googleAds/index.d.ts +11 -0
  164. package/googleAds/index.js +30 -0
  165. package/googleAds/keywordPlanner/index.d.ts +40 -0
  166. package/googleAds/keywordPlanner/index.js +59 -0
  167. package/googlePageSpeed/GooglePageSpeedNamespace.d.ts +11 -0
  168. package/googlePageSpeed/GooglePageSpeedNamespace.js +35 -0
  169. package/googlePageSpeed/index.d.ts +17 -0
  170. package/googlePageSpeed/index.js +44 -0
  171. package/googleSearchIncidents/index.d.ts +69 -0
  172. package/googleSearchIncidents/index.js +46 -0
  173. package/greenDomain/index.d.ts +21 -0
  174. package/greenDomain/index.js +41 -0
  175. package/inngest/index.d.ts +6 -0
  176. package/inngest/index.js +10 -0
  177. package/json/getJsonNewline.d.ts +1 -0
  178. package/json/getJsonNewline.js +13 -0
  179. package/json/index.d.ts +2 -0
  180. package/json/index.js +7 -0
  181. package/json/isJson.d.ts +1 -0
  182. package/json/isJson.js +26 -0
  183. package/littleWarden/LittleWardenNamespace.d.ts +11 -0
  184. package/littleWarden/LittleWardenNamespace.js +38 -0
  185. package/littleWarden/getUrlStatus.d.ts +4 -0
  186. package/littleWarden/getUrlStatus.js +16 -0
  187. package/littleWarden/index.d.ts +29 -0
  188. package/littleWarden/index.js +74 -0
  189. package/lumar/api/buildRequest.d.ts +13 -0
  190. package/lumar/api/buildRequest.js +80 -0
  191. package/lumar/api/getData.d.ts +5 -0
  192. package/lumar/api/getData.js +13 -0
  193. package/lumar/api/index.d.ts +36 -0
  194. package/lumar/api/index.js +33 -0
  195. package/lumar/api/initClient.d.ts +6 -0
  196. package/lumar/api/initClient.js +26 -0
  197. package/lumar/graphql/columns.d.ts +28 -0
  198. package/lumar/graphql/columns.js +31 -0
  199. package/lumar/graphql/getData.d.ts +1 -0
  200. package/lumar/graphql/getData.js +20 -0
  201. package/lumar/graphql/index.d.ts +29 -0
  202. package/lumar/graphql/index.js +39 -0
  203. package/lumar/graphql/initClient.d.ts +5 -0
  204. package/lumar/graphql/initClient.js +25 -0
  205. package/lumar/graphql/queries/crawl.d.ts +5 -0
  206. package/lumar/graphql/queries/crawl.js +2 -0
  207. package/lumar/graphql/queries/getCrawls.d.ts +18 -0
  208. package/lumar/graphql/queries/getCrawls.js +33 -0
  209. package/lumar/graphql/queries/getReportDifferences.d.ts +24 -0
  210. package/lumar/graphql/queries/getReportDifferences.js +37 -0
  211. package/lumar/graphql/queries/getRows.d.ts +38 -0
  212. package/lumar/graphql/queries/getRows.js +57 -0
  213. package/lumar/graphql/queries/getTotals.d.ts +25 -0
  214. package/lumar/graphql/queries/getTotals.js +40 -0
  215. package/lumar/graphql/queries/row.d.ts +157 -0
  216. package/lumar/graphql/queries/row.js +2 -0
  217. package/lumar/graphql/reportTemplates.d.ts +67 -0
  218. package/lumar/graphql/reportTemplates.js +70 -0
  219. package/myTarget/request.d.ts +5 -0
  220. package/myTarget/request.js +17 -0
  221. package/nextAuth/index.d.ts +6 -0
  222. package/nextAuth/index.js +11 -0
  223. package/nextAuth/isSessionReady.d.ts +1 -0
  224. package/nextAuth/isSessionReady.js +13 -0
  225. package/nextJs/getIp.d.ts +6 -0
  226. package/nextJs/getIp.js +14 -0
  227. package/nextJs/getUserAgent.d.ts +6 -0
  228. package/nextJs/getUserAgent.js +8 -0
  229. package/nextJs/index.d.ts +2 -0
  230. package/nextJs/index.js +7 -0
  231. package/number/format.d.ts +12 -0
  232. package/number/format.js +20 -0
  233. package/number/formatCurrency.d.ts +5 -0
  234. package/number/formatCurrency.js +21 -0
  235. package/number/getDecimal.d.ts +4 -0
  236. package/number/getDecimal.js +12 -0
  237. package/number/getNumber.d.ts +4 -0
  238. package/number/getNumber.js +48 -0
  239. package/number/getPercentIncrease.d.ts +4 -0
  240. package/number/getPercentIncrease.js +16 -0
  241. package/number/getSafeDivide.d.ts +11 -0
  242. package/number/getSafeDivide.js +20 -0
  243. package/number/index.d.ts +6 -0
  244. package/number/index.js +15 -0
  245. package/object/index.d.ts +1 -0
  246. package/object/index.js +5 -0
  247. package/object/replaceKeys.d.ts +5 -0
  248. package/object/replaceKeys.js +25 -0
  249. package/onePassword/OnePasswordNamespace.d.ts +13 -0
  250. package/onePassword/OnePasswordNamespace.js +81 -0
  251. package/onePassword/index.d.ts +7 -0
  252. package/onePassword/index.js +25 -0
  253. package/openAi/OpenAiNamespace.d.ts +11 -0
  254. package/openAi/OpenAiNamespace.js +44 -0
  255. package/openAi/index.d.ts +5 -0
  256. package/openAi/index.js +30 -0
  257. package/package.json +2 -2
  258. package/prisma/PrismaNamespace.d.ts +8 -0
  259. package/prisma/PrismaNamespace.js +79 -0
  260. package/prisma/getDecimal.d.ts +4 -0
  261. package/prisma/getDecimal.js +23 -0
  262. package/prisma/index.d.ts +8 -0
  263. package/prisma/index.js +29 -0
  264. package/snapchat/SnapchatNamespace.d.ts +15 -0
  265. package/snapchat/SnapchatNamespace.js +30 -0
  266. package/snapchat/index.d.ts +7 -0
  267. package/snapchat/index.js +30 -0
  268. package/sorting/byNumberAscending.d.ts +4 -0
  269. package/sorting/byNumberAscending.js +19 -0
  270. package/sorting/byNumberDescending.d.ts +4 -0
  271. package/sorting/byNumberDescending.js +22 -0
  272. package/sorting/byStringAscending.d.ts +4 -0
  273. package/sorting/byStringAscending.js +16 -0
  274. package/sorting/byStringDescending.d.ts +4 -0
  275. package/sorting/byStringDescending.js +16 -0
  276. package/sorting/index.d.ts +4 -0
  277. package/sorting/index.js +11 -0
  278. package/stream/index.d.ts +1 -0
  279. package/stream/index.js +5 -0
  280. package/stream/sort.d.ts +13 -0
  281. package/stream/sort.js +51 -0
  282. package/string/getCapitalised.d.ts +5 -0
  283. package/string/getCapitalised.js +18 -0
  284. package/string/getClean.d.ts +18 -0
  285. package/string/getClean.js +51 -0
  286. package/string/getFolder.d.ts +4 -0
  287. package/string/getFolder.js +15 -0
  288. package/string/getProperCase.d.ts +11 -0
  289. package/string/getProperCase.js +25 -0
  290. package/string/getString.d.ts +4 -0
  291. package/string/getString.js +34 -0
  292. package/string/getStringFromStream.d.ts +5 -0
  293. package/string/getStringFromStream.js +17 -0
  294. package/string/getUnescaped.d.ts +6 -0
  295. package/string/getUnescaped.js +26 -0
  296. package/string/getWithoutAccents.d.ts +5 -0
  297. package/string/getWithoutAccents.js +13 -0
  298. package/string/getWithoutHtmlTags.d.ts +5 -0
  299. package/string/getWithoutHtmlTags.js +12 -0
  300. package/string/getWithoutPunctuation.d.ts +5 -0
  301. package/string/getWithoutPunctuation.js +13 -0
  302. package/string/getWithoutUnderscores.d.ts +4 -0
  303. package/string/getWithoutUnderscores.js +11 -0
  304. package/string/getWithoutWhitespaces.d.ts +5 -0
  305. package/string/getWithoutWhitespaces.js +13 -0
  306. package/string/index.d.ts +12 -0
  307. package/string/index.js +27 -0
  308. package/swr/index.d.ts +42 -0
  309. package/swr/index.js +59 -0
  310. package/upTimeRobot/UpTimeRobotNamespace.d.ts +31 -0
  311. package/upTimeRobot/UpTimeRobotNamespace.js +52 -0
  312. package/upTimeRobot/index.d.ts +38 -0
  313. package/upTimeRobot/index.js +63 -0
  314. package/url/index.d.ts +30 -0
  315. package/url/index.js +72 -0
  316. package/url/writeUrlContents.d.ts +6 -0
  317. package/url/writeUrlContents.js +75 -0
  318. package/util/defaultTo.d.ts +4 -0
  319. package/util/defaultTo.js +44 -0
  320. package/util/getBrotliCompressed.d.ts +5 -0
  321. package/util/getBrotliCompressed.js +23 -0
  322. package/util/getBrotliDecompressed.d.ts +5 -0
  323. package/util/getBrotliDecompressed.js +24 -0
  324. package/util/getClean.d.ts +11 -0
  325. package/util/getClean.js +23 -0
  326. package/util/getGzipCompressed.d.ts +5 -0
  327. package/util/getGzipCompressed.js +23 -0
  328. package/util/getGzipDecompressed.d.ts +5 -0
  329. package/util/getGzipDecompressed.js +24 -0
  330. package/util/getWithoutHash.d.ts +4 -0
  331. package/util/getWithoutHash.js +18 -0
  332. package/util/getWithoutParameter.d.ts +4 -0
  333. package/util/getWithoutParameter.js +18 -0
  334. package/util/index.d.ts +11 -0
  335. package/util/index.js +25 -0
  336. package/util/isUndefined.d.ts +4 -0
  337. package/util/isUndefined.js +13 -0
  338. package/util/promiseChunks.d.ts +5 -0
  339. package/util/promiseChunks.js +19 -0
  340. package/util/sleep.d.ts +1 -0
  341. package/util/sleep.js +7 -0
  342. package/webWorker/index.d.ts +5 -0
  343. package/webWorker/index.js +9 -0
  344. package/xml/getXml.d.ts +1 -0
  345. package/xml/getXml.js +18 -0
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.snapchatClient = void 0;
4
+ const SnapchatNamespace_1 = require("./SnapchatNamespace");
5
+ const onePassword_1 = require("../onePassword");
6
+ const snapchatNamespaces = new Map();
7
+ const snapchatClient = async (key = "default", config, vaultId, itemId) => {
8
+ if (snapchatNamespaces.has(key)) {
9
+ return snapchatNamespaces.get(key);
10
+ }
11
+ let instanceConfig;
12
+ if (config) {
13
+ instanceConfig = config;
14
+ }
15
+ else if (vaultId && itemId) {
16
+ instanceConfig = await (await (0, onePassword_1.onePasswordClient)())
17
+ .getJsonNote(vaultId, itemId);
18
+ }
19
+ else if ("default" === key && process.env.SNAPCHAT_VAULT_ID && process.env.SNAPCHAT_ITEM_ID) {
20
+ instanceConfig = await (await (0, onePassword_1.onePasswordClient)())
21
+ .getJsonNote(process.env.SNAPCHAT_VAULT_ID, process.env.SNAPCHAT_ITEM_ID);
22
+ }
23
+ else {
24
+ throw new Error(`Config required for namespace '${key}'`);
25
+ }
26
+ const namespace = new SnapchatNamespace_1.SnapchatNamespace(key, instanceConfig);
27
+ snapchatNamespaces.set(key, namespace);
28
+ return namespace;
29
+ };
30
+ exports.snapchatClient = snapchatClient;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take two values, ensure they are numbers and return the sorting value.
3
+ */
4
+ export declare const byNumberAscending: (valueA: any, valueB: any) => number;
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.byNumberAscending = void 0;
4
+ /**
5
+ * Take two values, ensure they are numbers and return the sorting value.
6
+ */
7
+ const byNumberAscending = (valueA, valueB) => {
8
+ const a = Number(valueA);
9
+ const b = Number(valueB);
10
+ // Handle NaN cases
11
+ if (isNaN(a) && isNaN(b))
12
+ return 0;
13
+ if (isNaN(a))
14
+ return 1;
15
+ if (isNaN(b))
16
+ return -1;
17
+ return a - b;
18
+ };
19
+ exports.byNumberAscending = byNumberAscending;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take two values, ensure they are numbers and return the sorting value.
3
+ */
4
+ export declare const byNumberDescending: (valueA: any, valueB: any) => number;
@@ -0,0 +1,22 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.byNumberDescending = void 0;
4
+ /**
5
+ * Take two values, ensure they are numbers and return the sorting value.
6
+ */
7
+ const byNumberDescending = (valueA, valueB) => {
8
+ const a = Number(valueA);
9
+ const b = Number(valueB);
10
+ // Handle NaN cases
11
+ if (isNaN(a) && isNaN(b)) {
12
+ return 0;
13
+ }
14
+ if (isNaN(a)) {
15
+ return 1;
16
+ }
17
+ if (isNaN(b)) {
18
+ return -1;
19
+ }
20
+ return b - a;
21
+ };
22
+ exports.byNumberDescending = byNumberDescending;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take two values, clean the strings and return the sorting value.
3
+ */
4
+ export declare const byStringAscending: (valueA: any, valueB: any) => string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.byStringAscending = void 0;
4
+ /**
5
+ * Take two values, clean the strings and return the sorting value.
6
+ */
7
+ const byStringAscending = (valueA, valueB) => {
8
+ const valueAClean = valueA.toString()
9
+ .trim()
10
+ .toLowerCase();
11
+ const valueBClean = valueB.toString()
12
+ .trim()
13
+ .toLowerCase();
14
+ return valueAClean.localeCompare(valueBClean);
15
+ };
16
+ exports.byStringAscending = byStringAscending;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take two values, clean the strings and return the sorting value.
3
+ */
4
+ export declare const byStringDescending: (valueA: any, valueB: any) => string;
@@ -0,0 +1,16 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.byStringDescending = void 0;
4
+ /**
5
+ * Take two values, clean the strings and return the sorting value.
6
+ */
7
+ const byStringDescending = (valueA, valueB) => {
8
+ const valueAClean = valueA.toString()
9
+ .trim()
10
+ .toLowerCase();
11
+ const valueBClean = valueB.toString()
12
+ .trim()
13
+ .toLowerCase();
14
+ return valueBClean.localeCompare(valueAClean);
15
+ };
16
+ exports.byStringDescending = byStringDescending;
@@ -0,0 +1,4 @@
1
+ export { byNumberAscending } from "./byNumberAscending";
2
+ export { byNumberDescending } from "./byNumberDescending";
3
+ export { byStringAscending } from "./byStringAscending";
4
+ export { byStringDescending } from "./byStringDescending";
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.byStringDescending = exports.byStringAscending = exports.byNumberDescending = exports.byNumberAscending = void 0;
4
+ var byNumberAscending_1 = require("./byNumberAscending");
5
+ Object.defineProperty(exports, "byNumberAscending", { enumerable: true, get: function () { return byNumberAscending_1.byNumberAscending; } });
6
+ var byNumberDescending_1 = require("./byNumberDescending");
7
+ Object.defineProperty(exports, "byNumberDescending", { enumerable: true, get: function () { return byNumberDescending_1.byNumberDescending; } });
8
+ var byStringAscending_1 = require("./byStringAscending");
9
+ Object.defineProperty(exports, "byStringAscending", { enumerable: true, get: function () { return byStringAscending_1.byStringAscending; } });
10
+ var byStringDescending_1 = require("./byStringDescending");
11
+ Object.defineProperty(exports, "byStringDescending", { enumerable: true, get: function () { return byStringDescending_1.byStringDescending; } });
@@ -0,0 +1 @@
1
+ export { sort } from "./sort";
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sort = void 0;
4
+ var sort_1 = require("./sort");
5
+ Object.defineProperty(exports, "sort", { enumerable: true, get: function () { return sort_1.sort; } });
@@ -0,0 +1,13 @@
1
+ declare const Transform: any;
2
+ /**
3
+ * Batch sort stream without overloading the memory limit.
4
+ * https://www.npmjs.com/package/fast-stream-sort
5
+ */
6
+ declare class SortStreamer extends Transform {
7
+ constructor(options: any, comp: any);
8
+ _transform(data: any, _: any, callback: any): void;
9
+ _flush(): void;
10
+ fullflush(): void;
11
+ }
12
+ export declare const sort: (comp: any, options: any) => SortStreamer;
13
+ export {};
package/stream/sort.js ADDED
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.sort = void 0;
4
+ const Transform = require("stream").Transform;
5
+ const batch = 15000;
6
+ /**
7
+ * Batch sort stream without overloading the memory limit.
8
+ * https://www.npmjs.com/package/fast-stream-sort
9
+ */
10
+ class SortStreamer extends Transform {
11
+ constructor(options, comp) {
12
+ super(options);
13
+ this.a = new Array(batch);
14
+ this.i = 0;
15
+ this.k = 0;
16
+ this.currentSize = batch;
17
+ this.isDone = false;
18
+ this.sortedArray = undefined;
19
+ this.comp = comp;
20
+ }
21
+ _transform(data, _, callback) {
22
+ if (data) {
23
+ this.a[this.i++] = data;
24
+ if (this.i == this.currentSize) {
25
+ this.currentSize = this.currentSize * 2;
26
+ var tmp = new Array(this.currentSize);
27
+ for (var j = 0; j < this.i; j++) {
28
+ tmp[j] = this.a[j];
29
+ }
30
+ this.a = tmp;
31
+ }
32
+ }
33
+ callback();
34
+ }
35
+ _flush() {
36
+ this.sortedArray = this.a.slice(0, this.i)
37
+ .sort(this.comp);
38
+ this.fullflush();
39
+ }
40
+ fullflush() {
41
+ while (this.k < this.i) {
42
+ this.push(this.sortedArray[this.k++]);
43
+ }
44
+ this.push(null);
45
+ }
46
+ }
47
+ const sort = (comp, options) => {
48
+ options = options || { objectMode: true };
49
+ return new SortStreamer(options, comp);
50
+ };
51
+ exports.sort = sort;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Convert a string into Capitalised Text.
3
+ * https://stackoverflow.com/a/196991/2664955
4
+ */
5
+ export declare const getCapitalised: (input: string, split?: string) => string;
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getCapitalised = void 0;
4
+ /**
5
+ * Convert a string into Capitalised Text.
6
+ * https://stackoverflow.com/a/196991/2664955
7
+ */
8
+ const getCapitalised = (input, split = "_") => {
9
+ const regex = new RegExp(split || "_", "g");
10
+ return input
11
+ .replace(regex, " ")
12
+ .replace(/\w\S*/g, function (txt) {
13
+ return txt.charAt(0)
14
+ .toUpperCase() + txt.substr(1)
15
+ .toLowerCase();
16
+ });
17
+ };
18
+ exports.getCapitalised = getCapitalised;
@@ -0,0 +1,18 @@
1
+ type GetCleanProps = {
2
+ accents?: boolean;
3
+ decoded?: boolean;
4
+ htmlTags?: boolean;
5
+ input: any;
6
+ lowercase?: boolean;
7
+ propercase?: boolean;
8
+ punctuation?: boolean;
9
+ trim?: boolean;
10
+ underscores?: boolean;
11
+ uppercase?: boolean;
12
+ whitespace?: boolean;
13
+ };
14
+ /**
15
+ * Shorthand function to get a clean version of a string.
16
+ */
17
+ export declare const getClean: (props: GetCleanProps) => string;
18
+ export {};
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getClean = void 0;
4
+ const getString_1 = require("./getString");
5
+ const getWithoutHtmlTags_1 = require("./getWithoutHtmlTags");
6
+ const getWithoutAccents_1 = require("./getWithoutAccents");
7
+ const getProperCase_1 = require("./getProperCase");
8
+ const getWithoutWhitespaces_1 = require("./getWithoutWhitespaces");
9
+ const getWithoutPunctuation_1 = require("./getWithoutPunctuation");
10
+ const getWithoutUnderscores_1 = require("./getWithoutUnderscores");
11
+ const getUnescaped_1 = require("./getUnescaped");
12
+ /**
13
+ * Shorthand function to get a clean version of a string.
14
+ */
15
+ const getClean = (props) => {
16
+ let response = (0, getString_1.getString)(props.input);
17
+ if (props.decoded) {
18
+ response = (0, getUnescaped_1.getUnescaped)(response);
19
+ }
20
+ if (props.accents) {
21
+ response = (0, getWithoutAccents_1.getWithoutAccents)(response);
22
+ }
23
+ if (props.htmlTags) {
24
+ response = (0, getWithoutHtmlTags_1.getWithoutHtmlTags)(response);
25
+ }
26
+ if (props.underscores) {
27
+ response = (0, getWithoutUnderscores_1.getWithoutUnderscores)(response);
28
+ }
29
+ if (props.punctuation) {
30
+ response = (0, getWithoutPunctuation_1.getWithoutPunctuation)(response);
31
+ }
32
+ if (props.whitespace) {
33
+ response = (0, getWithoutWhitespaces_1.getWithoutWhitespaces)(response);
34
+ }
35
+ if (props.lowercase) {
36
+ response = response.toLowerCase();
37
+ }
38
+ if (props.propercase) {
39
+ response = (0, getProperCase_1.getProperCase)({
40
+ input: response,
41
+ });
42
+ }
43
+ if (props.uppercase) {
44
+ response = response.toUpperCase();
45
+ }
46
+ if (props.trim) {
47
+ response = response.trim();
48
+ }
49
+ return response;
50
+ };
51
+ exports.getClean = getClean;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Take an input that may have a / before or after the input and return just the folder.
3
+ */
4
+ export declare const getFolder: (input: string) => string;
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getFolder = void 0;
7
+ const trim_1 = __importDefault(require("lodash/trim"));
8
+ /**
9
+ * Take an input that may have a / before or after the input and return just the folder.
10
+ */
11
+ const getFolder = (input) => {
12
+ return (0, trim_1.default)(input, "/")
13
+ .trim();
14
+ };
15
+ exports.getFolder = getFolder;
@@ -0,0 +1,11 @@
1
+ type GetProperCaseProps = {
2
+ input: string;
3
+ hyphen?: boolean;
4
+ pipe?: boolean;
5
+ underscore?: boolean;
6
+ };
7
+ /**
8
+ * Return a string "With Proper Casing".
9
+ */
10
+ export declare const getProperCase: (props: GetProperCaseProps) => string;
11
+ export {};
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getProperCase = void 0;
4
+ /**
5
+ * Return a string "With Proper Casing".
6
+ */
7
+ const getProperCase = (props) => {
8
+ let response = props.input;
9
+ if (props?.hyphen) {
10
+ response = response.split(/-/g)
11
+ .join(" ");
12
+ }
13
+ if (props?.pipe) {
14
+ response = response.split(/\|/g)
15
+ .join(" ");
16
+ }
17
+ if (props?.underscore) {
18
+ response = response.split(/_/g)
19
+ .join(" ");
20
+ }
21
+ return response.replace(/\w\S*/g, word => word.charAt(0)
22
+ .toUpperCase() + word.substr(1)
23
+ .toLowerCase());
24
+ };
25
+ exports.getProperCase = getProperCase;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Convert into string.
3
+ */
4
+ export declare const getString: (input: any) => string;
@@ -0,0 +1,34 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getString = void 0;
7
+ const isArray_1 = __importDefault(require("lodash/isArray"));
8
+ const isDate_1 = __importDefault(require("lodash/isDate"));
9
+ const isObject_1 = __importDefault(require("lodash/isObject"));
10
+ const date_1 = require("../date");
11
+ /**
12
+ * Convert into string.
13
+ */
14
+ const getString = (input) => {
15
+ let string = "";
16
+ // Already a string
17
+ if ("string" === typeof input) {
18
+ string = input;
19
+ }
20
+ // Convert a number into a date
21
+ else if ("number" === typeof input) {
22
+ string = input.toString();
23
+ }
24
+ // Object or array to JSON
25
+ else if ((0, isObject_1.default)(input) || (0, isArray_1.default)(input)) {
26
+ string = JSON.stringify(input);
27
+ }
28
+ // Date
29
+ else if ((0, isDate_1.default)(input)) {
30
+ string = (0, date_1.getYmdString)(input);
31
+ }
32
+ return string;
33
+ };
34
+ exports.getString = getString;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Converts a stream into a string.
3
+ * https://stackoverflow.com/a/49428486
4
+ */
5
+ export declare const getStringFromStream: (stream: any) => Promise<string>;
@@ -0,0 +1,17 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getStringFromStream = void 0;
4
+ /**
5
+ * Converts a stream into a string.
6
+ * https://stackoverflow.com/a/49428486
7
+ */
8
+ const getStringFromStream = (stream) => {
9
+ const chunks = [];
10
+ return new Promise((resolve, reject) => {
11
+ stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
12
+ stream.on("error", (err) => reject(err));
13
+ stream.on("end", () => resolve(Buffer.concat(chunks)
14
+ .toString("utf8")));
15
+ });
16
+ };
17
+ exports.getStringFromStream = getStringFromStream;
@@ -0,0 +1,6 @@
1
+ /**
2
+ * Convert escaped copy into unescaped.
3
+ * E.g. there&#39;s => there's
4
+ * https://stackoverflow.com/a/42182294/2664955
5
+ */
6
+ export declare const getUnescaped: (input: string) => string;
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.getUnescaped = void 0;
7
+ const unescape_1 = __importDefault(require("lodash/unescape"));
8
+ /**
9
+ * Convert escaped copy into unescaped.
10
+ * E.g. there&#39;s => there's
11
+ * https://stackoverflow.com/a/42182294/2664955
12
+ */
13
+ const getUnescaped = (input) => {
14
+ let response = input;
15
+ // Only works if DOM exists
16
+ if ("undefined" !== typeof document) {
17
+ let el = document.createElement("textarea");
18
+ el.innerHTML = response;
19
+ response = el.value;
20
+ }
21
+ else {
22
+ response = (0, unescape_1.default)(response);
23
+ }
24
+ return response;
25
+ };
26
+ exports.getUnescaped = getUnescaped;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Remove the accents from a string.
3
+ * https://stackoverflow.com/a/37511463
4
+ */
5
+ export declare const getWithoutAccents: (input: string) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWithoutAccents = void 0;
4
+ /**
5
+ * Remove the accents from a string.
6
+ * https://stackoverflow.com/a/37511463
7
+ */
8
+ const getWithoutAccents = (input) => {
9
+ return input
10
+ .normalize("NFD")
11
+ .replace(/[\u0300-\u036f]/g, "");
12
+ };
13
+ exports.getWithoutAccents = getWithoutAccents;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Removes all HTML tags from an input.
3
+ * https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
4
+ */
5
+ export declare const getWithoutHtmlTags: (input: string) => string;
@@ -0,0 +1,12 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWithoutHtmlTags = void 0;
4
+ /**
5
+ * Removes all HTML tags from an input.
6
+ * https://css-tricks.com/snippets/javascript/strip-html-tags-in-javascript/
7
+ */
8
+ const getWithoutHtmlTags = (input) => {
9
+ return input
10
+ .replace(/(<([^>]+)>)/gi, "");
11
+ };
12
+ exports.getWithoutHtmlTags = getWithoutHtmlTags;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Remove all punctuation from a string and replace with a space.
3
+ * https://stackoverflow.com/a/25575009
4
+ */
5
+ export declare const getWithoutPunctuation: (input: string) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWithoutPunctuation = void 0;
4
+ /**
5
+ * Remove all punctuation from a string and replace with a space.
6
+ * https://stackoverflow.com/a/25575009
7
+ */
8
+ const getWithoutPunctuation = (input) => {
9
+ return input
10
+ .replace(/[\u2000-\u206F\u2E00-\u2E7F\\'!"#$%&()*+,\-.\/:;<=>?@\[\]^_`{|}~]/g, "")
11
+ .replace(/\s+/g, " ");
12
+ };
13
+ exports.getWithoutPunctuation = getWithoutPunctuation;
@@ -0,0 +1,4 @@
1
+ /**
2
+ * Replace all underscores with a space.
3
+ */
4
+ export declare const getWithoutUnderscores: (input: string) => string;
@@ -0,0 +1,11 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWithoutUnderscores = void 0;
4
+ /**
5
+ * Replace all underscores with a space.
6
+ */
7
+ const getWithoutUnderscores = (input) => {
8
+ return input
9
+ .replace("_", " ");
10
+ };
11
+ exports.getWithoutUnderscores = getWithoutUnderscores;
@@ -0,0 +1,5 @@
1
+ /**
2
+ * Remove all new lines, tabs multiple spaces, with a single space.
3
+ * https://stackoverflow.com/a/45029224
4
+ */
5
+ export declare const getWithoutWhitespaces: (input: string) => string;
@@ -0,0 +1,13 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWithoutWhitespaces = void 0;
4
+ /**
5
+ * Remove all new lines, tabs multiple spaces, with a single space.
6
+ * https://stackoverflow.com/a/45029224
7
+ */
8
+ const getWithoutWhitespaces = (input) => {
9
+ return input
10
+ .replace(/\s+/g, " ")
11
+ .trim();
12
+ };
13
+ exports.getWithoutWhitespaces = getWithoutWhitespaces;
@@ -0,0 +1,12 @@
1
+ export { getCapitalised } from "./getCapitalised";
2
+ export { getClean } from "./getClean";
3
+ export { getFolder } from "./getFolder";
4
+ export { getProperCase } from "./getProperCase";
5
+ export { getString } from "./getString";
6
+ export { getStringFromStream } from "./getStringFromStream";
7
+ export { getUnescaped } from "./getUnescaped";
8
+ export { getWithoutAccents } from "./getWithoutAccents";
9
+ export { getWithoutHtmlTags } from "./getWithoutHtmlTags";
10
+ export { getWithoutPunctuation } from "./getWithoutPunctuation";
11
+ export { getWithoutUnderscores } from "./getWithoutUnderscores";
12
+ export { getWithoutWhitespaces } from "./getWithoutWhitespaces";
@@ -0,0 +1,27 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.getWithoutWhitespaces = exports.getWithoutUnderscores = exports.getWithoutPunctuation = exports.getWithoutHtmlTags = exports.getWithoutAccents = exports.getUnescaped = exports.getStringFromStream = exports.getString = exports.getProperCase = exports.getFolder = exports.getClean = exports.getCapitalised = void 0;
4
+ var getCapitalised_1 = require("./getCapitalised");
5
+ Object.defineProperty(exports, "getCapitalised", { enumerable: true, get: function () { return getCapitalised_1.getCapitalised; } });
6
+ var getClean_1 = require("./getClean");
7
+ Object.defineProperty(exports, "getClean", { enumerable: true, get: function () { return getClean_1.getClean; } });
8
+ var getFolder_1 = require("./getFolder");
9
+ Object.defineProperty(exports, "getFolder", { enumerable: true, get: function () { return getFolder_1.getFolder; } });
10
+ var getProperCase_1 = require("./getProperCase");
11
+ Object.defineProperty(exports, "getProperCase", { enumerable: true, get: function () { return getProperCase_1.getProperCase; } });
12
+ var getString_1 = require("./getString");
13
+ Object.defineProperty(exports, "getString", { enumerable: true, get: function () { return getString_1.getString; } });
14
+ var getStringFromStream_1 = require("./getStringFromStream");
15
+ Object.defineProperty(exports, "getStringFromStream", { enumerable: true, get: function () { return getStringFromStream_1.getStringFromStream; } });
16
+ var getUnescaped_1 = require("./getUnescaped");
17
+ Object.defineProperty(exports, "getUnescaped", { enumerable: true, get: function () { return getUnescaped_1.getUnescaped; } });
18
+ var getWithoutAccents_1 = require("./getWithoutAccents");
19
+ Object.defineProperty(exports, "getWithoutAccents", { enumerable: true, get: function () { return getWithoutAccents_1.getWithoutAccents; } });
20
+ var getWithoutHtmlTags_1 = require("./getWithoutHtmlTags");
21
+ Object.defineProperty(exports, "getWithoutHtmlTags", { enumerable: true, get: function () { return getWithoutHtmlTags_1.getWithoutHtmlTags; } });
22
+ var getWithoutPunctuation_1 = require("./getWithoutPunctuation");
23
+ Object.defineProperty(exports, "getWithoutPunctuation", { enumerable: true, get: function () { return getWithoutPunctuation_1.getWithoutPunctuation; } });
24
+ var getWithoutUnderscores_1 = require("./getWithoutUnderscores");
25
+ Object.defineProperty(exports, "getWithoutUnderscores", { enumerable: true, get: function () { return getWithoutUnderscores_1.getWithoutUnderscores; } });
26
+ var getWithoutWhitespaces_1 = require("./getWithoutWhitespaces");
27
+ Object.defineProperty(exports, "getWithoutWhitespaces", { enumerable: true, get: function () { return getWithoutWhitespaces_1.getWithoutWhitespaces; } });