@docaohuynh/ielts-api-utils 1.0.8 → 1.0.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.
package/dist/index.js CHANGED
@@ -500,6 +500,14 @@ var normalizeText = (text) => {
500
500
  var fullNameToUsername = (fullName) => {
501
501
  return import_transliteration.transliterate(fullName).normalize("NFD").replace(/[\u0300-\u036f]/g, "").toLowerCase().replace(/[^a-z0-9]/g, "").trim();
502
502
  };
503
+ // src/utils/strings/empty-line.util.ts
504
+ function removeEmptyLines(str) {
505
+ if (typeof str !== "string") {
506
+ throw new TypeError("Input must be a string");
507
+ }
508
+ return str.split(/\r?\n/).filter((line) => line.trim() !== "").join(`
509
+ `);
510
+ }
503
511
  // src/utils/decode/decode-signed.util.ts
504
512
  function decodeSignedPayload(signedPayload) {
505
513
  const parts = signedPayload.split(".");
@@ -7259,6 +7267,36 @@ function slugify(string, options) {
7259
7267
  var textToSlug = (text) => {
7260
7268
  return slugify(text);
7261
7269
  };
7270
+ // src/utils/date/date-compare.util.ts
7271
+ function compareDates(date1, date2) {
7272
+ if (date1 === null && date2 === null) {
7273
+ return 0;
7274
+ }
7275
+ if (date1 === null) {
7276
+ return -1;
7277
+ }
7278
+ if (date2 === null) {
7279
+ return 1;
7280
+ }
7281
+ const d1 = new Date(date1);
7282
+ const d2 = new Date(date2);
7283
+ if (d1.getTime() < d2.getTime()) {
7284
+ return -1;
7285
+ } else if (d1.getTime() > d2.getTime()) {
7286
+ return 1;
7287
+ } else {
7288
+ return 0;
7289
+ }
7290
+ }
7291
+ function isBefore(date1, date2) {
7292
+ return compareDates(date1, date2) < 0;
7293
+ }
7294
+ function isAfter(date1, date2) {
7295
+ return compareDates(date1, date2) > 0;
7296
+ }
7297
+ function isEqual(date1, date2) {
7298
+ return compareDates(date1, date2) === 0;
7299
+ }
7262
7300
  export {
7263
7301
  withTimeout,
7264
7302
  textToSlug,
@@ -7273,7 +7311,11 @@ export {
7273
7311
  sendDeleteWithBearer,
7274
7312
  sendDelete,
7275
7313
  replaceWordInList,
7314
+ removeEmptyLines,
7276
7315
  normalizeText,
7316
+ isEqual,
7317
+ isBefore,
7318
+ isAfter,
7277
7319
  getCurrentDateStr,
7278
7320
  getCurrentDateInUserTimezone,
7279
7321
  getCurrentDateFullInUserTimezone,
@@ -7286,5 +7328,6 @@ export {
7286
7328
  delayInMilliseconds,
7287
7329
  decryptText,
7288
7330
  decrypt,
7289
- decodeSignedPayload
7331
+ decodeSignedPayload,
7332
+ compareDates
7290
7333
  };
@@ -0,0 +1,29 @@
1
+ /**
2
+ * Compares two date strings in ISO format or null values
3
+ * @param date1 - First date string in ISO format or null
4
+ * @param date2 - Second date string in ISO format or null
5
+ * @returns -1 if date1 is earlier than date2, 0 if equal, 1 if date1 is later than date2
6
+ * If either date is null, treats it as earlier than any valid date
7
+ */
8
+ export declare function compareDates(date1: string | null, date2: string | null): number;
9
+ /**
10
+ * Checks if date1 is earlier than date2
11
+ * @param date1 - First date string in ISO format or null
12
+ * @param date2 - Second date string in ISO format or null
13
+ * @returns true if date1 is earlier than date2, false otherwise
14
+ */
15
+ export declare function isBefore(date1: string | null, date2: string | null): boolean;
16
+ /**
17
+ * Checks if date1 is later than date2
18
+ * @param date1 - First date string in ISO format or null
19
+ * @param date2 - Second date string in ISO format or null
20
+ * @returns true if date1 is later than date2, false otherwise
21
+ */
22
+ export declare function isAfter(date1: string | null, date2: string | null): boolean;
23
+ /**
24
+ * Checks if two dates are equal
25
+ * @param date1 - First date string in ISO format or null
26
+ * @param date2 - Second date string in ISO format or null
27
+ * @returns true if dates are equal, false otherwise
28
+ */
29
+ export declare function isEqual(date1: string | null, date2: string | null): boolean;
@@ -0,0 +1 @@
1
+ export * from './date-compare.util';
@@ -3,7 +3,7 @@ export * from './strings';
3
3
  export * from './decode';
4
4
  export * from './language';
5
5
  export * from './list';
6
- export * from './strings';
7
6
  export * from './time';
8
7
  export * from './request';
9
8
  export * from './slug';
9
+ export * from './date';
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Removes empty lines from a string.
3
+ * An empty line is considered to be a line that contains only whitespace characters or is completely empty.
4
+ *
5
+ * @param str - The input string to remove empty lines from
6
+ * @returns A new string with empty lines removed
7
+ */
8
+ export declare function removeEmptyLines(str: string): string;
@@ -1,2 +1,3 @@
1
1
  export * from './split.util';
2
2
  export * from './normalize.util';
3
+ export * from './empty-line.util';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@docaohuynh/ielts-api-utils",
3
- "version": "1.0.8",
3
+ "version": "1.0.10",
4
4
  "description": "Utilities for IELTS API",
5
5
  "module": "index.ts",
6
6
  "main": "dist/index.js",