Files
common/packages/util/src/is/function.ts
T
2021-01-03 11:20:22 +01:00

24 lines
565 B
TypeScript

// Copyright 2017-2021 @polkadot/util authors & contributors
// SPDX-License-Identifier: Apache-2.0
// eslint-disable-next-line @typescript-eslint/ban-types
type FnType = Function;
/**
* @name isFunction
* @summary Tests for a `function`.
* @description
* Checks to see if the input value is a JavaScript function.
* @example
* <BR>
*
* ```javascript
* import { isFunction } from '@polkadot/util';
*
* isFunction(() => false); // => true
* ```
*/
export function isFunction (value: unknown): value is FnType {
return typeof value === 'function';
}