@naturalcycles/js-lib 14.275.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
@@ -243,6 +243,11 @@ export type NonNegativeNumber = number;
243
243
  * data: (number | null)[]
244
244
  */
245
245
  export type NullableNumber = number | null;
246
+ export type NullablePositiveNumber = number | null;
247
+ export type NullableNonNegativeNumber = number | null;
248
+ export type NullableInteger = number | null;
249
+ export type NullablePositiveInteger = number | null;
250
+ export type NullableNotNegativeInteger = number | null;
246
251
  export type NullableString = string | null;
247
252
  export type NullableBoolean = boolean | null;
248
253
  export type NullableBuffer = Buffer | null;
@@ -259,16 +264,20 @@ export type SemVerString = string;
259
264
  * Named type for JSON.parse / JSON.stringify second argument
260
265
  */
261
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[];
262
271
  /**
263
272
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
264
273
  * Only affects typings, no runtime effect.
265
274
  */
266
- export declare const _stringMapValues: <T>(m: StringMap<T>) => T[];
275
+ export declare const _stringMapValues: <T>(map: StringMap<T>) => T[];
267
276
  /**
268
277
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
269
278
  * Only affects typings, no runtime effect.
270
279
  */
271
- 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][];
272
281
  /**
273
282
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.
274
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.275.0",
3
+ "version": "14.277.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build-esm-cjs",
@@ -20,7 +20,7 @@
20
20
  "zod": "^3"
21
21
  },
22
22
  "devDependencies": {
23
- "@naturalcycles/bench-lib": "^3",
23
+ "@naturalcycles/bench-lib": "^4",
24
24
  "@naturalcycles/dev-lib": "^17",
25
25
  "@naturalcycles/nodejs-lib": "^13",
26
26
  "@naturalcycles/time-lib": "^3",
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
@@ -306,6 +307,13 @@ export type NonNegativeNumber = number
306
307
  * data: (number | null)[]
307
308
  */
308
309
  export type NullableNumber = number | null
310
+ export type NullablePositiveNumber = number | null
311
+ export type NullableNonNegativeNumber = number | null
312
+
313
+ export type NullableInteger = number | null
314
+ export type NullablePositiveInteger = number | null
315
+ export type NullableNotNegativeInteger = number | null
316
+
309
317
  export type NullableString = string | null
310
318
  export type NullableBoolean = boolean | null
311
319
  export type NullableBuffer = Buffer | null
@@ -327,17 +335,28 @@ export type SemVerString = string
327
335
  */
328
336
  export type Reviver = (this: any, key: string, value: any) => any
329
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
+
330
349
  /**
331
350
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
332
351
  * Only affects typings, no runtime effect.
333
352
  */
334
- export const _stringMapValues = Object.values as <T>(m: StringMap<T>) => T[]
353
+ export const _stringMapValues = Object.values as <T>(map: StringMap<T>) => T[]
335
354
 
336
355
  /**
337
356
  * Needed due to https://github.com/microsoft/TypeScript/issues/13778
338
357
  * Only affects typings, no runtime effect.
339
358
  */
340
- 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][]
341
360
 
342
361
  /**
343
362
  * Alias of `Object.keys`, but returns keys typed as `keyof T`, not as just `string`.