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

simple-aria2

v1.0.4

Published

It is a minimalist, browser - and NodeJs-enabled, easy-to-use aria2 dependency that provides only basic download, pause, delete, and fetch functionality. And provides an extension.

Downloads

3

Readme

simple-aria2


UseEnvironment

  1. The nodejs version is greater than 12
  2. Support for browsers and nodejs
  3. Please ensure that aria2 is enabled on your computer environment before use, otherwise it cannot be used normally

Introduction

Please ensure that aria2 is enabled on your computer environment before use, otherwise it cannot be used normally

Hello, my name is fuzhu, you can call me blue, here is my email [email protected]

This dependency only provides the most basic download, get the download list, delete the task, suspend the task operation, other operations please send according to the project send or send_async two methods.

The dependency package was originally intended to be used by itself, and found that it was more comfortable to use after packaging, and directly open source.

Install

The installation method is very simple, you just need to enter these two lines of command in the command line

npm i simple-aria2

or

yarn add simple-aria2

The next step is to use it directly on nodejs

const Aria2 = require('simple-aria2').default

or

import Aria2 from 'simple-aria2'

UseExample

First

First we need to define an aria2 object, and here I'll use es6 module as an example

import Aria2 from 'simple-aria2'
// The aria2 address here is defined by you, using the websocket protocol
const mAria2 = new Aria2('ws://localhost:6800/jsonrpc')

Example

Get all downloads

This is a listening function that gets the download every 3 seconds and returns a time type. You can stop this function using the clearInterval method

mAria2.active(list => {
  console.log(list)
  // Can use stop callback
  // clearInterval(mTimer)
}, 3000)

Return example

[{"bitfield":"ffffffffffffffffffffff80","completedLength":"92999832","connections":"0","dir":"C:\\Users\\17748\\Desktop\\node-aria2","downloadSpeed":"0","errorCode":"0","files":[{"completedLength":"92999832","index":"1","length":"92999832","path":"C:/Users/17748/Desktop/node-aria2/dasd","selected":"true","uris":[{"status":"used","uri":"https://webcdn.m.qq.com/spcmgr/download/VSCodeUserSetup-x64-1.79.2.exe"},{"status":"used","uri":"https://webcdn.m.qq.com/spcmgr/download/VSCodeUserSetup-x64-1.79.2.exe"},{"status":"used","uri":"https://webcdn.m.qq.com/spcmgr/download/VSCodeUserSetup-x64-1.79.2.exe"},{"status":"waiting","uri":"https://webcdn.m.qq.com/spcmgr/download/VSCodeUserSetup-x64-1.79.2.exe"},{"status":"waiting","uri":"https://webcdn.m.qq.com/spcmgr/download/VSCodeUserSetup-x64-1.79.2.exe"}]}],"gid":"d9e82441075b4d17","numPieces":"89","pieceLength":"1048576","status":"complete","totalLength":"92999832","uploadLength":"0","uploadSpeed":"0"}]

Download file

The download url can be a seed or a magnetic or a normal url

This is a promise example that only returns the gid of the download list, which can be used to manipulate the download status, and more Gids can be viewed from the list

mAria2.add(
  'http://xxxx.xxxx',
  {
    dir: '',
    out: '',
    'split': 5,
    'max-connection-per-server': 1,
    'seed-ratio': 1
  }
).then(res => {
  console.log(res)
  // { id: 1, jsonrpc: '2.0', result: '3b096f6a4f0b322a' }
})

Paused, Continue, Remove

Pause, continue, the removal method is the same, just need to pass the corresponding gid line, gid please use the active function to get from the list

// Pause
mAria2.pause(['3b096f6a4f0b322a'])
.then(res => console.log(res))

// continue
mAria2.continue(['3b096f6a4f0b322a'])
.then(res => console.log(res))

// Remove
mAria2.remove(['3b096f6a4f0b322a'])
.then(res => console.log(res))

custom

This method allows you to customize some data to be sent

// use callback
mAria2.send({ method: 'aria2.tellActive' }, res => {
  console.log(res)
})

// use promise
mAria2.send_async({ method: 'aria2.tellActive' }).then(res => {
  console.log(res)
})