#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

#1185 in Asynchronous

Download history 182/week @ 2024-04-10 120/week @ 2024-04-17 59/week @ 2024-04-24 180/week @ 2024-05-01 246/week @ 2024-05-08 240/week @ 2024-05-15 283/week @ 2024-05-22 134/week @ 2024-05-29 157/week @ 2024-06-05 185/week @ 2024-06-12 136/week @ 2024-06-19 182/week @ 2024-06-26 143/week @ 2024-07-03 378/week @ 2024-07-10 228/week @ 2024-07-17 199/week @ 2024-07-24

974 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–15MB
~222K SLoC