Socket
Socket
Sign inDemoInstall

is-arrow-function

Package Overview
Dependencies
0
Maintainers
1
Versions
7
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 1.0.2 to 2.0.0

.jscs.json

14

index.js

@@ -0,10 +1,16 @@

'use strict';
var toStr = Object.prototype.toString;
var fnToStr = Function.prototype.toString;
var isFnRegex = /^\s*function/;
var isNonArrowFnRegex = /^\s*function/;
var isArrowFnWithParensRegex = /^\([^\)]*\) *=>/;
var isArrowFnWithoutParensRegex = /^[^=]*=>/;
module.exports = function isArrowFunction(fn) {
"use strict";
var fnStr = toStr.call(fn);
return fnStr === '[object Function]' && !isFnRegex.test(fnToStr.call(fn));
var typeStr = toStr.call(fn);
var fnStr = typeStr === '[object Function]' ? fnToStr.call(fn) : '';
return fnStr.length > 0
&& !isNonArrowFnRegex.test(fnStr)
&& (isArrowFnWithParensRegex.test(fnStr) || isArrowFnWithoutParensRegex.test(fnStr));
};
{
"name": "is-arrow-function",
"version": "1.0.2",
"version": "2.0.0",
"description": "Determine if a function is an ES6 arrow function or not.",
"main": "index.js",
"scripts": {
"test": "node --harmony test/index.js",
"test": "npm run lint && node --harmony test/index.js",
"coverage": "covert test/index.js",
"coverage-quiet": "covert test/index.js --quiet"
"coverage-quiet": "covert test/index.js --quiet",
"lint": "jscs *.js */*.js"
},

@@ -31,4 +32,5 @@ "repository": {

"devDependencies": {
"tape": "~2.14.0",
"covert": "~0.4.0"
"tape": "~3.0.3",
"covert": "1.0.0",
"jscs": "~1.8.1"
},

@@ -35,0 +37,0 @@ "testling": {

@@ -1,8 +0,10 @@

#is-arrow-function <sup>[![Version Badge][2]][1]</sup>
#is-arrow-function <sup>[![Version Badge][npm-version-svg]][npm-url]</sup>
[![Build Status][3]][4] [![dependency status][5]][6] [![dev dependency status][7]][8]
[![Build Status][travis-svg]][travis-url]
[![dependency status][deps-svg]][deps-url]
[![dev dependency status][dev-deps-svg]][dev-deps-url]
[![npm badge][11]][1]
[![npm badge][npm-badge-png]][npm-url]
[![browser support][9]][10]
[![browser support][testling-png]][testling-url]

@@ -20,2 +22,5 @@ npm module to determine if a function is an ES6 arrow function or not.

assert(isArrowFunction((a, b) => a * b));
assert(isArrowFunction(() => 42));
assert(isArrowFunction(x => x * x));
assert(isArrowFunction(x => () => x * x));
```

@@ -26,13 +31,13 @@

[1]: https://npmjs.org/package/is-arrow-function
[2]: http://vb.teelaun.ch/ljharb/node-is-arrow-function.svg
[3]: https://travis-ci.org/ljharb/node-is-arrow-function.png
[4]: https://travis-ci.org/ljharb/node-is-arrow-function
[5]: https://david-dm.org/ljharb/node-is-arrow-function.png
[6]: https://david-dm.org/ljharb/node-is-arrow-function
[7]: https://david-dm.org/ljharb/node-is-arrow-function/dev-status.png
[8]: https://david-dm.org/ljharb/node-is-arrow-function#info=devDependencies
[9]: https://ci.testling.com/ljharb/node-is-arrow-function.png
[10]: https://ci.testling.com/ljharb/node-is-arrow-function
[11]: https://nodei.co/npm/is-arrow-function.png?downloads=true&stars=true
[npm-url]: https://npmjs.org/package/is-arrow-function
[npm-version-svg]: http://vb.teelaun.ch/ljharb/node-is-arrow-function.svg
[travis-svg]: https://travis-ci.org/ljharb/node-is-arrow-function.svg
[travis-url]: https://travis-ci.org/ljharb/node-is-arrow-function
[deps-svg]: https://david-dm.org/ljharb/node-is-arrow-function.svg
[deps-url]: https://david-dm.org/ljharb/node-is-arrow-function
[dev-deps-svg]: https://david-dm.org/ljharb/node-is-arrow-function/dev-status.svg
[dev-deps-url]: https://david-dm.org/ljharb/node-is-arrow-function#info=devDependencies
[testling-png]: https://ci.testling.com/ljharb/node-is-arrow-function.png
[testling-url]: https://ci.testling.com/ljharb/node-is-arrow-function
[npm-badge-png]: https://nodei.co/npm/is-arrow-function.png?downloads=true&stars=true

@@ -1,6 +0,6 @@

"use strict";
'use strict';
var test = require('tape');
var isArrowFunction = require('../index');
var arrowFunc = require('../test/make-arrow-fn');
var arrowFuncs = require('../test/make-arrow-fns');

@@ -60,4 +60,6 @@ var forEach = function (arr, func) {

test('returns true for arrow functions', function (t) {
if (arrowFunc) {
t.ok(isArrowFunction(arrowFunc), 'arrow function is arrow function');
if (arrowFuncs.length > 0) {
arrowFuncs.forEach(function (arrowFunc) {
t.ok(isArrowFunction(arrowFunc), 'arrow function ' + arrowFunc + ' is arrow function');
});
} else {

@@ -64,0 +66,0 @@ t.skip('arrow function is arrow function - this environment does not support ES6 arrow functions. Please run `node --harmony`, or use a supporting browser.');

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc