pax_global_header00006660000000000000000000000064132135475010014513gustar00rootroot0000000000000052 comment=38285099666f4ca31ed4b1390105700bf881c8e5 estree-is-function-1.0.0/000077500000000000000000000000001321354750100152345ustar00rootroot00000000000000estree-is-function-1.0.0/.gitignore000066400000000000000000000010401321354750100172170ustar00rootroot00000000000000# Logs logs *.log # Runtime data pids *.pid *.seed # Directory for instrumented libs generated by jscoverage/JSCover lib-cov # Coverage directory used by tools like istanbul coverage # Grunt intermediate storage (http://gruntjs.com/creating-plugins#storing-task-files) .grunt # node-waf configuration .lock-wscript # Compiled binary addons (http://nodejs.org/api/addons.html) build/Release # Dependency directory # https://www.npmjs.org/doc/misc/npm-faq.html#should-i-check-my-node_modules-folder-into-git node_modules package-lock.json estree-is-function-1.0.0/.travis.yml000066400000000000000000000001201321354750100173360ustar00rootroot00000000000000language: node_js node_js: - 8 - 6 - 4 cache: directories: - ~/.npm estree-is-function-1.0.0/LICENSE.md000066400000000000000000000011641321354750100166420ustar00rootroot00000000000000# [Apache License 2.0](https://spdx.org/licenses/Apache-2.0) Copyright 2017 Renée Kooi Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at > http://www.apache.org/licenses/LICENSE-2.0 Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License. estree-is-function-1.0.0/README.md000066400000000000000000000017051321354750100165160ustar00rootroot00000000000000# estree-is-function check if an AST node is a function of some sort. [![npm][npm-image]][npm-url] [![travis][travis-image]][travis-url] [![standard][standard-image]][standard-url] [npm-image]: https://img.shields.io/npm/v/estree-is-function.svg?style=flat-square [npm-url]: https://www.npmjs.com/package/estree-is-function [travis-image]: https://img.shields.io/travis/goto-bus-stop/estree-is-function.svg?style=flat-square [travis-url]: https://travis-ci.org/goto-bus-stop/estree-is-function [standard-image]: https://img.shields.io/badge/code%20style-standard-brightgreen.svg?style=flat-square [standard-url]: http://npm.im/standard ## Install ``` npm install estree-is-function ``` ## Usage ```js var isFunction = require('estree-is-function') isFunction(parse('function a () {}')) // true isFunction(parse('(function () {})')) // true isFunction(parse('(() => {})')) // true isFunction(parse('var x')) // false ``` ## License [Apache-2.0](LICENSE.md) estree-is-function-1.0.0/index.js000066400000000000000000000006341321354750100167040ustar00rootroot00000000000000module.exports = function isFunction (node) { if (typeof node !== 'object' || !node) { throw new TypeError('estree-is-function: node must be an object') } if (typeof node.type !== 'string') { throw new TypeError('estree-is-function: node must have a string type') } return node.type === 'FunctionDeclaration' || node.type === 'FunctionExpression' || node.type === 'ArrowFunctionExpression' } estree-is-function-1.0.0/package.json000066400000000000000000000014341321354750100175240ustar00rootroot00000000000000{ "name": "estree-is-function", "description": "check if an AST node is a function of some sort", "version": "1.0.0", "author": "Renée Kooi ", "bugs": { "url": "https://github.com/goto-bus-stop/estree-is-function/issues" }, "devDependencies": { "acorn": "^5.2.1", "standard": "^10.0.3", "tape": "^4.8.0" }, "homepage": "https://github.com/goto-bus-stop/estree-is-function", "keywords": [ "arrow-function", "check", "detect", "estree", "function", "functiondeclaration", "functionexpression" ], "license": "Apache-2.0", "main": "index.js", "repository": { "type": "git", "url": "https://github.com/goto-bus-stop/estree-is-function.git" }, "scripts": { "test": "standard && node test.js" } } estree-is-function-1.0.0/test.js000066400000000000000000000015551321354750100165570ustar00rootroot00000000000000var test = require('tape') var isFunction = require('./') var parse = require('acorn').parse test('throws if not a node', function (t) { t.plan(2) t.throws(function () { isFunction(null) }) t.throws(function () { isFunction({ whatever: 'xyz' }) }) }) test('FunctionDeclaration', function (t) { t.plan(1) t.ok(isFunction(parse('function a () {}').body[0])) }) test('ArrowFunction', function (t) { t.plan(1) t.ok(isFunction(parse('(() => {})').body[0].expression)) }) test('FunctionExpression', function (t) { t.plan(2) t.ok(isFunction(parse('(function () {})').body[0].expression)) t.ok(isFunction(parse('(function a () {})').body[0].expression)) }) test('anything else', function (t) { t.plan(3) t.notOk(isFunction(parse('10').body[0])) t.notOk(isFunction(parse('class A {}').body[0])) t.notOk(isFunction(parse('var x = () => {}').body[0])) })