0.2.2 • Published 5 months ago

@stdlib/assert-is-arrow-function v0.2.2

Weekly downloads
-
License
Apache-2.0
Repository
github
Last release
5 months ago

isArrowFunction

NPM version Build Status Coverage Status

Test if a value is an arrow function.

Installation

npm install @stdlib/assert-is-arrow-function

Usage

var isArrowFunction = require( '@stdlib/assert-is-arrow-function' );

isArrowFunction( value )

Tests if a value is a an arrow function such as ( a, b ) => a + b, x => x, or ( x ) => { return x*x; }.

var beep = () => {
    console.log( 'beep' );
};

var bool = isArrowFunction( beep );
// returns true

function boop() {
    console.log( 'boop' );
}

bool = isArrowFunction( boop );
// returns false

Examples

var isArrowFunction = require( '@stdlib/assert-is-arrow-function' );

var bool = isArrowFunction( () => {} );
// returns true

bool = isArrowFunction( function foo() {} );
// returns false

bool = isArrowFunction( 'beep' );
// returns false

bool = isArrowFunction( 5 );
// returns false

bool = isArrowFunction( true );
// returns false

bool = isArrowFunction( null );
// returns false

bool = isArrowFunction( [] );
// returns false

bool = isArrowFunction( {} );
// returns false

Notice

This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2024. The Stdlib Authors.