0.1.1 • Published 6 years ago

get-function-header v0.1.1

Weekly downloads
2
License
MIT
Repository
github
Last release
6 years ago

get-function-header npm GitHub license Build Status Coverage Status

Zero-dependency get function header

Installation

yarn add get-function-header

Usage

import getFunctionHeader from 'get-function-header'

async function sayHello(who, ...messages) {
  console.log(`${ who }: ${ messages.join() }`)
}

getFunctionHeader(sayHello.toString()).trim()
// async function sayHello(who, ...messages)

API

Table of Contents

getFunctionHeader

Get function header codeing from function string.

Parameters

  • code string The function string get from Function.prototype.toString
  • withComments boolean Return header with comments or not (optional, default false)

Returns string The function header string