npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

argumentsof

v1.0.1

Published

Npm module which parses arguments of any callables.

Downloads

12

Readme

argumentsof

Npm module which parses arguments of any callables.

Installation

npm install argumentsof

Usage

import argumnetsOf from 'argumentsof'

const sum = (one, ...numbers) => numbers.reduce((s, n) => s + n, one);

console.log(argumnetsOf(sum));
/*
[{
    name: 'one'
    rest: false,
}, {
    name: 'numbers'
    rest: true,
}]
*/

See argumentsOf.test.js for more examples.

Limitations

  1. It parses only arguments which have a name without default value.
  2. Resulting from 1. - it can't parse destructuring or any arguments assignment.
  3. Due to DX of code minification on client side, parsed names at runtime can differ from the source code. So it's preferable to be used on backend, where minification doesn't matter so much.

Motivation

This package is mostly useful for implementing such things as, for example, an automatic dependency injection pattern by parsing. You can easily parse class' arguments and then inject dependencies into constructor relying on the parsing result.

That's why it doesn't support parsing of destructuring and assignments. In the first case we can't extract the name of argument, and in the second - it's better to inject default value rather then to set it explicitly.

API

default export

can parse named and anonymous function, arrow function and class constructor.

By default it exports a function which recognizes itself a type of callable and tries to parse it.

So the basic usage is just to import and use:

import argumentsOf from 'argumentsof'

create

It also exports a function which builds an argumentsOf function. create accepts a configuration object, which specifies what types of callables to parse.

import { create } from 'argumentsof';

// Default configuration object
const argumentsOf = create({ 
  arrow: true, 
  class: true, 
  regular: true,
});