@guillaume-docquier/tools-ts 6.0.0 → 6.1.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.
package/dist/Sort.d.ts CHANGED
@@ -3,4 +3,8 @@ export declare const Sort: {
3
3
  * Sorts numbers by ascending values
4
4
  */
5
5
  byAscending: (a: number, b: number) => number;
6
+ /**
7
+ * Sorts records by a numeric property in ascending order
8
+ */
9
+ byAscendingProperty: <TProperty extends PropertyKey>(property: TProperty) => <TRecord extends Record<TProperty, number>>(a: TRecord, b: TRecord) => number;
6
10
  };
package/dist/Sort.js CHANGED
@@ -5,5 +5,11 @@ export const Sort = {
5
5
  byAscending: (a, b) => {
6
6
  return a - b;
7
7
  },
8
+ /**
9
+ * Sorts records by a numeric property in ascending order
10
+ */
11
+ byAscendingProperty: (property) => (a, b) => {
12
+ return Sort.byAscending(a[property], b[property]);
13
+ },
8
14
  };
9
15
  //# sourceMappingURL=Sort.js.map
package/dist/Sort.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Sort.js","sourceRoot":"","sources":["../src/Sort.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB;;OAEG;IACH,WAAW,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;QAC5C,OAAO,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;CACF,CAAA"}
1
+ {"version":3,"file":"Sort.js","sourceRoot":"","sources":["../src/Sort.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,IAAI,GAAG;IAClB;;OAEG;IACH,WAAW,EAAE,CAAC,CAAS,EAAE,CAAS,EAAU,EAAE;QAC5C,OAAO,CAAC,GAAG,CAAC,CAAA;IACd,CAAC;IAED;;OAEG;IACH,mBAAmB,EACjB,CAAgC,QAAmB,EAAE,EAAE,CACvD,CAA4C,CAAU,EAAE,CAAU,EAAU,EAAE;QAC5E,OAAO,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC,QAAQ,CAAC,EAAE,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAA;IACnD,CAAC;CACJ,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@guillaume-docquier/tools-ts",
3
- "version": "6.0.0",
3
+ "version": "6.1.0",
4
4
  "description": "My personal collection of typescript tools",
5
5
  "homepage": "https://github.com/Guillaume-Docquier/tools-ts",
6
6
  "license": "MIT",