@zelgadis87/utils-core 4.10.0 → 4.11.1

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "$schema": "https://json.schemastore.org/package",
3
3
  "name": "@zelgadis87/utils-core",
4
- "version": "4.10.0",
4
+ "version": "4.11.1",
5
5
  "author": "Zelgadis87",
6
6
  "license": "ISC",
7
7
  "private": false,
@@ -19,18 +19,18 @@
19
19
  }
20
20
  },
21
21
  "devDependencies": {
22
- "@stylistic/eslint-plugin-ts": "2.13.0",
23
- "@typescript-eslint/eslint-plugin": "8.20.0",
24
- "@typescript-eslint/parser": "8.20.0",
25
- "@vitest/coverage-v8": "2.1.8",
26
- "@vitest/ui": "2.1.8",
27
- "esbuild": "0.24.2",
28
- "eslint": "9.18.0",
29
- "nx": "20.3.2",
22
+ "@stylistic/eslint-plugin-ts": "4.2.0",
23
+ "@typescript-eslint/eslint-plugin": "8.26.1",
24
+ "@typescript-eslint/parser": "8.26.1",
25
+ "@vitest/coverage-v8": "3.0.8",
26
+ "@vitest/ui": "3.0.8",
27
+ "esbuild": "0.19.2",
28
+ "eslint": "9.22.0",
29
+ "nx": "20.6.0",
30
30
  "rimraf": "6.0.1",
31
- "typescript": "5.7.3",
32
- "typescript-eslint": "8.20.0",
33
- "vitest": "2.1.8"
31
+ "typescript": "5.8.2",
32
+ "typescript-eslint": "8.26.1",
33
+ "vitest": "3.0.8"
34
34
  },
35
35
  "dependencies": {
36
36
  "small-date": "^2.0.1"
@@ -5,6 +5,7 @@ export default constant;
5
5
  export const constantNull = constant( null );
6
6
  export const constantTrue = constant( true );
7
7
  export const constantFalse = constant( false );
8
+ export const constantUndefined = constant( void 0 );
8
9
  export const alwaysTrue = constantTrue;
9
10
  export const alwaysFalse = constantFalse;
10
11
  export const constantZero = constant( 0 );
@@ -1,3 +1,4 @@
1
+ import { identity } from './_index.js';
1
2
  import { constantTrue } from './functions.js';
2
3
 
3
4
  export * from './functions/constant.js';
@@ -61,4 +62,28 @@ export function xor<T>( a: TPredicate<T>, b: TPredicate<T> ): TPredicate<T> {
61
62
  return ( t: T ) => a( t ) !== b( t );
62
63
  }
63
64
 
65
+ export function pipedInvoke<T, A>( op1: TFunction<T, A> ): TFunction<T, A>;
66
+ export function pipedInvoke<T, A, B>( op1: TFunction<T, A>, op2: TFunction<A, B> ): TFunction<T, B>;
67
+ export function pipedInvoke<T, A, B, C>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C> ): TFunction<T, C>;
68
+ export function pipedInvoke<T, A, B, C, D>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D> ): TFunction<T, D>;
69
+ export function pipedInvoke<T, A, B, C, D, E>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E> ): TFunction<T, E>;
70
+ export function pipedInvoke<T, A, B, C, D, E, F>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F> ): TFunction<T, F>;
71
+ export function pipedInvoke<T, A, B, C, D, E, F, G>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G> ): TFunction<T, G>;
72
+ export function pipedInvoke<T, A, B, C, D, E, F, G, H>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>, op8: TFunction<G, H> ): TFunction<T, H>;
73
+ export function pipedInvoke<T, A, B, C, D, E, F, G, H, I>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>, op8: TFunction<G, H>, op9: TFunction<H, I> ): TFunction<T, I>;
74
+ export function pipedInvoke<T, A, B, C, D, E, F, G, H, I>( op1: TFunction<T, A>, op2: TFunction<A, B>, op3: TFunction<B, C>, op4: TFunction<C, D>, op5: TFunction<D, E>, op6: TFunction<E, F>, op7: TFunction<F, G>, op8: TFunction<G, H>, op9: TFunction<H, I>, ...operations: TFunction<any, any>[] ): TFunction<T, unknown>;
75
+ export function pipedInvoke( ...fns: Array<TFunction<any, any>>): TFunction<any, any> { return pipedInvokeFromArray( fns ) }
64
76
 
77
+ export function pipedInvokeFromArray<T, R>( fns: Array<TFunction<any, any>>): TFunction<any, any> {
78
+ if ( fns.length === 0 ) {
79
+ return identity as TFunction<any, any>;
80
+ }
81
+
82
+ if ( fns.length === 1 ) {
83
+ return fns[ 0 ];
84
+ }
85
+
86
+ return function piped( input: T ): R {
87
+ return fns.reduce( ( prev: any, fn: TFunction<T, R> ) => fn( prev ), input as any );
88
+ };
89
+ }
@@ -94,6 +94,9 @@ export function clamp( n: number, min: number, max: number ): number {
94
94
  return n;
95
95
  }
96
96
  }
97
+ export function clampInt0_100( n: number ) {
98
+ return clamp( Math.round( n ), 0, 100 ) as TNumber0_100;
99
+ }
97
100
 
98
101
  export function tryToParseNumber( numberStr: string ) {
99
102
  return withTryCatch( () => {
@@ -33,5 +33,6 @@ export async function awaitAtMost<T>( p: Promise<T>, t: TimeDuration ): Promise<
33
33
  return value;
34
34
  throw new TimeoutError();
35
35
  } );
36
-
37
36
  }
37
+
38
+ export const NEVER = new Promise( _resolve => { /* never end */ } );
@@ -1,4 +0,0 @@
1
- export * from './CancelableDeferred.ts';
2
- export * from './Deferred';
3
- export * from './RateThrottler';
4
- export * from './Semaphore';
@@ -1,2 +0,0 @@
1
- export * from './Lazy.js';
2
- export * from './LazyAsync.js';
@@ -1,4 +0,0 @@
1
- export * from './types.js';
2
- export { default as ComparisonChain } from './ComparisonChain.js';
3
- export * from './Sorter.js';
4
- export * from './types.js';
@@ -1,7 +0,0 @@
1
- export { default as RandomTimeDuration } from './RandomTimeDuration';
2
- export { TPredefinedTimeDuration, TValidTimeDuration, TimeDuration, isAllowedTimeDuration } from './TimeDuration';
3
- export { default as TimeFrequency } from './TimeFrequency';
4
- export * from './TimeInstant';
5
- export * from './TimeRange.js';
6
- export { default as TimeUnit } from './TimeUnit';
7
- export * from './types';
@@ -1,2 +0,0 @@
1
- export * from './DataUpgrader';
2
- export type { TUpgradable } from './types';
@@ -1,14 +0,0 @@
1
- export * from './arrays.js';
2
- export * from './booleans.js';
3
- export { TCssDeclarationRulesDictionary as TCSSDeclarationRulesDictionary, cssDeclarationRulesDictionaryToCss } from './css.js';
4
- export * from './empties.js';
5
- export * from './errors.js';
6
- export * from './functions.js';
7
- export * from './json.js';
8
- export * from './nulls.js';
9
- export * from './numbers.js';
10
- export * from './primitives.js';
11
- export * from './promises.js';
12
- export * from './random.js';
13
- export * from './records.js';
14
- export * from './strings.js';