Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/kgryte/regex-native-function
Regular expression to detect a native function.
https://github.com/kgryte/regex-native-function
Last synced: 25 days ago
JSON representation
Regular expression to detect a native function.
- Host: GitHub
- URL: https://github.com/kgryte/regex-native-function
- Owner: kgryte
- License: mit
- Created: 2015-08-16T01:02:37.000Z (about 9 years ago)
- Default Branch: master
- Last Pushed: 2015-08-16T01:26:19.000Z (about 9 years ago)
- Last Synced: 2024-10-06T10:02:02.633Z (about 1 month ago)
- Language: JavaScript
- Size: 117 KB
- Stars: 5
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
Native Function
===
[![NPM version][npm-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependencies][dependencies-image]][dependencies-url]> [Regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to detect a native function.
## Installation
``` bash
$ npm install regex-native-function
```## Usage
``` javascript
var re = require( 'regex-native-function' );
```#### re
[Regular expression](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Regular_Expressions) to detect a native `function`.
``` javascript
var bool = re.test( Math.sqrt.toString() );
// returns truebool = re.test( (function(){}).toString() );
// returns false
```## Examples
``` javascript
var re = require( 'regex-native-function' );function isNative( fcn ) {
return re.test( fcn.toString() );
}console.log( isNative( Math.sqrt ) );
// returns trueconsole.log( isNative( String ) );
// returns trueconsole.log( isNative( Int8Array ) );
// returns trueconsole.log( isNative( Date ) );
// returns trueconsole.log( isNative( function(){} ) );
// returns false
```To run the example code from the top-level application directory,
``` bash
$ node ./examples/index.js
```## Tests
### Unit
Unit tests use the [Mocha](http://mochajs.org/) test framework with [Chai](http://chaijs.com) assertions. To run the tests, execute the following command in the top-level application directory:
``` bash
$ make test
```All new feature development should have corresponding unit tests to validate correct functionality.
### Test Coverage
This repository uses [Istanbul](https://github.com/gotwarlost/istanbul) as its code coverage tool. To generate a test coverage report, execute the following command in the top-level application directory:
``` bash
$ make test-cov
```Istanbul creates a `./reports/coverage` directory. To access an HTML version of the report,
``` bash
$ make view-cov
```---
## License[MIT license](http://opensource.org/licenses/MIT).
## Copyright
Copyright © 2015. Athan Reines.
[npm-image]: http://img.shields.io/npm/v/regex-native-function.svg
[npm-url]: https://npmjs.org/package/regex-native-function[travis-image]: http://img.shields.io/travis/kgryte/regex-native-function/master.svg
[travis-url]: https://travis-ci.org/kgryte/regex-native-function[codecov-image]: https://img.shields.io/codecov/c/github/kgryte/regex-native-function/master.svg
[codecov-url]: https://codecov.io/github/kgryte/regex-native-function?branch=master[dependencies-image]: http://img.shields.io/david/kgryte/regex-native-function.svg
[dependencies-url]: https://david-dm.org/kgryte/regex-native-function[dev-dependencies-image]: http://img.shields.io/david/dev/kgryte/regex-native-function.svg
[dev-dependencies-url]: https://david-dm.org/dev/kgryte/regex-native-function[github-issues-image]: http://img.shields.io/github/issues/kgryte/regex-native-function.svg
[github-issues-url]: https://github.com/kgryte/regex-native-function/issues