@appartmint/mint 0.14.15 → 0.15.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,17 @@ export declare abstract class mintList {
7
7
  * @param list - the list to shuffle
8
8
  * @returns - the shuffled list
9
9
  */
10
- static shuffle(list: any[]): any[];
10
+ static shuffleCopy(list: any[]): any[];
11
+ /**
12
+ * Filters the array in place based on a test condition and returns the filtered array.
13
+ * This method modifies the original array by removing elements that do not pass the test implemented by the provided function.
14
+ *
15
+ * @template T The type of elements in the array.
16
+ * @param {T[]} list The array to filter, which will be modified in place.
17
+ * @param {(item: T) => boolean} test A function that tests each element of the array. Return `true` to keep the element, `false` otherwise.
18
+ * @returns {T[]} The original array with only the elements that passed the test.
19
+ */
20
+ static filter<T>(list: T[], test: (item: T) => boolean): T[];
11
21
  }
12
22
  export default mintList;
13
23
  //# sourceMappingURL=list.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/ts/imports/util/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,8BAAsB,QAAQ;IAC7B;;;;OAIG;IACH,MAAM,CAAC,OAAO,CAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE;CAQnC;AACD,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"list.d.ts","sourceRoot":"","sources":["../../../../src/ts/imports/util/list.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,8BAAsB,QAAQ;IAC7B;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAE,IAAI,EAAE,GAAG,EAAE,GAAG,GAAG,EAAE;IASvC;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CAAC,CAAC,EAAG,IAAI,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,CAAC,IAAI,EAAE,CAAC,KAAK,OAAO,GAAG,CAAC,EAAE;CAU7D;AACD,eAAe,QAAQ,CAAC"}
@@ -35,7 +35,15 @@ export declare abstract class mintObject {
35
35
  /**
36
36
  * Sorts an object's entries alphabetically by key
37
37
  */
38
- static sort(object: any): Object;
38
+ static sort(object: any, compareFn?: (a: string, b: string) => number): any;
39
+ /**
40
+ * Sorts an object's entries alphabetically by key
41
+ */
42
+ static sortKeys(object: any, compareFn?: (a: string, b: string) => number): any;
43
+ /**
44
+ * Sorts an object's entries alphabetically by value
45
+ */
46
+ static sortValues(object: any, compareFn: (a: any, b: any) => number): any;
39
47
  /**
40
48
  * @alias mintObject.filterKeys
41
49
  */
@@ -1 +1 @@
1
- {"version":3,"file":"object.d.ts","sourceRoot":"","sources":["../../../../src/ts/imports/util/object.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,8BAAsB,UAAU;IAC5B;;OAEG;IACF,MAAM,CAAC,SAAS,CAAE,IAAI,EAAE,GAAG,EAAE,IAAI,EAAE,GAAG,GAAI,OAAO;IAclD;;;;;;;OAOG;IACH,MAAM,CAAC,UAAU,CAAE,QAAQ,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,GAAI,OAAO;IA8BxD;;;;;OAKG;IACH,MAAM,CAAC,MAAM,CAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,MAAM;IAIpD;;;;OAIG;IACH,MAAM,CAAC,UAAU,CAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,GAAG;IASrD;;OAEG;IACH,MAAM,CAAC,YAAY,CAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAI,GAAG;IAStD;;OAEG;IACH,MAAM,CAAC,IAAI,CAAE,MAAM,EAAE,GAAG,GAAI,MAAM;IAOlC;;OAEG;IACH,MAAM,CAAC,MAAM,CAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,MAAM;IAIpD;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAE,MAAM,EAAE,GAAG,EAAE,IAAI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K,MAAM,GAAI,GAAG;IAOjF;;OAEG;IACH,MAAM,CAAC,UAAU,CAAE,MAAM,EAAE,GAAG,EAAE,SAAS,EAAE,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,KAAK,MAAM,GAAI,GAAG;IAO5E;;OAEG;IACH,MAAM,CAAC,MAAM,CAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,MAAM;IAIpD;;;;;OAKG;IACH,MAAM,CAAC,UAAU,CAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,MAAM,EAAE,GAAI,MAAM;IAOxD;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,GAAI,MAAM;IASzD;;;;;OAKG;IACH,MAAM,CAAC,WAAW,CAAE,QAAQ,EAAE,GAAG,EAAE,EAAE,MAAM,CAAC,EAAE,GAAG,EAAE,EAAE,GAAG,SAAO,GAAI,GAAG;CAoCzE;AACD,eAAe,UAAU,CAAC"}
@@ -12,6 +12,10 @@ export declare abstract class mintText {
12
12
  * Pluralize the given word
13
13
  */
14
14
  static pluralize(word: string): string;
15
+ /**
16
+ * Capitalize the first letter of the given word
17
+ */
18
+ static titleCase(text: string): string;
15
19
  }
16
20
  export default mintText;
17
21
  //# sourceMappingURL=text.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/ts/imports/util/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,8BAAsB,QAAQ;IAa7B;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIjC;;OAEG;IACH,MAAM,CAAC,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAiBvC;AACD,eAAe,QAAQ,CAAC"}
1
+ {"version":3,"file":"text.d.ts","sourceRoot":"","sources":["../../../../src/ts/imports/util/text.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,8BAAsB,QAAQ;IAa7B;;;;OAIG;IACH,MAAM,CAAC,IAAI,CAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IAIjC;;OAEG;IACH,MAAM,CAAC,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM;IAkBvC;;OAEG;IACH,MAAM,CAAC,SAAS,CAAE,IAAI,EAAE,MAAM,GAAG,MAAM;CAKvC;AACD,eAAe,QAAQ,CAAC"}
package/dist/js/index.js CHANGED
@@ -750,7 +750,7 @@ class mintList {
750
750
  * @param list - the list to shuffle
751
751
  * @returns - the shuffled list
752
752
  */
753
- static shuffle(list) {
753
+ static shuffleCopy(list) {
754
754
  let copy = [...list];
755
755
  for (let i = copy.length - 1; i > 0; i--) {
756
756
  const j = Math.floor(Math.random() * (i + 1));
@@ -758,6 +758,25 @@ class mintList {
758
758
  }
759
759
  return copy;
760
760
  }
761
+ /**
762
+ * Filters the array in place based on a test condition and returns the filtered array.
763
+ * This method modifies the original array by removing elements that do not pass the test implemented by the provided function.
764
+ *
765
+ * @template T The type of elements in the array.
766
+ * @param {T[]} list The array to filter, which will be modified in place.
767
+ * @param {(item: T) => boolean} test A function that tests each element of the array. Return `true` to keep the element, `false` otherwise.
768
+ * @returns {T[]} The original array with only the elements that passed the test.
769
+ */
770
+ static filter(list, test) {
771
+ let newLength = 0;
772
+ for (let i = 0; i < list.length; i++) {
773
+ if (test(list[i])) {
774
+ list[newLength++] = list[i];
775
+ }
776
+ }
777
+ list.length = newLength;
778
+ return list;
779
+ }
761
780
  }
762
781
  exports.mintList = mintList;
763
782
  ;
@@ -902,8 +921,23 @@ class mintObject {
902
921
  /**
903
922
  * Sorts an object's entries alphabetically by key
904
923
  */
905
- static sort(object) {
906
- return Object.keys(object).sort().reduce((obj, key) => {
924
+ static sort(object, compareFn) {
925
+ return this.sortKeys(object, compareFn);
926
+ }
927
+ /**
928
+ * Sorts an object's entries alphabetically by key
929
+ */
930
+ static sortKeys(object, compareFn) {
931
+ return Object.keys(object).sort(compareFn).reduce((obj, key) => {
932
+ obj[key] = object[key];
933
+ return obj;
934
+ }, {});
935
+ }
936
+ /**
937
+ * Sorts an object's entries alphabetically by value
938
+ */
939
+ static sortValues(object, compareFn) {
940
+ return Object.keys(object).sort((a, b) => compareFn(object[a], object[b])).reduce((obj, key) => {
907
941
  obj[key] = object[key];
908
942
  return obj;
909
943
  }, {});
@@ -1373,6 +1407,12 @@ class mintText {
1373
1407
  }
1374
1408
  return word + 's';
1375
1409
  }
1410
+ /**
1411
+ * Capitalize the first letter of the given word
1412
+ */
1413
+ static titleCase(text) {
1414
+ return text.toLowerCase().replace(/(?:^|\s)\S/g, a => a.toUpperCase());
1415
+ }
1376
1416
  }
1377
1417
  exports.mintText = mintText;
1378
1418
  ;