Comparing version 4.1.0 to 4.1.1
@@ -41,3 +41,3 @@ "use strict"; | ||
return { methodName: prefix(method), params: this.addSecret(params) }; | ||
}) | ||
}), | ||
]; | ||
@@ -51,3 +51,3 @@ return super.call("system.multicall", multi); | ||
prefix(method), | ||
this.addSecret(params) | ||
this.addSecret(params), | ||
]) | ||
@@ -59,3 +59,3 @@ ); | ||
const events = await this.call("system.listNotifications"); | ||
return events.map(event => unprefix(event)); | ||
return events.map((event) => unprefix(event)); | ||
} | ||
@@ -65,3 +65,3 @@ | ||
const methods = await this.call("system.listMethods"); | ||
return methods.map(method => unprefix(method)); | ||
return methods.map((method) => unprefix(method)); | ||
} | ||
@@ -77,5 +77,5 @@ } | ||
secret: "", | ||
path: "/jsonrpc" | ||
path: "/jsonrpc", | ||
}); | ||
module.exports = Aria2; |
@@ -5,3 +5,3 @@ "use strict"; | ||
module.exports = aria2 => { | ||
module.exports = (aria2) => { | ||
aria2.on("open", () => { | ||
@@ -15,3 +15,3 @@ console.log("aria2", "OPEN"); | ||
aria2.on("input", m => { | ||
aria2.on("input", (m) => { | ||
console.log("aria2", "IN"); | ||
@@ -21,3 +21,3 @@ console.log(inspect(m, { depth: null, colors: true })); | ||
aria2.on("output", m => { | ||
aria2.on("output", (m) => { | ||
console.log("aria2", "OUT"); | ||
@@ -24,0 +24,0 @@ console.log(inspect(m, { depth: null, colors: true })); |
@@ -41,3 +41,3 @@ "use strict"; | ||
return new Promise((resolve, reject) => { | ||
const cb = err => { | ||
const cb = (err) => { | ||
if (err) reject(err); | ||
@@ -52,3 +52,3 @@ else resolve(); | ||
async http(message) { | ||
const response = this.fetch(this.url("http"), { | ||
const response = await this.fetch(this.url("http"), { | ||
method: "POST", | ||
@@ -58,9 +58,12 @@ body: JSON.stringify(message), | ||
Accept: "application/json", | ||
"Content-Type": "application/json" | ||
} | ||
"Content-Type": "application/json", | ||
}, | ||
}); | ||
response.then(async res => { | ||
this._onmessage(await res.json()); | ||
}); | ||
response | ||
.json() | ||
.then(this._onmessage) | ||
.catch((err) => { | ||
this.emit("error", err); | ||
}); | ||
@@ -78,3 +81,3 @@ return response; | ||
"json-rpc": "2.0", | ||
id: this.id() | ||
id: this.id(), | ||
}; | ||
@@ -159,4 +162,11 @@ | ||
}; | ||
socket.onmessage = event => { | ||
this._onmessage(JSON.parse(event.data)); | ||
socket.onmessage = (event) => { | ||
let message; | ||
try { | ||
message = JSON.parse(event.data); | ||
} catch (err) { | ||
this.emit("error", err); | ||
return; | ||
} | ||
this._onmessage(message); | ||
}; | ||
@@ -166,2 +176,5 @@ socket.onopen = (...args) => { | ||
}; | ||
socket.onerror = (...args) => { | ||
this.emit("error", ...args); | ||
}; | ||
@@ -185,5 +198,5 @@ return promiseEvent(this, "open"); | ||
fetch, | ||
WebSocket | ||
WebSocket, | ||
}; | ||
module.exports = JSONRPCClient; |
{ | ||
"name": "aria2", | ||
"version": "4.1.0", | ||
"description": "Library and cli for aria2, \"The next generation download utility.\"", | ||
"version": "4.1.1", | ||
"description": "Library and for aria2, \"The next generation download utility.\"", | ||
"homepage": "https://github.com/sonnyp/aria2.js", | ||
@@ -21,5 +21,2 @@ "bugs": "https://github.com/sonnyp/aria2.js/issues", | ||
], | ||
"bin": { | ||
"aria2rpc": "./bin/cli.js" | ||
}, | ||
"scripts": { | ||
@@ -33,12 +30,11 @@ "preversion": "npm test", | ||
"dependencies": { | ||
"commander": "^3.0.1", | ||
"node-fetch": "^2.6.0", | ||
"ws": "^7.1.2" | ||
"node-fetch": "^2.6.1", | ||
"ws": "^7.4.0" | ||
}, | ||
"devDependencies": { | ||
"ava": "^2.3.0", | ||
"prettier": "1.18.2" | ||
"ava": "^3.13.0", | ||
"prettier": "2.1.2" | ||
}, | ||
"engines": { | ||
"node": ">= 7.6.0" | ||
"node": ">= 10" | ||
}, | ||
@@ -45,0 +41,0 @@ "browser": { |
# aria2.js | ||
JavaScript (Node.js and browsers) library and [cli](https://github.com/sonnyp/aria2.js/blob/master/bin/README.md) for [aria2, "The next generation download utility."](https://aria2.github.io/) | ||
JavaScript (Node.js and browsers) library for [aria2, "The next generation download utility."](https://aria2.github.io/) | ||
[![license](https://img.shields.io/github/license/sonnyp/aria2.js.svg?maxAge=2592000&style=flat-square)](https://raw.githubusercontent.com/sonnyp/aria2.js/master/LICENSE) | ||
[![Build Status](https://img.shields.io/travis/sonnyp/aria2.js/master.svg?style=flat-square)](https://travis-ci.org/sonnyp/aria2.js/branches) | ||
[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier) | ||
[![Dependency Status](https://img.shields.io/david/sonnyp/aria2.js.svg?style=flat-square)](https://david-dm.org/sonnyp/aria2.js) | ||
[![devDependency Status](https://img.shields.io/david/dev/sonnyp/aria2.js.svg?style=flat-square)](https://david-dm.org/sonnyp/aria2.js?type=dev) | ||
- [aria2.js](#aria2js) | ||
@@ -34,3 +26,2 @@ - [Introduction](#introduction) | ||
* [WebSocket](https://aria2.github.io/manual/en/html/aria2c.html#json-rpc-over-websocket) | ||
* ~~[JSONP](https://aria2.github.io/manual/en/html/aria2c.html#json-rpc-using-http-get)~~ [#25](https://github.com/sonnyp/aria2.js/pull/25) | ||
* promise API | ||
@@ -37,0 +28,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
2
1
14830
12
281
214
- Removedcommander@^3.0.1
- Removedcommander@3.0.2(transitive)
Updatednode-fetch@^2.6.1
Updatedws@^7.4.0