Comparing version 1.0.1 to 1.1.0
16
Aria2.js
@@ -7,2 +7,3 @@ (function(global) { | ||
var httpclient | ||
var noop = function() {} | ||
@@ -35,3 +36,3 @@ if (typeof module !== 'undefined' && module.exports) { | ||
'port': this.port, | ||
'path': '/jsonrpc', | ||
'path': this.path, | ||
'secure': this.secure, | ||
@@ -120,3 +121,3 @@ 'query': { | ||
Aria2.prototype.open = function(fn) { | ||
var url = (this.secure ? 'wss' : 'ws') + '://' + this.host + ':' + this.port + '/jsonrpc' | ||
var url = 'ws' + (this.secure ? 's' : '') + '://' + this.host + ':' + this.port + this.path | ||
var socket = this.socket = new WebSocket(url) | ||
@@ -147,6 +148,12 @@ var that = this | ||
Aria2.prototype.close = function() { | ||
if (!this.socket) | ||
Aria2.prototype.close = function(fn) { | ||
fn = fn || noop | ||
if (!this.socket) { | ||
fn() | ||
return | ||
} | ||
this.socket.addEventListener('close', function() { | ||
fn() | ||
}) | ||
this.socket.close() | ||
@@ -255,2 +262,3 @@ } | ||
'secret': '', | ||
'path': '/jsonrpc', | ||
} | ||
@@ -257,0 +265,0 @@ |
{ | ||
"name": "aria2", | ||
"version": "1.0.1", | ||
"description": "Library for aria2, \"The next generation download utility.\"", | ||
"version": "1.1.0", | ||
"description": "Library and cli for aria2, \"The next generation download utility.\"", | ||
"homepage": "https://github.com/sonnyp/aria2.js", | ||
@@ -21,5 +21,8 @@ "bugs": "https://github.com/sonnyp/aria2.js/issues", | ||
], | ||
"bin": { | ||
"aria2rpc": "./bin/cli.js" | ||
}, | ||
"scripts": { | ||
"preversion": "npm test", | ||
"lint": "./node_modules/.bin/eslint .", | ||
"lint": "eslint .", | ||
"unit": "mocha test/unit.js", | ||
@@ -32,4 +35,5 @@ "integration": "mocha test/integration.js", | ||
"dependencies": { | ||
"ws": "^0.8.0", | ||
"httpclient": "0.0.4" | ||
"commander": "^2.9.0", | ||
"httpclient": "0.0.4", | ||
"ws": "^0.8.0" | ||
}, | ||
@@ -36,0 +40,0 @@ "devDependencies": { |
aria2.js | ||
======== | ||
JavaScript (Node.js and browsers) library for [aria2, "The next generation download utility."](http://aria2.sourceforge.net/) | ||
JavaScript (Node.js and browsers) library and cli for [aria2, "The next generation download utility."](http://aria2.sourceforge.net/) | ||
@@ -79,3 +79,3 @@ [![Build Status](https://img.shields.io/travis/sonnyp/aria2.js/master.svg?style=flat-square)](https://travis-ci.org/sonnyp/aria2.js/branches) | ||
```xml | ||
<script src="node_modules/aria2/lib/index.js"></script> | ||
<script src="node_modules/aria2/Aria2.js"></script> | ||
``` | ||
@@ -86,2 +86,8 @@ ```javascript | ||
---- | ||
Start aria2c in daemon mode with | ||
```aria2c --enable-rpc --rpc-listen-all=true --rpc-allow-origin-all``` | ||
[↑](#aria2js) | ||
@@ -95,3 +101,3 @@ | ||
default options are | ||
default options match aria2c defaults and are | ||
@@ -103,3 +109,4 @@ ```javascript | ||
secure: false, | ||
secret: '' | ||
secret: '', | ||
path: '/jsonrpc' | ||
} | ||
@@ -120,3 +127,3 @@ ``` | ||
}; | ||
aria2.open(); | ||
aria2.open([cb]); | ||
``` | ||
@@ -134,3 +141,3 @@ | ||
}; | ||
aria2.close(); | ||
aria2.close([cb]); | ||
``` | ||
@@ -137,0 +144,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
22147
9
376
215
3
+ Addedcommander@^2.9.0
+ Addedcommander@2.20.3(transitive)