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

apt-client

v3.0.2

Published

A library for reading aptly repositories

Downloads

38

Readme

Apt-Client

A basic Apt client for node and the browser, so you can get information about debian packages.

  • new AptClient(sources?: string[], arch?: string, cachetime? number) Constructs a new client for a possibly-empty list of source and optionally-specified architecture (defaults to 'all'). The sources should be strings just like you would see in a sources.list file, one per line, or URLs directly to a Sources(.gz) or Packages(.gz) file. If cachetime is specified, client.update will avoid re-requesting data for particular sources if they have already been requested within the last cachetime milliseconds.

  • client.update(sources?: string[], arch?: string, cachetime? number, clear?: boolean): Promise<[string, string][]> Rewrites the local cache with data fetched from the specified sources. The first three arguments default to the values provided to the constructor. This allows you the flexibility to specify a source list, target architecture, or cache timeout at client-creation time, or at update time. The clear parameter specifies whether the cached package data should be totally replaced, or only updated--the latter is useful if you wish to re-request a specific source without wiping out cached data previously requested from other sources. This defaults to true. The return value is a list of error pairs, with the first element of each pair being a description of the error, and the second being the repo spec or URL on which the error occurred.

  • client.getPackages(): { bin: string[], src: string[] } Returns lists of the names of all packages available as binaries or source.

  • client.listVersions(pkgName: string): { bin: string[], src: string[] } For a given package name, returns all of the versions available in binary or source formats.

  • client.getPkgInfo(pkgNames: Iterable<string>): Promise<{ bin: Map<string, PkgInfo<BinPkgInfo>>, src: Map<string, PkgInfo<SrcPkgInfo>> }> Gets detailed information about the named packages.

  • client.getBinFiles(pkgNames: Iterable<string>, checkHash=true): Promise<Map<string, ArrayBuffer | null>> Gets the binary .deb files for a list of packages as ArrayBuffers. If checkHash is not false, and an MD5, SHA1, or SHA256 hash was specified for a given package, the downloaded file data will be discarded and the package's entry in the returned map set to null unless the hash verification passes.

  • client.getSrcFiles(pkgNames: Iterable<string>, checkHash=true): Promise<Map<string, { [key: string]: ArrayBuffer | null}>> Gets the source files for a list of packages, with the sources of each package provided as an object mapping from source file name to ArrayBuffer. If checkHash is not false, files listed in the package Files must match their specified size, and files listed in the ChecksumsSha1 or ChecksumsSha256 sections must match the provided hash, or their data will be discarded and the file's entry in the returned map will be set to null.

  • client.isLatest(pkgName: string, version: string): boolean Checks if a given package version is the latest. Defaults to true if the package is not found in the cached sources. Checks against binary packages first, and source versions if the binary does not exist.

  • client.areLatest(packages: Iterable<[pkgName: string, version: string]>): Generator<[string, boolean]> Checks if each package is at the latest version, with the same algorithm as client.isLatest.

  • client.getLatest(packages: Iterable<string>): Generator<[pkgName: string, version: string]> Gets the latest version of each package available as a binary, or as a source if no binaries are available.

  • client.areAllLatest(packages: Iterable<[pkgName: string, version: string]>): boolean Checks if all the requested packages are up to date; this is more efficient than client.areLatest due to short-circuiting on the first non-up-to-date package.

  • AptClient.cmpVersions(a: string, b: string): number Compares two Debian package version strings and returns < 0 if a is less than b, > 0 if a is greater than b, and 0 if a equals b.

  • type PkgInfo<T> { latest: string, versions: Map<string, T> } For a given package, caches the latest version available and provides a map from version numbers to more detailed information about that package version.

Data guaranteed to be available on all package version info objects includes:

  • Package: string The package name
  • RepoBase: string The URL to the repository from which this information was obtained.
  • Version: string The version of the package being described.
  • Maintainer: { name: string, email: string } Contact information for the package maintainer. (Note that while the object is guaranteed to be present, the name, email, or both may be empty strings.)

Additional data guaranteed to be available on all version objects for binary packages includes:

  • Architecture: string[] A list of architectures for which binaries are available.
  • InstalledSize: number
  • Description: string
  • Filename: string A relative URL specifying where the binary file is stored in the repository.
  • Size: number

Additional data guaranteed to be available on all version objects for source packages includes:

  • Directory: string A relative URL specifying the directory in which source files are stored in the repository.
  • Files: { name: string, hash: string, size: number }[] A list of objects describing the individual source files.

Numerous other optional fields may or may not be present depending on their presence in the specific repository being queried.