0.2.2 • Published 5 months ago

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

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

isNativeFunction

NPM version Build Status Coverage Status

Test if a value is a native function.

Native functions execute native code that is typically not written in JavaScript, but a lower-level language like C++. This includes the JavaScript built-in functions, functions implemented using Node.js C/C++ addons, and code compiled via WebAssembly.

Installation

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

Usage

var isNativeFunction = require( '@stdlib/assert-is-native-function' );

isNativeFunction( value )

Tests if a value is a native function.

var bool = isNativeFunction( Date );
// returns true

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

bool = isNativeFunction( beep );
// returns false

Examples

var isNativeFunction = require( '@stdlib/assert-is-native-function' );

var bool = isNativeFunction( Math.sqrt );
// returns true

bool = isNativeFunction( Date );
// returns true

bool = isNativeFunction( RegExp );
// returns true

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

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

bool = isNativeFunction( 5 );
// returns false

bool = isNativeFunction( true );
// returns false

bool = isNativeFunction( null );
// returns false

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

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

See Also


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.