@elyukai/utils 0.1.5 → 0.1.7
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/CHANGELOG.md +14 -0
- package/dist/dictionary.d.ts +1 -1
- package/dist/function.d.ts +18 -0
- package/dist/function.js +18 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,20 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [commit-and-tag-version](https://github.com/absolute-version/commit-and-tag-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
## [0.1.7](https://github.com/elyukai/ts-utils/compare/v0.1.6...v0.1.7) (2026-02-05)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
* add bind function for partiall application ([bc11da5](https://github.com/elyukai/ts-utils/commit/bc11da568c8ce15c071432307abcb7143f40b5ee))
|
|
11
|
+
|
|
12
|
+
## [0.1.6](https://github.com/elyukai/ts-utils/compare/v0.1.5...v0.1.6) (2026-01-28)
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
### Bug Fixes
|
|
16
|
+
|
|
17
|
+
* signature of map method ([3f8197f](https://github.com/elyukai/ts-utils/commit/3f8197fc7e8d5a003d493ae1460060e0c868e4db))
|
|
18
|
+
|
|
5
19
|
## [0.1.5](https://github.com/elyukai/ts-utils/compare/v0.1.4...v0.1.5) (2026-01-28)
|
|
6
20
|
|
|
7
21
|
|
package/dist/dictionary.d.ts
CHANGED
|
@@ -107,7 +107,7 @@ export declare class Dictionary<T extends AnyNonNullish | null, K extends string
|
|
|
107
107
|
/**
|
|
108
108
|
* Applies a function to every key-value pair in the dictionary.
|
|
109
109
|
*/
|
|
110
|
-
map<U extends AnyNonNullish | null>(mapFn: (value: T, key: K) => U): Dictionary<U>;
|
|
110
|
+
map<U extends AnyNonNullish | null>(mapFn: (value: T, key: K) => U): Dictionary<U, K>;
|
|
111
111
|
/**
|
|
112
112
|
* Calls the specified callback function for all the elements in an array. The return value of the callback function is the accumulated result, and is provided as an argument in the next call to the callback function.
|
|
113
113
|
*/
|
package/dist/function.d.ts
CHANGED
|
@@ -50,3 +50,21 @@ export declare const not: <T>(predicate: (value: T) => boolean) => (value: T) =>
|
|
|
50
50
|
* ```
|
|
51
51
|
*/
|
|
52
52
|
export declare const on: <T, U, V>(accessor: (value: T) => U, combinator: (a: U, b: U) => V) => ((a: T, b: T) => V);
|
|
53
|
+
/**
|
|
54
|
+
* Returns a function that binds the given arguments to the provided function.
|
|
55
|
+
*
|
|
56
|
+
* This is useful for creating partially applied functions or for fixing certain arguments of a function while leaving others flexible.
|
|
57
|
+
*
|
|
58
|
+
* @param fn The function to bind arguments to.
|
|
59
|
+
* @param fixedArgs The arguments to bind to the function.
|
|
60
|
+
* @returns A new function that takes the remaining arguments and calls the original function with both the fixed and remaining arguments.
|
|
61
|
+
*
|
|
62
|
+
* @example
|
|
63
|
+
* ```ts
|
|
64
|
+
* const add = (a: number, b: number) => a + b;
|
|
65
|
+
* const add5 = bind(add, 5);
|
|
66
|
+
*
|
|
67
|
+
* console.log(add5(10)); // Output: 15
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
export declare const bind: <A extends unknown[], B extends unknown[], R>(fn: (...args: [...A, ...B]) => R, ...fixedArgs: A) => ((...restArgs: B) => R);
|
package/dist/function.js
CHANGED
|
@@ -54,3 +54,21 @@ export const not = (predicate) => (value) => !predicate(value);
|
|
|
54
54
|
* ```
|
|
55
55
|
*/
|
|
56
56
|
export const on = (accessor, combinator) => (a, b) => combinator(accessor(a), accessor(b));
|
|
57
|
+
/**
|
|
58
|
+
* Returns a function that binds the given arguments to the provided function.
|
|
59
|
+
*
|
|
60
|
+
* This is useful for creating partially applied functions or for fixing certain arguments of a function while leaving others flexible.
|
|
61
|
+
*
|
|
62
|
+
* @param fn The function to bind arguments to.
|
|
63
|
+
* @param fixedArgs The arguments to bind to the function.
|
|
64
|
+
* @returns A new function that takes the remaining arguments and calls the original function with both the fixed and remaining arguments.
|
|
65
|
+
*
|
|
66
|
+
* @example
|
|
67
|
+
* ```ts
|
|
68
|
+
* const add = (a: number, b: number) => a + b;
|
|
69
|
+
* const add5 = bind(add, 5);
|
|
70
|
+
*
|
|
71
|
+
* console.log(add5(10)); // Output: 15
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export const bind = (fn, ...fixedArgs) => (...restArgs) => fn(...fixedArgs, ...restArgs);
|