# cp.fn.args

Functions for working with function arguments.


# API Overview

Functions - API calls offered directly by the extension

  • from
  • hasAny
  • hasNone
  • only
  • pack
  • unpack

# API Documentation

# Functions

# from

Signature cp.fn.args.from(index) -> function(...) -> ...
Type Function
Description Returns a function that selects the arguments from the provided index.
Parameters
  • index - The index of the argument to select.
Returns
  • A function that selects the argument at the specified index.
Notes None
Examples None
Source src/extensions/cp/fn/args.lua line 32

# hasAny

Signature cp.fn.args.hasAny(...) -> boolean
Type Function
Description Returns true if any of the arguments are not nil.
Parameters
  • ... - The arguments to check.
Returns
  • true if any of the arguments are not nil, false if not.
Notes None
Examples None
Source src/extensions/cp/fn/args.lua line 112

# hasNone

Signature cp.fn.args.hasNone(...) -> boolean
Type Function
Description Returns true if all the arguments are nil.
Parameters
  • ... - The arguments to check.
Returns
  • true if all the arguments are nil, false if not.
Notes None
Examples None
Source src/extensions/cp/fn/args.lua line 93

# only

Signature cp.fn.args.only(index, ...) -> function(...) -> any
Type Function
Description Returns a function that only returns the argument at the specified index.
Parameters
  • index - The index of the argument to return.
  • ... - The other indexes to include as well.
Returns
  • A function that returns the arguments at the specified indecies.
Notes None
Examples None
Source src/extensions/cp/fn/args.lua line 9

# pack

Signature cp.fn.args.pack(...) -> table, boolean
Type Function
Description Packs the arguments into a table.
Parameters
  • ... - The arguments to pack.
Returns
  • A table containing the arguments.
  • A boolean indicating whether the arguments were packed into a table.
Notes
  • If the number of arguments is 1 and the first argument is a table, and the table has a size of 1 or more, it will be returned.
  • Otherwise, the arguments are packed into a table.
Examples None
Source src/extensions/cp/fn/args.lua line 47

# unpack

Signature cp.fn.args.unpack(args, packed) -> ... | table
Type Function
Description Unpacks the arguments from a table.
Parameters
  • args - The arguments to unpack.
  • packed - A boolean indicating whether the arguments were packed.
Returns
  • The arguments, unpacked if necessary.
Notes
  • If the arguments were packed, the table is unpacked first.
  • * Otherwise, the arguments are returned unchanged.
Examples None
Source src/extensions/cp/fn/args.lua line 72