# GC.Spread.CalcEngine.Functions

## Content

# Namespace: Functions

[Spread](GC.Spread).[CalcEngine](GC.Spread.CalcEngine).Functions

## Table of contents

### Enumerations

- [AsyncFunctionEvaluateMode](../enums/GC.Spread.CalcEngine.Functions.AsyncFunctionEvaluateMode)

### Classes

- [AsyncFunction](../classes/GC.Spread.CalcEngine.Functions.AsyncFunction)
- [Function](../classes/GC.Spread.CalcEngine.Functions.Function)

### Interfaces

- [IFunctionDescription](../interfaces/GC.Spread.CalcEngine.Functions.IFunctionDescription)
- [IParameterDescription](../interfaces/GC.Spread.CalcEngine.Functions.IParameterDescription)

### Functions

- [defineGlobalCustomFunction](GC.Spread.CalcEngine.Functions#defineglobalcustomfunction)
- [findGlobalFunction](GC.Spread.CalcEngine.Functions#findglobalfunction)
- [removeGlobalFunction](GC.Spread.CalcEngine.Functions#removeglobalfunction)

## Functions

### <a id="defineglobalcustomfunction" name="defineglobalcustomfunction"></a> defineGlobalCustomFunction

▸ **defineGlobalCustomFunction**(`name`, `fn`): [`Function`](../classes/GC.Spread.CalcEngine.Functions.Function)

Defines a global custom function, which can be used in formulas.
The global custom function can be called from any spreadsheet.

**`example`**
```javascript
class FactorialFunction extends GC.Spread.CalcEngine.Functions.Function {
    constructor () {
        super('FACTORIAL', 1, 1, {
            description: "Function to calculate the Fibonacci number.",
            parameters: [{ name: 'n' }]
        });
    }
    evaluate (n) {
        var fib = [0, 1];
        for (var i = 2; i <= n; i++) {
          fib[i] = fib[i - 1] + fib[i - 2];
        }
        return fib[n];
    }
}
GC.Spread.CalcEngine.Functions.defineGlobalCustomFunction("FACTORIAL", new FactorialFunction());
```

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `name` | `string` | The name of the function. |
| `fn` | [`Function`](../classes/GC.Spread.CalcEngine.Functions.Function) | The function to add. |

#### Returns

[`Function`](../classes/GC.Spread.CalcEngine.Functions.Function)

The function that was added.

___

### <a id="findglobalfunction" name="findglobalfunction"></a> findGlobalFunction

▸ **findGlobalFunction**(`name?`): `any`

Gets all of the global functions or one global function that specified by name.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `name?` | `string` | The name of the function. |

#### Returns

`any`

If the name is empty, return all of the global functions, otherwise, return one function with the specified name.

___

### <a id="removeglobalfunction" name="removeglobalfunction"></a> removeGlobalFunction

▸ **removeGlobalFunction**(`name?`): `void`

If the name is empty, remove all of the global functions, otherwise, remove one function with the specified name.

#### Parameters

| Name | Type | Description |
| :------ | :------ | :------ |
| `name?` | `string` | The name of the function. |

#### Returns

`void`
