@8ms/helpers 2.1.4 → 2.2.10

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 (186) hide show
  1. package/.github/workflows/deploy_npmjs.yml +19 -14
  2. package/_class/BaseClass.js +43 -52
  3. package/_class/BaseNamespace.js +17 -20
  4. package/_class/index.js +2 -7
  5. package/adverity/getJobs.js +7 -11
  6. package/adverity/index.js +51 -54
  7. package/adverity/server.js +1 -5
  8. package/api/ApiResponseClass.js +84 -88
  9. package/api/functions.js +13 -22
  10. package/api/index.js +3 -19
  11. package/api/types.js +5 -9
  12. package/array/index.js +3 -11
  13. package/atInternet/index.js +10 -13
  14. package/aws/ec2/AwsEc2Namespace.js +34 -74
  15. package/aws/ec2/server.js +5 -9
  16. package/aws/ecs/AwsEcsNamespace.js +110 -150
  17. package/aws/ecs/server.js +5 -9
  18. package/aws/glue/AwsGlueNamespace.js +26 -66
  19. package/aws/glue/server.js +5 -9
  20. package/aws/isResponse200.js +3 -7
  21. package/aws/lambda/AwsLambdaNamespace.js +62 -102
  22. package/aws/lambda/server.js +6 -11
  23. package/aws/s3/AwsS3Namespace.js +347 -390
  24. package/aws/s3/payload.js +29 -32
  25. package/aws/s3/server.js +9 -14
  26. package/aws/server.js +5 -10
  27. package/aws/ses/AwsSesNamespace.js +36 -76
  28. package/aws/ses/SimpleEmail.js +267 -304
  29. package/aws/ses/server.js +6 -11
  30. package/aws/sqs/AwsSqsNamespace.js +49 -89
  31. package/aws/sqs/server.js +5 -9
  32. package/aws/ssm/AwsSsmNamespace.js +43 -79
  33. package/aws/ssm/server.js +5 -9
  34. package/axios/deleteRequest.js +8 -15
  35. package/axios/get.js +8 -15
  36. package/axios/index.js +3 -9
  37. package/axios/post.js +8 -15
  38. package/boolean/index.js +3 -10
  39. package/brightData/serpApi/buildGoogleSerpUrl.js +1 -5
  40. package/brightData/serpApi/buildGoogleTrendsUrl.js +1 -5
  41. package/brightData/serpApi/getAsyncRequestId.js +8 -12
  42. package/brightData/serpApi/getAsyncResults.js +8 -12
  43. package/brightData/serpApi/getRealtime.js +3 -7
  44. package/brightData/serpApi/server.js +6 -14
  45. package/brightData/server.js +2 -7
  46. package/brightData/webScraperIde/getBatch.js +3 -7
  47. package/brightData/webScraperIde/getRealtime.js +11 -15
  48. package/brightData/webScraperIde/server.js +2 -7
  49. package/cache/server.js +2 -7
  50. package/cache/test/cache.test.js +4 -6
  51. package/crud/index.js +1 -4
  52. package/crypto/getDecrypt.js +2 -39
  53. package/crypto/getEncrypt.js +2 -39
  54. package/crypto/getRandom.js +1 -5
  55. package/crypto/getSha256.js +4 -41
  56. package/crypto/index.js +4 -11
  57. package/date/calculation.js +70 -99
  58. package/date/financialYear.js +16 -23
  59. package/date/format.js +40 -61
  60. package/date/index.js +4 -20
  61. package/date/type.js +4 -7
  62. package/environment/index.js +15 -25
  63. package/eskimi/getAgeGroup.js +3 -7
  64. package/eskimi/getData.js +3 -7
  65. package/eskimi/getDevice.js +3 -7
  66. package/eskimi/getGender.js +3 -7
  67. package/eskimi/server.js +23 -26
  68. package/file/index.js +8 -46
  69. package/geo/countries.js +1 -4
  70. package/geo/index.js +2 -7
  71. package/geo/languages.js +1 -4
  72. package/google/bigQuery/GoogleBigQueryNamespace.js +108 -148
  73. package/google/bigQuery/loadData.js +1 -5
  74. package/google/bigQuery/server.js +8 -14
  75. package/google/server.js +1 -5
  76. package/google/sheets/GoogleSheetsNamespace.js +34 -74
  77. package/google/sheets/getAssociatedData.js +1 -5
  78. package/google/sheets/server.js +8 -14
  79. package/google/storage/GoogleCloudStorageNamespace.js +62 -102
  80. package/google/storage/server.js +6 -10
  81. package/googleAds/GoogleAdsNamespace.js +28 -68
  82. package/googleAds/keywordPlanner/server.js +32 -35
  83. package/googleAds/server.js +6 -10
  84. package/googlePageSpeed/GooglePageSpeedNamespace.js +21 -28
  85. package/googlePageSpeed/server.js +8 -12
  86. package/googleSearchIncidents/server.js +28 -32
  87. package/greenDomain/server.js +17 -21
  88. package/inngest/server.js +1 -4
  89. package/json/getJsonNewline.js +3 -7
  90. package/json/index.js +2 -7
  91. package/json/isJson.js +1 -5
  92. package/littleWarden/LittleWardenNamespace.js +24 -31
  93. package/littleWarden/getUrlStatus.js +3 -7
  94. package/littleWarden/server.js +14 -22
  95. package/lumar/api/buildRequest.js +14 -18
  96. package/lumar/api/getData.js +3 -7
  97. package/lumar/api/initClient.js +3 -7
  98. package/lumar/api/server.js +6 -12
  99. package/lumar/graphql/columns.js +1 -4
  100. package/lumar/graphql/getData.js +3 -7
  101. package/lumar/graphql/initClient.js +3 -7
  102. package/lumar/graphql/queries/crawl.js +1 -2
  103. package/lumar/graphql/queries/getCrawls.js +1 -3
  104. package/lumar/graphql/queries/getReportDifferences.js +3 -5
  105. package/lumar/graphql/queries/getRows.js +1 -3
  106. package/lumar/graphql/queries/getTotals.js +1 -3
  107. package/lumar/graphql/queries/row.js +1 -2
  108. package/lumar/graphql/reportTemplates.js +1 -4
  109. package/lumar/graphql/server.js +7 -15
  110. package/myTarget/server.js +3 -7
  111. package/nextAuth/index.js +2 -6
  112. package/nextAuth/isSessionReady.js +1 -5
  113. package/nextJs/client/LazyLoad.js +5 -12
  114. package/nextJs/client.js +1 -5
  115. package/nextJs/index.js +2 -7
  116. package/number/format.js +3 -7
  117. package/number/formatCurrency.js +1 -5
  118. package/number/getDecimal.js +3 -7
  119. package/number/getNumber.js +3 -7
  120. package/number/getPercentIncrease.js +4 -8
  121. package/number/getSafeDivide.js +6 -10
  122. package/number/index.js +6 -15
  123. package/object/index.js +1 -5
  124. package/object/replaceKeys.js +3 -7
  125. package/onePassword/OnePasswordNamespace.js +36 -76
  126. package/onePassword/server.js +3 -7
  127. package/openAi/OpenAiNamespace.js +32 -39
  128. package/openAi/server.js +6 -10
  129. package/package.json +136 -120
  130. package/prisma/PrismaNamespace.d.ts +3 -3
  131. package/prisma/PrismaNamespace.js +55 -81
  132. package/prisma/getDecimal.js +5 -12
  133. package/prisma/server.d.ts +13 -0
  134. package/prisma/server.js +6 -9
  135. package/snapchat/SnapchatNamespace.js +20 -27
  136. package/snapchat/server.js +6 -10
  137. package/sorting/byNumberAscending.js +1 -5
  138. package/sorting/byNumberDescending.js +1 -5
  139. package/sorting/byStringAscending.js +1 -5
  140. package/sorting/byStringDescending.js +1 -5
  141. package/sorting/index.js +4 -11
  142. package/stream/server.js +1 -5
  143. package/stream/sort.js +1 -5
  144. package/string/getCapitalised.js +3 -7
  145. package/string/getClean.js +17 -21
  146. package/string/getFolder.js +3 -10
  147. package/string/getProperCase.js +4 -8
  148. package/string/getString.js +8 -15
  149. package/string/getStringFromStream.js +1 -5
  150. package/string/getUnescaped.js +3 -10
  151. package/string/getWithoutAccents.js +1 -5
  152. package/string/getWithoutHtmlTags.js +1 -5
  153. package/string/getWithoutPunctuation.js +1 -5
  154. package/string/getWithoutUnderscores.js +1 -5
  155. package/string/getWithoutWhitespaces.js +1 -5
  156. package/string/index.js +12 -27
  157. package/string/reservedWords.js +5 -9
  158. package/swr/index.js +9 -18
  159. package/upTimeRobot/UpTimeRobotNamespace.js +32 -42
  160. package/upTimeRobot/server.js +11 -15
  161. package/url/index.js +12 -23
  162. package/url/server.js +1 -5
  163. package/url/writeUrlContents.js +6 -46
  164. package/util/defaultTo.js +5 -12
  165. package/util/getBrotliCompressed.js +3 -10
  166. package/util/getBrotliDecompressed.js +3 -10
  167. package/util/getClean.js +5 -9
  168. package/util/getError.js +1 -5
  169. package/util/getGzipCompressed.js +3 -10
  170. package/util/getGzipDecompressed.js +3 -10
  171. package/util/getWithoutHash.js +1 -5
  172. package/util/getWithoutParameter.js +1 -5
  173. package/util/index.js +7 -17
  174. package/util/isUndefined.js +3 -7
  175. package/util/promiseChunks.js +6 -10
  176. package/util/server.js +4 -11
  177. package/util/sleep.js +1 -5
  178. package/webWorker/index.js +1 -4
  179. package/xml/getXml.js +3 -7
  180. package/.yarn/install-state.gz +0 -0
  181. package/.yarn/releases/yarn-4.9.4.cjs +0 -942
  182. package/.yarnrc.yml +0 -3
  183. package/aws/athenaExpress/AwsAthenaNamespace.d.ts +0 -8
  184. package/aws/athenaExpress/AwsAthenaNamespace.js +0 -82
  185. package/aws/athenaExpress/server.d.ts +0 -10
  186. package/aws/athenaExpress/server.js +0 -40
@@ -1,88 +1,62 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14
- Object.defineProperty(o, "default", { enumerable: true, value: v });
15
- }) : function(o, v) {
16
- o["default"] = v;
17
- });
18
- var __importStar = (this && this.__importStar) || (function () {
19
- var ownKeys = function(o) {
20
- ownKeys = Object.getOwnPropertyNames || function (o) {
21
- var ar = [];
22
- for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
23
- return ar;
24
- };
25
- return ownKeys(o);
26
- };
27
- return function (mod) {
28
- if (mod && mod.__esModule) return mod;
29
- var result = {};
30
- if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
31
- __setModuleDefault(result, mod);
32
- return result;
33
- };
34
- })();
35
- Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.PrismaNamespace = void 0;
37
- const _class_1 = require("../_class");
38
- const getError_1 = require("../util/getError");
39
- class PrismaNamespace extends _class_1.BaseNamespace {
40
- constructor() {
41
- super(...arguments);
42
- // Async setup to only initialise where required
43
- this.ensureInit = async () => {
44
- if (!this.client) {
45
- let planetScaleAdapter = null;
46
- if (this.config.isPlanetScale) {
47
- try {
48
- const { PrismaPlanetScale } = await Promise.resolve().then(() => __importStar(require("@prisma/adapter-planetscale")));
49
- planetScaleAdapter = new PrismaPlanetScale({
50
- url: this.config.url,
51
- });
52
- }
53
- catch (e) {
54
- throw new Error(`PlanetScale Client not installed - ${(0, getError_1.getError)(e)}`);
55
- }
1
+ import { BaseNamespace } from "../_class";
2
+ import { getError } from "../util/getError";
3
+ export class PrismaNamespace extends BaseNamespace {
4
+ // Async setup to only initialise where required
5
+ ensureInit = async () => {
6
+ if (!this.client) {
7
+ let adapter = null;
8
+ if (this.config.isPlanetScale) {
9
+ try {
10
+ const { PrismaPlanetScale } = await import("@prisma/adapter-planetscale");
11
+ adapter = new PrismaPlanetScale({
12
+ url: this.config.url,
13
+ });
14
+ }
15
+ catch (e) {
16
+ throw new Error(`PlanetScale adapter not installed - ${getError(e)}`);
17
+ }
18
+ }
19
+ if (this.config.isMysql) {
20
+ try {
21
+ const { PrismaMariaDb } = await import("@prisma/adapter-mariadb");
22
+ adapter = new PrismaMariaDb(this.config.url);
56
23
  }
24
+ catch (e) {
25
+ throw new Error(`MariaDB adapter not installed - ${getError(e)}`);
26
+ }
27
+ }
28
+ else {
29
+ // Prisma v7 requires a driver adapter — use the one matching your database
30
+ // e.g. @prisma/adapter-pg for Postgres, @prisma/adapter-mysql2 for MySQL
57
31
  try {
58
- const { PrismaClient } = await Promise.resolve().then(() => __importStar(require("@prisma/client")));
59
- // Show the full query if debugging
60
- if (this.config.isDebug) {
61
- this.client = new PrismaClient({
62
- adapter: planetScaleAdapter,
63
- datasourceUrl: planetScaleAdapter ? undefined : this.config.url,
64
- log: [
65
- {
66
- emit: "event",
67
- level: "query",
68
- },
69
- ],
70
- });
71
- }
72
- // Standard prisma
73
- else {
74
- this.client = new PrismaClient({
75
- adapter: planetScaleAdapter,
76
- datasourceUrl: planetScaleAdapter ? undefined : this.config.url,
77
- });
78
- }
32
+ const { PrismaPg } = await import("@prisma/adapter-pg");
33
+ adapter = new PrismaPg({
34
+ connectionString: process.env.DATABASE_URL,
35
+ });
79
36
  }
80
37
  catch (e) {
81
- throw new Error(`Prisma Client not installed - ${(0, getError_1.getError)(e)}`);
38
+ throw new Error(`Postgres adapter not installed - ${getError(e)}`);
39
+ }
40
+ }
41
+ try {
42
+ // In Prisma v7, the client is generated to a custom output path
43
+ // @ts-ignore
44
+ const { PrismaClient } = await import("../../generated/prisma/client");
45
+ // Show the full query if debugging
46
+ if (this.config.isDebug) {
47
+ this.client = new PrismaClient({
48
+ adapter,
49
+ log: [{ emit: "event", level: "query" }],
50
+ });
51
+ }
52
+ // Standard prisma
53
+ else {
54
+ this.client = new PrismaClient({ adapter });
82
55
  }
83
56
  }
84
- };
85
- }
57
+ catch (e) {
58
+ throw new Error(`Prisma Client not installed - ${getError(e)}`);
59
+ }
60
+ }
61
+ };
86
62
  }
87
- exports.PrismaNamespace = PrismaNamespace;
88
- ;
@@ -1,23 +1,16 @@
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.getDecimal = void 0;
7
- const getDecimal_1 = require("../number/getDecimal");
8
- const isArray_1 = __importDefault(require("lodash/isArray"));
1
+ import { getDecimal as getNumberDecimal } from "../number/getDecimal";
2
+ import isArray from "lodash/isArray";
9
3
  /**
10
4
  * Fetch the number from a prisma decimal (comes through as an object).
11
5
  */
12
- const getDecimal = (input, dp = 2) => {
6
+ export const getDecimal = (input, dp = 2) => {
13
7
  let numberString = "";
14
8
  // Prisma value
15
- if ((0, isArray_1.default)(input?.d)) {
9
+ if (isArray(input?.d)) {
16
10
  numberString = input.absoluteValue();
17
11
  }
18
12
  else {
19
13
  numberString = input.toString();
20
14
  }
21
- return (0, getDecimal_1.getDecimal)(numberString, dp);
15
+ return getNumberDecimal(numberString, dp);
22
16
  };
23
- exports.getDecimal = getDecimal;
@@ -3,6 +3,19 @@ export type PrismaConfig = {
3
3
  url: string;
4
4
  isDebug: boolean;
5
5
  isPlanetScale: boolean;
6
+ isMysql: boolean;
7
+ isPostgres: boolean;
6
8
  };
9
+ /**
10
+ * Minimal interface representing a Prisma Client instance.
11
+ * Consumers of this library will have their own generated PrismaClient
12
+ * that satisfies this interface.
13
+ */
14
+ export interface PrismaClientLike {
15
+ $connect(): Promise<void>;
16
+ $disconnect(): Promise<void>;
17
+ $transaction(...args: any[]): Promise<any>;
18
+ [key: string]: any;
19
+ }
7
20
  export declare const prismaClient: (key?: string, config?: PrismaConfig) => Promise<PrismaNamespace>;
8
21
  export { getDecimal } from "./getDecimal";
package/prisma/server.js CHANGED
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getDecimal = exports.prismaClient = void 0;
4
- const PrismaNamespace_1 = require("./PrismaNamespace");
1
+ import { PrismaNamespace } from "./PrismaNamespace";
5
2
  const prismaNamespaces = new Map();
6
3
  // Main client that is used by system
7
- const prismaClient = async (key = "default", config) => {
4
+ export const prismaClient = async (key = "default", config) => {
8
5
  if (prismaNamespaces.has(key)) {
9
6
  return prismaNamespaces.get(key);
10
7
  }
@@ -14,17 +11,17 @@ const prismaClient = async (key = "default", config) => {
14
11
  url: process.env.DATABASE_URL,
15
12
  isDebug: 'true' === process.env.DATABASE_IS_DEBUG,
16
13
  isPlanetScale: 'true' === process.env.DATABASE_IS_PLANETSCALE,
14
+ isMysql: 'true' === process.env.DATABASE_IS_MYSQL,
15
+ isPostgres: 'true' === process.env.DATABASE_IS_POSTGRES,
17
16
  };
18
17
  }
19
18
  else {
20
19
  throw new Error(`Config required for namespace '${key}'`);
21
20
  }
22
21
  }
23
- const namespace = new PrismaNamespace_1.PrismaNamespace(key, config);
22
+ const namespace = new PrismaNamespace(key, config);
24
23
  await namespace.ensureInit();
25
24
  prismaNamespaces.set(key, namespace);
26
25
  return namespace;
27
26
  };
28
- exports.prismaClient = prismaClient;
29
- var getDecimal_1 = require("./getDecimal");
30
- Object.defineProperty(exports, "getDecimal", { enumerable: true, get: function () { return getDecimal_1.getDecimal; } });
27
+ export { getDecimal } from "./getDecimal";
@@ -1,29 +1,22 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.SnapchatNamespace = void 0;
4
- const _class_1 = require("../_class");
5
- const axios_1 = require("../axios");
6
- const luxon_1 = require("luxon");
7
- class SnapchatNamespace extends _class_1.BaseNamespace {
8
- constructor() {
9
- super(...arguments);
10
- /**
11
- * Renew the access token as it expires every 3 hours.
12
- */
13
- this.ensureInit = async () => {
14
- if (!this.client) {
15
- // Build the token request for Snapchat
16
- const url = `https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`;
17
- const apiResponse = await (0, axios_1.post)(url);
18
- if (apiResponse.isSuccess()) {
19
- this.client = {
20
- expires: luxon_1.DateTime.now()
21
- .toUnixInteger() + (3 * 60 * 60 * 1000),
22
- refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
23
- };
24
- }
1
+ import { BaseNamespace } from "../_class";
2
+ import { post } from "../axios";
3
+ import { DateTime } from "luxon";
4
+ export class SnapchatNamespace extends BaseNamespace {
5
+ /**
6
+ * Renew the access token as it expires every 3 hours.
7
+ */
8
+ ensureInit = async () => {
9
+ if (!this.client) {
10
+ // Build the token request for Snapchat
11
+ const url = `https://accounts.snapchat.com/login/oauth2/access_token?client_id=${this.config.clientId}&client_secret=${this.config.clientSecret}&grant_type=refresh_token&refresh_token=${this.config.refreshToken}`;
12
+ const apiResponse = await post(url);
13
+ if (apiResponse.isSuccess()) {
14
+ this.client = {
15
+ expires: DateTime.now()
16
+ .toUnixInteger() + (3 * 60 * 60 * 1000),
17
+ refreshToken: apiResponse.getBodyDefaultTo(["data", "access_token"], null)
18
+ };
25
19
  }
26
- };
27
- }
20
+ }
21
+ };
28
22
  }
29
- exports.SnapchatNamespace = SnapchatNamespace;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.snapchatClient = void 0;
4
- const SnapchatNamespace_1 = require("./SnapchatNamespace");
5
- const server_1 = require("../onePassword/server");
1
+ import { SnapchatNamespace } from "./SnapchatNamespace";
2
+ import { onePasswordClient } from "../onePassword/server";
6
3
  const snapchatNamespaces = new Map();
7
- const snapchatClient = async (key = "default", config, vaultId, itemId) => {
4
+ export const snapchatClient = async (key = "default", config, vaultId, itemId) => {
8
5
  if (snapchatNamespaces.has(key)) {
9
6
  return snapchatNamespaces.get(key);
10
7
  }
@@ -13,18 +10,17 @@ const snapchatClient = async (key = "default", config, vaultId, itemId) => {
13
10
  instanceConfig = config;
14
11
  }
15
12
  else if (vaultId && itemId) {
16
- instanceConfig = await (await (0, server_1.onePasswordClient)())
13
+ instanceConfig = await (await onePasswordClient())
17
14
  .getJsonNote(vaultId, itemId);
18
15
  }
19
16
  else if (process.env.SNAPCHAT_VAULT_ID && process.env.SNAPCHAT_ITEM_ID) {
20
- instanceConfig = await (await (0, server_1.onePasswordClient)())
17
+ instanceConfig = await (await onePasswordClient())
21
18
  .getJsonNote(process.env.SNAPCHAT_VAULT_ID, process.env.SNAPCHAT_ITEM_ID);
22
19
  }
23
20
  else {
24
21
  throw new Error(`Config required for namespace '${key}'`);
25
22
  }
26
- const namespace = new SnapchatNamespace_1.SnapchatNamespace(key, instanceConfig);
23
+ const namespace = new SnapchatNamespace(key, instanceConfig);
27
24
  snapchatNamespaces.set(key, namespace);
28
25
  return namespace;
29
26
  };
30
- exports.snapchatClient = snapchatClient;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byNumberAscending = void 0;
4
1
  /**
5
2
  * Take two values, ensure they are numbers and return the sorting value.
6
3
  */
7
- const byNumberAscending = (valueA, valueB) => {
4
+ export const byNumberAscending = (valueA, valueB) => {
8
5
  const a = Number(valueA);
9
6
  const b = Number(valueB);
10
7
  // Handle NaN cases
@@ -16,4 +13,3 @@ const byNumberAscending = (valueA, valueB) => {
16
13
  return -1;
17
14
  return a - b;
18
15
  };
19
- exports.byNumberAscending = byNumberAscending;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byNumberDescending = void 0;
4
1
  /**
5
2
  * Take two values, ensure they are numbers and return the sorting value.
6
3
  */
7
- const byNumberDescending = (valueA, valueB) => {
4
+ export const byNumberDescending = (valueA, valueB) => {
8
5
  const a = Number(valueA);
9
6
  const b = Number(valueB);
10
7
  // Handle NaN cases
@@ -19,4 +16,3 @@ const byNumberDescending = (valueA, valueB) => {
19
16
  }
20
17
  return b - a;
21
18
  };
22
- exports.byNumberDescending = byNumberDescending;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byStringAscending = void 0;
4
1
  /**
5
2
  * Take two values, clean the strings and return the sorting value.
6
3
  */
7
- const byStringAscending = (valueA, valueB) => {
4
+ export const byStringAscending = (valueA, valueB) => {
8
5
  const valueAClean = valueA.toString()
9
6
  .trim()
10
7
  .toLowerCase();
@@ -13,4 +10,3 @@ const byStringAscending = (valueA, valueB) => {
13
10
  .toLowerCase();
14
11
  return valueAClean.localeCompare(valueBClean);
15
12
  };
16
- exports.byStringAscending = byStringAscending;
@@ -1,10 +1,7 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.byStringDescending = void 0;
4
1
  /**
5
2
  * Take two values, clean the strings and return the sorting value.
6
3
  */
7
- const byStringDescending = (valueA, valueB) => {
4
+ export const byStringDescending = (valueA, valueB) => {
8
5
  const valueAClean = valueA.toString()
9
6
  .trim()
10
7
  .toLowerCase();
@@ -13,4 +10,3 @@ const byStringDescending = (valueA, valueB) => {
13
10
  .toLowerCase();
14
11
  return valueBClean.localeCompare(valueAClean);
15
12
  };
16
- exports.byStringDescending = byStringDescending;
package/sorting/index.js CHANGED
@@ -1,11 +1,4 @@
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; } });
1
+ export { byNumberAscending } from "./byNumberAscending";
2
+ export { byNumberDescending } from "./byNumberDescending";
3
+ export { byStringAscending } from "./byStringAscending";
4
+ export { byStringDescending } from "./byStringDescending";
package/stream/server.js CHANGED
@@ -1,5 +1 @@
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; } });
1
+ export { sort } from "./sort";
package/stream/sort.js CHANGED
@@ -1,6 +1,3 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sort = void 0;
4
1
  const Transform = require("stream").Transform;
5
2
  const batch = 15000;
6
3
  /**
@@ -44,8 +41,7 @@ class SortStreamer extends Transform {
44
41
  this.push(null);
45
42
  }
46
43
  }
47
- const sort = (comp, options) => {
44
+ export const sort = (comp, options) => {
48
45
  options = options || { objectMode: true };
49
46
  return new SortStreamer(options, comp);
50
47
  };
51
- exports.sort = sort;
@@ -1,18 +1,15 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getCapitalised = void 0;
4
- const reservedWords_1 = require("./reservedWords");
1
+ import { isReservedWord } from "./reservedWords";
5
2
  /**
6
3
  * Convert a string into Capitalised Text.
7
4
  * https://stackoverflow.com/a/196991/2664955
8
5
  */
9
- const getCapitalised = (input, split = "_") => {
6
+ export const getCapitalised = (input, split = "_") => {
10
7
  const regex = new RegExp(split || "_", "g");
11
8
  return input
12
9
  .replace(regex, " ")
13
10
  .replace(/\w\S*/g, function (txt) {
14
11
  // Check if individual word is reserved
15
- const reservedWord = (0, reservedWords_1.isReservedWord)(txt);
12
+ const reservedWord = isReservedWord(txt);
16
13
  if (reservedWord) {
17
14
  return reservedWord;
18
15
  }
@@ -22,4 +19,3 @@ const getCapitalised = (input, split = "_") => {
22
19
  .toLowerCase();
23
20
  });
24
21
  };
25
- exports.getCapitalised = getCapitalised;
@@ -1,42 +1,39 @@
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");
1
+ import { getString } from "./getString";
2
+ import { getWithoutHtmlTags } from "./getWithoutHtmlTags";
3
+ import { getWithoutAccents } from "./getWithoutAccents";
4
+ import { getProperCase } from "./getProperCase";
5
+ import { getWithoutWhitespaces } from "./getWithoutWhitespaces";
6
+ import { getWithoutPunctuation } from "./getWithoutPunctuation";
7
+ import { getWithoutUnderscores } from "./getWithoutUnderscores";
8
+ import { getUnescaped } from "./getUnescaped";
12
9
  /**
13
10
  * Shorthand function to get a clean version of a string.
14
11
  */
15
- const getClean = (props) => {
16
- let response = (0, getString_1.getString)(props.input);
12
+ export const getClean = (props) => {
13
+ let response = getString(props.input);
17
14
  if (props.decoded) {
18
- response = (0, getUnescaped_1.getUnescaped)(response);
15
+ response = getUnescaped(response);
19
16
  }
20
17
  if (props.accents) {
21
- response = (0, getWithoutAccents_1.getWithoutAccents)(response);
18
+ response = getWithoutAccents(response);
22
19
  }
23
20
  if (props.htmlTags) {
24
- response = (0, getWithoutHtmlTags_1.getWithoutHtmlTags)(response);
21
+ response = getWithoutHtmlTags(response);
25
22
  }
26
23
  if (props.underscores) {
27
- response = (0, getWithoutUnderscores_1.getWithoutUnderscores)(response);
24
+ response = getWithoutUnderscores(response);
28
25
  }
29
26
  if (props.punctuation) {
30
- response = (0, getWithoutPunctuation_1.getWithoutPunctuation)(response);
27
+ response = getWithoutPunctuation(response);
31
28
  }
32
29
  if (props.whitespace) {
33
- response = (0, getWithoutWhitespaces_1.getWithoutWhitespaces)(response);
30
+ response = getWithoutWhitespaces(response);
34
31
  }
35
32
  if (props.lowercase) {
36
33
  response = response.toLowerCase();
37
34
  }
38
35
  if (props.propercase) {
39
- response = (0, getProperCase_1.getProperCase)({
36
+ response = getProperCase({
40
37
  input: response,
41
38
  });
42
39
  }
@@ -48,4 +45,3 @@ const getClean = (props) => {
48
45
  }
49
46
  return response;
50
47
  };
51
- exports.getClean = getClean;
@@ -1,15 +1,8 @@
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"));
1
+ import trim from "lodash/trim";
8
2
  /**
9
3
  * Take an input that may have a / before or after the input and return just the folder.
10
4
  */
11
- const getFolder = (input) => {
12
- return (0, trim_1.default)(input, "/")
5
+ export const getFolder = (input) => {
6
+ return trim(input, "/")
13
7
  .trim();
14
8
  };
15
- exports.getFolder = getFolder;
@@ -1,15 +1,12 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getProperCase = void 0;
4
- const reservedWords_1 = require("./reservedWords");
1
+ import { isReservedWord, reservedWords } from "./reservedWords";
5
2
  /**
6
3
  * Return a string "With Proper Casing".
7
4
  */
8
- const getProperCase = (props) => {
5
+ export const getProperCase = (props) => {
9
6
  const cleanInput = props.input.toString()
10
7
  .trim();
11
8
  // Don't process if the entire input is a reserved word
12
- if (reservedWords_1.reservedWords.includes(cleanInput.toUpperCase())) {
9
+ if (reservedWords.includes(cleanInput.toUpperCase())) {
13
10
  return cleanInput;
14
11
  }
15
12
  // Build the split pattern - always include spaces
@@ -33,7 +30,7 @@ const getProperCase = (props) => {
33
30
  .filter(word => word.length > 0) // Remove empty strings
34
31
  .map(word => {
35
32
  // Check if individual word is reserved
36
- const reservedWord = (0, reservedWords_1.isReservedWord)(word);
33
+ const reservedWord = isReservedWord(word);
37
34
  if (reservedWord) {
38
35
  return reservedWord;
39
36
  }
@@ -44,4 +41,3 @@ const getProperCase = (props) => {
44
41
  });
45
42
  return words.join(' ');
46
43
  };
47
- exports.getProperCase = getProperCase;
@@ -1,17 +1,11 @@
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");
1
+ import isArray from "lodash/isArray";
2
+ import isDate from "lodash/isDate";
3
+ import isObject from "lodash/isObject";
4
+ import { getYmdString } from "../date";
11
5
  /**
12
6
  * Convert into string.
13
7
  */
14
- const getString = (input) => {
8
+ export const getString = (input) => {
15
9
  let string = "";
16
10
  // Already a string
17
11
  if ("string" === typeof input) {
@@ -22,13 +16,12 @@ const getString = (input) => {
22
16
  string = input.toString();
23
17
  }
24
18
  // Object or array to JSON
25
- else if ((0, isObject_1.default)(input) || (0, isArray_1.default)(input)) {
19
+ else if (isObject(input) || isArray(input)) {
26
20
  string = JSON.stringify(input);
27
21
  }
28
22
  // Date
29
- else if ((0, isDate_1.default)(input)) {
30
- string = (0, date_1.getYmdString)(input);
23
+ else if (isDate(input)) {
24
+ string = getYmdString(input);
31
25
  }
32
26
  return string;
33
27
  };
34
- exports.getString = getString;
@@ -1,11 +1,8 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getStringFromStream = void 0;
4
1
  /**
5
2
  * Converts a stream into a string.
6
3
  * https://stackoverflow.com/a/49428486
7
4
  */
8
- const getStringFromStream = (stream) => {
5
+ export const getStringFromStream = (stream) => {
9
6
  const chunks = [];
10
7
  return new Promise((resolve, reject) => {
11
8
  stream.on("data", (chunk) => chunks.push(Buffer.from(chunk)));
@@ -14,4 +11,3 @@ const getStringFromStream = (stream) => {
14
11
  .toString("utf8")));
15
12
  });
16
13
  };
17
- exports.getStringFromStream = getStringFromStream;