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 🙏

© 2024 – Pkg Stats / Ryan Hefner

@typescript/ata

v0.9.7

Published

A dependency for downloading `*.d.ts` files corresponding to a Node.js source file. Relies on API's provided by [jsdelivr](https://www.jsdelivr.com).

Downloads

40,516

Readme

TypeScript - Automatic Type Acquisition

A dependency for downloading *.d.ts files corresponding to a Node.js source file. Relies on API's provided by jsdelivr.

Usage

// Create the function for running ATA with a series of callbacks
const ata = setupTypeAcquisition({
  projectName: "My ATA Project",
  typescript: ts,
  logger: console,
  delegate: {
    receivedFile: (code: string, path: string) => {
      // Add code to your runtime at the path...
    },
    started: () => {
      console.log("ATA start")
    },
    progress: (downloaded: number, total: number) => {
      console.log(`Got ${downloaded} out of ${total}`)
    },
    finished: vfs => {
      console.log("ATA done", vfs)
    },
  },
})

// Run that function with the new sourcefile
ata(`import danger from "danger"`)

You can call ata when it is convenient to you, it will not grab the same dependencies twice. The callbacks for started and finished are only triggered when some work is going to happen, so you can use those for UI elements show/hide. progress is triggered every 5 downloads.

How it works

At a high level, for this input code:

import danger from "danger"

The library will

  • Look for the latest npm module of "danger", then get its file list
  • As there are .d.ts files to download in the dep, then it triggers started
  • Download the *.d.ts files for "danger" from the npm module "danger"
  • Read those .d.ts and look at these modules from usage:
    • "node-fetch" - it sees that "node-fetch" has no .d.ts files and gets them from "@types/node-fetch"
    • "commander" - it sees that command ships its own types
    • "@octokit/rest" - it sees that octokit/rest ships its own types
    • "gitlab" - it also sees
  • Recurse though their dependencies too.
  • Once those are done, trigger finished with a Map of the vfs if you prefer to set them in bulk.

Niceties

Users can give a specific npm version or tag to work from instead of the default "latest":

import { xy } from "xyz" // types: beta

If this isn't something you want, I'm not against a flag to disable it.