#npm #package #metadata #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

#1103 in Asynchronous

Download history 32/week @ 2024-01-20 69/week @ 2024-01-27 54/week @ 2024-02-03 62/week @ 2024-02-10 91/week @ 2024-02-17 77/week @ 2024-02-24 12/week @ 2024-03-02 9/week @ 2024-03-09 26/week @ 2024-03-16 157/week @ 2024-03-23 132/week @ 2024-03-30 72/week @ 2024-04-06 236/week @ 2024-04-13 41/week @ 2024-04-20 51/week @ 2024-04-27 269/week @ 2024-05-04

635 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–17MB
~251K SLoC