{"version":3,"file":"bind.mjs","names":[],"sources":["../../src/function/bind.ts"],"sourcesContent":["/**\n * Creates a function that invokes func with the this binding of thisArg and\n * partialArgs prepended to the arguments it receives.\n *\n * @template T - The type of the function\n * @param func - The function to bind\n * @param thisArg - The this binding of func\n * @param partialArgs - The arguments to be partially applied\n * @returns Returns the new bound function\n *\n * @example\n * const obj = {\n *   name: 'Alice',\n *   greet(greeting: string) {\n *     return `${greeting}, ${this.name}!`;\n *   }\n * };\n * const boundGreet = bind(obj.greet, obj, 'Hello');\n * boundGreet(); // => 'Hello, Alice!'\n *\n * @example\n * function add(this: { base: number }, a: number, b: number) {\n *   return this.base + a + b;\n * }\n * const obj = { base: 10 };\n * const boundAdd = bind(add, obj, 5);\n * boundAdd(3); // => 18\n */\nexport function bind<T extends (...args: never[]) => unknown>(\n  func: T,\n  thisArg: unknown,\n  ...partialArgs: unknown[]\n): (...args: unknown[]) => ReturnType<T> {\n  const call = (args: unknown[]): ReturnType<T> =>\n    (func as (this: unknown, ...args: never[]) => ReturnType<T>).apply(thisArg, args as never[]);\n\n  return function (...args: unknown[]): ReturnType<T> {\n    return call([...partialArgs, ...args]);\n  };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA4BA,SAAgB,KACd,MACA,SACA,GAAG,aACoC;CACvC,MAAM,QAAQ,SACX,KAA4D,MAAM,SAAS,IAAe;CAE7F,OAAO,SAAU,GAAG,MAAgC;EAClD,OAAO,KAAK,CAAC,GAAG,aAAa,GAAG,IAAI,CAAC;CACvC;AACF"}