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

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

#6 in #package-metadata

Download history 314/week @ 2023-11-14 30/week @ 2023-11-21 34/week @ 2023-11-28 52/week @ 2023-12-05 14/week @ 2023-12-12 9/week @ 2023-12-19 11/week @ 2023-12-26 6/week @ 2024-01-02 89/week @ 2024-01-09 108/week @ 2024-01-16 34/week @ 2024-01-23 71/week @ 2024-01-30 65/week @ 2024-02-06 55/week @ 2024-02-13 84/week @ 2024-02-20 72/week @ 2024-02-27

288 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–18MB
~256K SLoC