cafe-utility 17.0.0 → 17.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.
Files changed (3) hide show
  1. package/index.d.ts +2 -0
  2. package/index.js +11 -1
  3. package/package.json +1 -1
package/index.d.ts CHANGED
@@ -206,6 +206,7 @@ declare function resolveMarkdownLinks(string: string, transformer: (label: strin
206
206
  declare function toQueryString(object: Record<string, any>, questionMark?: boolean): string;
207
207
  declare function parseQueryString(queryString: string): Record<string, string>;
208
208
  declare function hasKey(object: Record<string, any>, key: string): boolean;
209
+ declare function selectMax<T>(object: Record<string, T>, mapper: (item: T) => number): [string, T] | null;
209
210
  declare function buildUrl(baseUrl?: string | null, path?: string | null, query?: Record<string, any> | null): string;
210
211
  declare function parseCsv(string: string, delimiter?: string, quote?: string): string[];
211
212
  declare function humanizeProgress(state: Progress): string;
@@ -574,6 +575,7 @@ export declare const Objects: {
574
575
  toQueryString: typeof toQueryString;
575
576
  parseQueryString: typeof parseQueryString;
576
577
  hasKey: typeof hasKey;
578
+ selectMax: typeof selectMax;
577
579
  };
578
580
  export declare const Types: {
579
581
  isFunction: typeof isFunction;
package/index.js CHANGED
@@ -1116,6 +1116,15 @@ function parseQueryString(n) {
1116
1116
  function hasKey(n, e) {
1117
1117
  return Object.prototype.hasOwnProperty.call(n, e)
1118
1118
  }
1119
+ function selectMax(n, e) {
1120
+ let t = null,
1121
+ r = -1 / 0
1122
+ for (const [o, i] of Object.entries(n)) {
1123
+ const s = e(i)
1124
+ s > r && ((r = s), (t = o))
1125
+ }
1126
+ return t ? [t, n[t]] : null
1127
+ }
1119
1128
  function buildUrl(n, e, t) {
1120
1129
  return joinUrl(n, e) + toQueryString(t || {})
1121
1130
  }
@@ -2139,7 +2148,8 @@ function raycastCircle(n, e, t) {
2139
2148
  fromObjectString,
2140
2149
  toQueryString,
2141
2150
  parseQueryString,
2142
- hasKey
2151
+ hasKey,
2152
+ selectMax
2143
2153
  }),
2144
2154
  (exports.Types = {
2145
2155
  isFunction,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cafe-utility",
3
- "version": "17.0.0",
3
+ "version": "17.1.0",
4
4
  "description": "",
5
5
  "main": "index.js",
6
6
  "exports": {