Tweakr
    Preparing search index...

    Function unary

    • Creates a function that only accepts a single argument, ignoring any additional arguments passed to it.

      Type Parameters

      • T extends (...args: any[]) => any

      Parameters

      • fn: T

        The function to wrap.

      Returns (arg: Parameters<T>[0]) => any

      A new function that only takes the first argument.

      const parse = unary(JSON.parse);
      parse('{"a":1}', 'extra'); // ignores 'extra', only uses the first argument

      1.1.0