@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.
- package/.github/workflows/deploy_npmjs.yml +7 -0
- package/.yarn/install-state.gz +0 -0
- package/_class/BaseClass.d.ts +18 -0
- package/_class/BaseClass.js +53 -0
- package/_class/BaseNamespace.d.ts +9 -0
- package/_class/BaseNamespace.js +27 -0
- package/_class/index.d.ts +2 -0
- package/_class/index.js +7 -0
- package/adverity/getJobs.d.ts +15 -0
- package/adverity/getJobs.js +30 -0
- package/adverity/index.d.ts +112 -0
- package/adverity/index.js +61 -0
- package/api/ApiResponseClass.d.ts +35 -0
- package/api/ApiResponseClass.js +97 -0
- package/api/index.d.ts +22 -0
- package/api/index.js +44 -0
- package/array/index.d.ts +8 -0
- package/array/index.js +17 -0
- package/atInternet/index.d.ts +16 -0
- package/atInternet/index.js +18 -0
- package/aws/athenaExpress/AwsAthenaNamespace.d.ts +8 -0
- package/aws/athenaExpress/AwsAthenaNamespace.js +82 -0
- package/aws/athenaExpress/index.d.ts +10 -0
- package/aws/athenaExpress/index.js +40 -0
- package/aws/ec2/AwsEc2Namespace.d.ts +10 -0
- package/aws/ec2/AwsEc2Namespace.js +78 -0
- package/aws/ec2/index.d.ts +3 -0
- package/aws/ec2/index.js +16 -0
- package/aws/ecs/AwsEcsNamespace.d.ts +53 -0
- package/aws/ecs/AwsEcsNamespace.js +159 -0
- package/aws/ecs/index.d.ts +3 -0
- package/aws/ecs/index.js +16 -0
- package/aws/glue/AwsGlueNamespace.d.ts +12 -0
- package/aws/glue/AwsGlueNamespace.js +70 -0
- package/aws/glue/index.d.ts +3 -0
- package/aws/glue/index.js +16 -0
- package/aws/index.d.ts +9 -0
- package/aws/index.js +34 -0
- package/aws/isResponse200.d.ts +4 -0
- package/aws/isResponse200.js +16 -0
- package/aws/lambda/AwsLambdaNamespace.d.ts +21 -0
- package/aws/lambda/AwsLambdaNamespace.js +110 -0
- package/aws/lambda/index.d.ts +4 -0
- package/aws/lambda/index.js +21 -0
- package/aws/s3/AwsS3Namespace.d.ts +60 -0
- package/aws/s3/AwsS3Namespace.js +401 -0
- package/aws/s3/index.d.ts +25 -0
- package/aws/s3/index.js +36 -0
- package/aws/s3/payload.d.ts +42 -0
- package/aws/s3/payload.js +46 -0
- package/aws/ses/AwsSesNamespace.d.ts +18 -0
- package/aws/ses/AwsSesNamespace.js +69 -0
- package/aws/ses/SimpleEmail.d.ts +56 -0
- package/aws/ses/SimpleEmail.js +106 -0
- package/aws/ses/index.d.ts +4 -0
- package/aws/ses/index.js +18 -0
- package/aws/sqs/AwsSqsNamespace.d.ts +34 -0
- package/aws/sqs/AwsSqsNamespace.js +96 -0
- package/aws/sqs/index.d.ts +3 -0
- package/aws/sqs/index.js +16 -0
- package/aws/ssm/AwsSsmNamespace.d.ts +11 -0
- package/aws/ssm/AwsSsmNamespace.js +89 -0
- package/aws/ssm/index.d.ts +3 -0
- package/aws/ssm/index.js +16 -0
- package/axios/deleteRequest.d.ts +6 -0
- package/axios/deleteRequest.js +33 -0
- package/axios/get.d.ts +5 -0
- package/axios/get.js +31 -0
- package/axios/index.d.ts +3 -0
- package/axios/index.js +9 -0
- package/axios/post.d.ts +5 -0
- package/axios/post.js +32 -0
- package/boolean/getBoolean.d.ts +4 -0
- package/boolean/getBoolean.js +23 -0
- package/boolean/index.d.ts +1 -0
- package/boolean/index.js +5 -0
- package/brightData/index.d.ts +15 -0
- package/brightData/index.js +20 -0
- package/brightData/serpApi/buildGoogleSerpUrl.d.ts +32 -0
- package/brightData/serpApi/buildGoogleSerpUrl.js +116 -0
- package/brightData/serpApi/buildGoogleTrendsUrl.d.ts +22 -0
- package/brightData/serpApi/buildGoogleTrendsUrl.js +61 -0
- package/brightData/serpApi/getAsyncRequestId.d.ts +8 -0
- package/brightData/serpApi/getAsyncRequestId.js +36 -0
- package/brightData/serpApi/getAsyncResults.d.ts +7 -0
- package/brightData/serpApi/getAsyncResults.js +35 -0
- package/brightData/serpApi/getRealtime.d.ts +5 -0
- package/brightData/serpApi/getRealtime.js +30 -0
- package/brightData/serpApi/index.d.ts +14 -0
- package/brightData/serpApi/index.js +23 -0
- package/brightData/webScraperIde/getBatch.d.ts +7 -0
- package/brightData/webScraperIde/getBatch.js +28 -0
- package/brightData/webScraperIde/getRealtime.d.ts +7 -0
- package/brightData/webScraperIde/getRealtime.js +49 -0
- package/brightData/webScraperIde/index.d.ts +2 -0
- package/brightData/webScraperIde/index.js +7 -0
- package/cache/index.d.ts +2 -0
- package/cache/index.js +48 -0
- package/cache/test/cache.test.d.ts +1 -0
- package/cache/test/cache.test.js +10 -0
- package/crud/index.d.ts +6 -0
- package/crud/index.js +10 -0
- package/crypto/getDecrypt.d.ts +5 -0
- package/crypto/getDecrypt.js +47 -0
- package/crypto/getEncrypt.d.ts +5 -0
- package/crypto/getEncrypt.js +47 -0
- package/crypto/getRandom.d.ts +4 -0
- package/crypto/getRandom.js +12 -0
- package/crypto/getSha256.d.ts +5 -0
- package/crypto/getSha256.js +48 -0
- package/crypto/index.d.ts +4 -0
- package/crypto/index.js +11 -0
- package/date/calculation.d.ts +75 -0
- package/date/calculation.js +207 -0
- package/date/financialYear.d.ts +19 -0
- package/date/financialYear.js +85 -0
- package/date/format.d.ts +68 -0
- package/date/format.js +150 -0
- package/date/index.d.ts +35 -0
- package/date/index.js +57 -0
- package/environment/index.d.ts +32 -0
- package/environment/index.js +92 -0
- package/eskimi/getAgeGroup.d.ts +4 -0
- package/eskimi/getAgeGroup.js +15 -0
- package/eskimi/getData.d.ts +4 -0
- package/eskimi/getData.js +17 -0
- package/eskimi/getDevice.d.ts +4 -0
- package/eskimi/getDevice.js +15 -0
- package/eskimi/getGender.d.ts +4 -0
- package/eskimi/getGender.js +15 -0
- package/eskimi/index.d.ts +49 -0
- package/eskimi/index.js +96 -0
- package/file/createDirectory.d.ts +5 -0
- package/file/createDirectory.js +50 -0
- package/file/index.d.ts +1 -0
- package/file/index.js +5 -0
- package/geo/countries.d.ts +12 -0
- package/geo/countries.js +222 -0
- package/geo/index.d.ts +2 -0
- package/geo/index.js +7 -0
- package/geo/languages.d.ts +9 -0
- package/geo/languages.js +58 -0
- package/google/bigQuery/GoogleBigQueryNamespace.d.ts +51 -0
- package/google/bigQuery/GoogleBigQueryNamespace.js +165 -0
- package/google/bigQuery/index.d.ts +5 -0
- package/google/bigQuery/index.js +37 -0
- package/google/bigQuery/loadData.d.ts +19 -0
- package/google/bigQuery/loadData.js +18 -0
- package/google/index.d.ts +27 -0
- package/google/index.js +24 -0
- package/google/sheets/GoogleSheetsNamespace.d.ts +16 -0
- package/google/sheets/GoogleSheetsNamespace.js +81 -0
- package/google/sheets/getAssociatedData.d.ts +10 -0
- package/google/sheets/getAssociatedData.js +43 -0
- package/google/sheets/index.d.ts +8 -0
- package/google/sheets/index.js +37 -0
- package/google/storage/GoogleCloudStorageNamespace.d.ts +20 -0
- package/google/storage/GoogleCloudStorageNamespace.js +108 -0
- package/google/storage/index.d.ts +3 -0
- package/google/storage/index.js +30 -0
- package/googleAds/GoogleAdsNamespace.d.ts +11 -0
- package/googleAds/GoogleAdsNamespace.js +73 -0
- package/googleAds/index.d.ts +11 -0
- package/googleAds/index.js +30 -0
- package/googleAds/keywordPlanner/index.d.ts +40 -0
- package/googleAds/keywordPlanner/index.js +59 -0
- package/googlePageSpeed/GooglePageSpeedNamespace.d.ts +11 -0
- package/googlePageSpeed/GooglePageSpeedNamespace.js +35 -0
- package/googlePageSpeed/index.d.ts +17 -0
- package/googlePageSpeed/index.js +44 -0
- package/googleSearchIncidents/index.d.ts +69 -0
- package/googleSearchIncidents/index.js +46 -0
- package/greenDomain/index.d.ts +21 -0
- package/greenDomain/index.js +41 -0
- package/inngest/index.d.ts +6 -0
- package/inngest/index.js +10 -0
- package/json/getJsonNewline.d.ts +1 -0
- package/json/getJsonNewline.js +13 -0
- package/json/index.d.ts +2 -0
- package/json/index.js +7 -0
- package/json/isJson.d.ts +1 -0
- package/json/isJson.js +26 -0
- package/littleWarden/LittleWardenNamespace.d.ts +11 -0
- package/littleWarden/LittleWardenNamespace.js +38 -0
- package/littleWarden/getUrlStatus.d.ts +4 -0
- package/littleWarden/getUrlStatus.js +16 -0
- package/littleWarden/index.d.ts +29 -0
- package/littleWarden/index.js +74 -0
- package/lumar/api/buildRequest.d.ts +13 -0
- package/lumar/api/buildRequest.js +80 -0
- package/lumar/api/getData.d.ts +5 -0
- package/lumar/api/getData.js +13 -0
- package/lumar/api/index.d.ts +36 -0
- package/lumar/api/index.js +33 -0
- package/lumar/api/initClient.d.ts +6 -0
- package/lumar/api/initClient.js +26 -0
- package/lumar/graphql/columns.d.ts +28 -0
- package/lumar/graphql/columns.js +31 -0
- package/lumar/graphql/getData.d.ts +1 -0
- package/lumar/graphql/getData.js +20 -0
- package/lumar/graphql/index.d.ts +29 -0
- package/lumar/graphql/index.js +39 -0
- package/lumar/graphql/initClient.d.ts +5 -0
- package/lumar/graphql/initClient.js +25 -0
- package/lumar/graphql/queries/crawl.d.ts +5 -0
- package/lumar/graphql/queries/crawl.js +2 -0
- package/lumar/graphql/queries/getCrawls.d.ts +18 -0
- package/lumar/graphql/queries/getCrawls.js +33 -0
- package/lumar/graphql/queries/getReportDifferences.d.ts +24 -0
- package/lumar/graphql/queries/getReportDifferences.js +37 -0
- package/lumar/graphql/queries/getRows.d.ts +38 -0
- package/lumar/graphql/queries/getRows.js +57 -0
- package/lumar/graphql/queries/getTotals.d.ts +25 -0
- package/lumar/graphql/queries/getTotals.js +40 -0
- package/lumar/graphql/queries/row.d.ts +157 -0
- package/lumar/graphql/queries/row.js +2 -0
- package/lumar/graphql/reportTemplates.d.ts +67 -0
- package/lumar/graphql/reportTemplates.js +70 -0
- package/myTarget/request.d.ts +5 -0
- package/myTarget/request.js +17 -0
- package/nextAuth/index.d.ts +6 -0
- package/nextAuth/index.js +11 -0
- package/nextAuth/isSessionReady.d.ts +1 -0
- package/nextAuth/isSessionReady.js +13 -0
- package/nextJs/getIp.d.ts +6 -0
- package/nextJs/getIp.js +14 -0
- package/nextJs/getUserAgent.d.ts +6 -0
- package/nextJs/getUserAgent.js +8 -0
- package/nextJs/index.d.ts +2 -0
- package/nextJs/index.js +7 -0
- package/number/format.d.ts +12 -0
- package/number/format.js +20 -0
- package/number/formatCurrency.d.ts +5 -0
- package/number/formatCurrency.js +21 -0
- package/number/getDecimal.d.ts +4 -0
- package/number/getDecimal.js +12 -0
- package/number/getNumber.d.ts +4 -0
- package/number/getNumber.js +48 -0
- package/number/getPercentIncrease.d.ts +4 -0
- package/number/getPercentIncrease.js +16 -0
- package/number/getSafeDivide.d.ts +11 -0
- package/number/getSafeDivide.js +20 -0
- package/number/index.d.ts +6 -0
- package/number/index.js +15 -0
- package/object/index.d.ts +1 -0
- package/object/index.js +5 -0
- package/object/replaceKeys.d.ts +5 -0
- package/object/replaceKeys.js +25 -0
- package/onePassword/OnePasswordNamespace.d.ts +13 -0
- package/onePassword/OnePasswordNamespace.js +81 -0
- package/onePassword/index.d.ts +7 -0
- package/onePassword/index.js +25 -0
- package/openAi/OpenAiNamespace.d.ts +11 -0
- package/openAi/OpenAiNamespace.js +44 -0
- package/openAi/index.d.ts +5 -0
- package/openAi/index.js +30 -0
- package/package.json +2 -2
- package/prisma/PrismaNamespace.d.ts +8 -0
- package/prisma/PrismaNamespace.js +79 -0
- package/prisma/getDecimal.d.ts +4 -0
- package/prisma/getDecimal.js +23 -0
- package/prisma/index.d.ts +8 -0
- package/prisma/index.js +29 -0
- package/snapchat/SnapchatNamespace.d.ts +15 -0
- package/snapchat/SnapchatNamespace.js +30 -0
- package/snapchat/index.d.ts +7 -0
- package/snapchat/index.js +30 -0
- package/sorting/byNumberAscending.d.ts +4 -0
- package/sorting/byNumberAscending.js +19 -0
- package/sorting/byNumberDescending.d.ts +4 -0
- package/sorting/byNumberDescending.js +22 -0
- package/sorting/byStringAscending.d.ts +4 -0
- package/sorting/byStringAscending.js +16 -0
- package/sorting/byStringDescending.d.ts +4 -0
- package/sorting/byStringDescending.js +16 -0
- package/sorting/index.d.ts +4 -0
- package/sorting/index.js +11 -0
- package/stream/index.d.ts +1 -0
- package/stream/index.js +5 -0
- package/stream/sort.d.ts +13 -0
- package/stream/sort.js +51 -0
- package/string/getCapitalised.d.ts +5 -0
- package/string/getCapitalised.js +18 -0
- package/string/getClean.d.ts +18 -0
- package/string/getClean.js +51 -0
- package/string/getFolder.d.ts +4 -0
- package/string/getFolder.js +15 -0
- package/string/getProperCase.d.ts +11 -0
- package/string/getProperCase.js +25 -0
- package/string/getString.d.ts +4 -0
- package/string/getString.js +34 -0
- package/string/getStringFromStream.d.ts +5 -0
- package/string/getStringFromStream.js +17 -0
- package/string/getUnescaped.d.ts +6 -0
- package/string/getUnescaped.js +26 -0
- package/string/getWithoutAccents.d.ts +5 -0
- package/string/getWithoutAccents.js +13 -0
- package/string/getWithoutHtmlTags.d.ts +5 -0
- package/string/getWithoutHtmlTags.js +12 -0
- package/string/getWithoutPunctuation.d.ts +5 -0
- package/string/getWithoutPunctuation.js +13 -0
- package/string/getWithoutUnderscores.d.ts +4 -0
- package/string/getWithoutUnderscores.js +11 -0
- package/string/getWithoutWhitespaces.d.ts +5 -0
- package/string/getWithoutWhitespaces.js +13 -0
- package/string/index.d.ts +12 -0
- package/string/index.js +27 -0
- package/swr/index.d.ts +42 -0
- package/swr/index.js +59 -0
- package/upTimeRobot/UpTimeRobotNamespace.d.ts +31 -0
- package/upTimeRobot/UpTimeRobotNamespace.js +52 -0
- package/upTimeRobot/index.d.ts +38 -0
- package/upTimeRobot/index.js +63 -0
- package/url/index.d.ts +30 -0
- package/url/index.js +72 -0
- package/url/writeUrlContents.d.ts +6 -0
- package/url/writeUrlContents.js +75 -0
- package/util/defaultTo.d.ts +4 -0
- package/util/defaultTo.js +44 -0
- package/util/getBrotliCompressed.d.ts +5 -0
- package/util/getBrotliCompressed.js +23 -0
- package/util/getBrotliDecompressed.d.ts +5 -0
- package/util/getBrotliDecompressed.js +24 -0
- package/util/getClean.d.ts +11 -0
- package/util/getClean.js +23 -0
- package/util/getGzipCompressed.d.ts +5 -0
- package/util/getGzipCompressed.js +23 -0
- package/util/getGzipDecompressed.d.ts +5 -0
- package/util/getGzipDecompressed.js +24 -0
- package/util/getWithoutHash.d.ts +4 -0
- package/util/getWithoutHash.js +18 -0
- package/util/getWithoutParameter.d.ts +4 -0
- package/util/getWithoutParameter.js +18 -0
- package/util/index.d.ts +11 -0
- package/util/index.js +25 -0
- package/util/isUndefined.d.ts +4 -0
- package/util/isUndefined.js +13 -0
- package/util/promiseChunks.d.ts +5 -0
- package/util/promiseChunks.js +19 -0
- package/util/sleep.d.ts +1 -0
- package/util/sleep.js +7 -0
- package/webWorker/index.d.ts +5 -0
- package/webWorker/index.js +9 -0
- package/xml/getXml.d.ts +1 -0
- 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,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,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,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,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;
|
package/sorting/index.js
ADDED
|
@@ -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";
|
package/stream/index.js
ADDED
package/stream/sort.d.ts
ADDED
|
@@ -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,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,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,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,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,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,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'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,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,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,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,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,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";
|
package/string/index.js
ADDED
|
@@ -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; } });
|