@naturalcycles/js-lib 14.276.0 → 14.277.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/types.d.ts CHANGED
@@ -264,16 +264,20 @@ export type SemVerString = string;
264
264
  * Named type for JSON.parse / JSON.stringify second argument
265
265
  */
266
266
  export type Reviver = (this: any, key: string, value: any) => any;
267
+ /**
268
+ * Like _stringMapValues, but values are sorted.
269
+ */
270
+ export declare function _stringMapValuesSorted<T>(map: StringMap<T>, mapper: Mapper<T, any>, dir?: SortDirection): T[];
267
271
  /**
268
272
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
269
273
  * Only affects typings, no runtime effect.
270
274
  */
271
- export declare const _stringMapValues: <T>(m: StringMap<T>) => T[];
275
+ export declare const _stringMapValues: <T>(map: StringMap<T>) => T[];
272
276
  /**
273
277
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
274
278
  * Only affects typings, no runtime effect.
275
279
  */
276
- export declare const _stringMapEntries: <T>(m: StringMap<T>) => [k: string, v: T][];
280
+ export declare const _stringMapEntries: <T>(map: StringMap<T>) => [k: string, v: T][];
277
281
  /**
278
282
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
279
283
  * This is how TypeScript should work, actually.
package/dist/types.js CHANGED
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports._objectAssign = exports._objectEntries = exports._objectKeys = exports._stringMapEntries = exports._stringMapValues = exports._passNothingPredicate = exports._passthroughPredicate = exports._noop = exports._passUndefinedMapper = exports._passthroughMapper = exports.MISS = exports.SKIP = exports.END = void 0;
4
+ exports._stringMapValuesSorted = _stringMapValuesSorted;
4
5
  exports._typeCast = _typeCast;
6
+ const array_util_1 = require("./array/array.util");
5
7
  /**
6
8
  * Symbol to indicate END of Sequence.
7
9
  */
@@ -28,6 +30,12 @@ const _passthroughPredicate = () => true;
28
30
  exports._passthroughPredicate = _passthroughPredicate;
29
31
  const _passNothingPredicate = () => false;
30
32
  exports._passNothingPredicate = _passNothingPredicate;
33
+ /**
34
+ * Like _stringMapValues, but values are sorted.
35
+ */
36
+ function _stringMapValuesSorted(map, mapper, dir = 'asc') {
37
+ return (0, array_util_1._sortBy)((0, exports._stringMapValues)(map), mapper, false, dir);
38
+ }
31
39
  /**
32
40
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
33
41
  * Only affects typings, no runtime effect.
package/dist-esm/types.js CHANGED
@@ -1,3 +1,4 @@
1
+ import { _sortBy } from './array/array.util';
1
2
  /**
2
3
  * Symbol to indicate END of Sequence.
3
4
  */
@@ -19,6 +20,12 @@ export const _passUndefinedMapper = () => undefined;
19
20
  export const _noop = (..._args) => undefined;
20
21
  export const _passthroughPredicate = () => true;
21
22
  export const _passNothingPredicate = () => false;
23
+ /**
24
+ * Like _stringMapValues, but values are sorted.
25
+ */
26
+ export function _stringMapValuesSorted(map, mapper, dir = 'asc') {
27
+ return _sortBy(_stringMapValues(map), mapper, false, dir);
28
+ }
22
29
  /**
23
30
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
24
31
  * Only affects typings, no runtime effect.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/js-lib",
3
- "version": "14.276.0",
3
+ "version": "14.277.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build-esm-cjs",
package/src/types.ts CHANGED
@@ -1,3 +1,4 @@
1
+ import { _sortBy } from './array/array.util'
1
2
  import type { Promisable } from './typeFest'
2
3
 
3
4
  declare const __brand: unique symbol
@@ -334,17 +335,28 @@ export type SemVerString = string
334
335
  */
335
336
  export type Reviver = (this: any, key: string, value: any) => any
336
337
 
338
+ /**
339
+ * Like _stringMapValues, but values are sorted.
340
+ */
341
+ export function _stringMapValuesSorted<T>(
342
+ map: StringMap<T>,
343
+ mapper: Mapper<T, any>,
344
+ dir: SortDirection = 'asc',
345
+ ): T[] {
346
+ return _sortBy(_stringMapValues(map), mapper, false, dir)
347
+ }
348
+
337
349
  /**
338
350
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
339
351
  * Only affects typings, no runtime effect.
340
352
  */
341
- export const _stringMapValues = Object.values as <T>(m: StringMap<T>) => T[]
353
+ export const _stringMapValues = Object.values as <T>(map: StringMap<T>) => T[]
342
354
 
343
355
  /**
344
356
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
345
357
  * Only affects typings, no runtime effect.
346
358
  */
347
- export const _stringMapEntries = Object.entries as <T>(m: StringMap<T>) => [k: string, v: T][]
359
+ export const _stringMapEntries = Object.entries as <T>(map: StringMap<T>) => [k: string, v: T][]
348
360
 
349
361
  /**
350
362
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.