get-function-header

0.1.1 • Public • Published

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

/get-function-header/

    Package Sidebar

    Install

    npm i get-function-header

    Weekly Downloads

    7

    Version

    0.1.1

    License

    MIT

    Last publish

    Collaborators

    • black_glory