@elyukai/utils 0.1.6 → 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 CHANGED
@@ -2,6 +2,13 @@
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
+
5
12
  ## [0.1.6](https://github.com/elyukai/ts-utils/compare/v0.1.5...v0.1.6) (2026-01-28)
6
13
 
7
14
 
@@ -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);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@elyukai/utils",
3
- "version": "0.1.6",
3
+ "version": "0.1.7",
4
4
  "description": "A set of JavaScript helper functions.",
5
5
  "files": [
6
6
  "dist",