#package-metadata #npm #async-client #registry #fetching #sync

npm-package

A simple client for fetching metadata from the npm package

2 unstable releases

0.2.0 Jan 31, 2023
0.1.0 Jan 31, 2023

#18 in #package-metadata

Download history 607/week @ 2024-11-17 346/week @ 2024-11-24 561/week @ 2024-12-01 680/week @ 2024-12-08 648/week @ 2024-12-15 199/week @ 2024-12-22 321/week @ 2024-12-29 676/week @ 2025-01-05 646/week @ 2025-01-12 655/week @ 2025-01-19 683/week @ 2025-01-26 646/week @ 2025-02-02 535/week @ 2025-02-09 583/week @ 2025-02-16 536/week @ 2025-02-23 596/week @ 2025-03-02

2,293 downloads per month

MIT license

11KB
137 lines

npm-package

A very light-weight sync and async client for fetching metadata from the npm registry for a npm package.

Usage

These examples come from our examples folder

Using the Async Client

use npm_package::AsyncNpmClient;
use tokio;

#[tokio::main]
async fn main() {
    let client = AsyncNpmClient::new();
    let is_wsl_package = client.get("is-wsl").await.unwrap();

    println!(
        "Description of is-wsl from the npm registry: {}",
        is_wsl_package.description
    );
}

Using the Sync Client

use npm_package::SyncNpmClient;

fn main() {
    let client = SyncNpmClient::new();
    let package = client.get("is-interactive").unwrap();
    let version_history = package.versions.keys().collect::<Vec<_>>();

    println!("All is-interactive releases on npm: {:?}", version_history);
}

Dependencies

~4–16MB
~223K SLoC