Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@rqt/aqt

Package Overview
Dependencies
Maintainers
1
Versions
18
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@rqt/aqt - npm Package Compare versions

Comparing version 1.3.0 to 1.4.0

compile/template.js

7

CHANGELOG.md

@@ -0,1 +1,8 @@

## 8 January 2020
### [1.4.0](https://github.com/rqt/aqt/compare/v1.3.0...v1.4.0)
- [fix] Compile w/ destructured headers' names for Closure.
- [doc] Add `typedefs.json` file.
## 29 July 2019

@@ -2,0 +9,0 @@

163

compile/aqt.js

@@ -10,6 +10,6 @@ #!/usr/bin/env node

const stream = require('stream');
const {request:u} = https;
const {request:y} = http;
const {debuglog:z} = util;
const A = (a, b = 0, c = !1) => {
const t = https.request;
const x = http.request;
const y = util.debuglog;
const z = (a, b = 0, c = !1) => {
if (0 === b && !c) {

@@ -20,11 +20,11 @@ return a;

return c ? a[a.length - 1] : a.slice(b).join("\n");
}, B = (a, b = !1) => A(a, 2 + (b ? 1 : 0)), C = a => {
}, A = (a, b = !1) => z(a, 2 + (b ? 1 : 0)), B = a => {
({callee:{caller:a}} = a);
return a;
};
const {homedir:G} = os;
const H = /\s+at.*(?:\(|\s)(.*)\)?/, I = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, J = G(), K = a => {
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, f = new RegExp(I.source.replace("IGNORED_MODULES", c.join("|")));
const F = os.homedir;
const G = /\s+at.*(?:\(|\s)(.*)\)?/, H = /^(?:(?:(?:node|(?:internal\/[\w/]*|.*node_modules\/(?:IGNORED_MODULES)\/.*)?\w+)\.js:\d+:\d+)|native)/, I = F(), J = a => {
const {pretty:b = !1, ignoredModules:c = ["pirates"]} = {}, f = new RegExp(H.source.replace("IGNORED_MODULES", c.join("|")));
return a.replace(/\\/g, "/").split("\n").filter(d => {
d = d.match(H);
d = d.match(G);
if (null === d || !d[1]) {

@@ -35,22 +35,22 @@ return !0;

return d.includes(".app/Contents/Resources/electron.asar") || d.includes(".app/Contents/Resources/default_app.asar") ? !1 : !f.test(d);
}).filter(d => d.trim()).map(d => b ? d.replace(H, (e, k) => e.replace(k, k.replace(J, "~"))) : d).join("\n");
}).filter(d => d.trim()).map(d => b ? d.replace(G, (e, k) => e.replace(k, k.replace(I, "~"))) : d).join("\n");
};
function L(a, b, c = !1) {
function K(a, b, c = !1) {
return function(f) {
var d = C(arguments), {stack:e} = Error();
const k = A(e, 2, !0), l = (e = f instanceof Error) ? f.message : f;
var d = B(arguments), {stack:e} = Error();
const k = z(e, 2, !0), l = (e = f instanceof Error) ? f.message : f;
d = [`Error: ${l}`, ...null !== d && a === d || c ? [b] : [k, b]].join("\n");
d = K(d);
d = J(d);
return Object.assign(e ? f : Error(), {message:l, stack:d});
};
}
;function M(a) {
;function L(a) {
var {stack:b} = Error();
const c = C(arguments);
b = B(b, a);
return L(c, b, a);
const c = B(arguments);
b = A(b, a);
return K(c, b, a);
}
;const {parse:N} = url;
const {Writable:O} = stream;
const P = (a, b) => {
;const M = url.parse;
const N = stream.Writable;
const O = (a, b) => {
b.once("error", c => {

@@ -61,15 +61,12 @@ a.emit("error", c);

};
class Q extends O {
class P extends N {
constructor(a) {
var b = a || {}, c = Object.assign({}, b);
const f = void 0 === b.binary ? !1 : b.binary, d = void 0 === b.rs ? null : b.rs;
b = (delete c.binary, delete c.rs, c);
const {a:e = M(!0), proxyError:k} = a || {}, l = (n, q) => e(q);
super(b);
const {binary:b = !1, rs:c = null, ...f} = a || {}, {a:d = L(!0), proxyError:e} = a || {}, k = (l, m) => d(m);
super(f);
this.b = [];
this.g = new Promise((n, q) => {
this.g = new Promise((l, m) => {
this.on("finish", () => {
let g;
f ? g = Buffer.concat(this.b) : g = this.b.join("");
n(g);
b ? g = Buffer.concat(this.b) : g = this.b.join("");
l(g);
this.b = [];

@@ -79,11 +76,11 @@ });

if (-1 == g.stack.indexOf("\n")) {
l`${g}`;
k`${g}`;
} else {
const t = K(g.stack);
g.stack = t;
k && l`${g}`;
const r = J(g.stack);
g.stack = r;
e && k`${g}`;
}
q(g);
m(g);
});
d && P(this, d).pipe(this);
c && O(this, c).pipe(this);
});

@@ -99,28 +96,22 @@ }

}
const R = async(a, b) => {
b = void 0 === b ? {} : b;
({c:a} = new Q(Object.assign({}, {rs:a}, b, {a:M(!0)})));
const Q = async(a, b = {}) => {
({c:a} = new P({rs:a, ...b, a:L(!0)}));
return await a;
};
const {createGunzip:S} = zlib;
const T = a => {
({"content-encoding":a} = a.headers);
return "gzip" == a;
}, U = (a, b, c) => {
c = void 0 === c ? {} : c;
const {justHeaders:f, binary:d, a:e = M(!0)} = c;
let k, l, n, q, g = 0, t = 0;
const R = zlib.createGunzip;
const S = (a, b, c = {}) => {
const {justHeaders:f, binary:d, a:e = L(!0)} = c;
let k, l, m, g, r = 0, u = 0;
c = (new Promise((v, w) => {
k = a(b, async h => {
({headers:l} = h);
const {statusMessage:p, statusCode:r} = h;
n = {statusMessage:p, statusCode:r};
m = {statusMessage:h.statusMessage, statusCode:h.statusCode};
if (f) {
h.destroy();
} else {
var m = T(h);
h.on("data", x => g += x.byteLength);
h = m ? h.pipe(S()) : h;
q = await R(h, {binary:d});
t = q.length;
var n = "gzip" == h.headers["content-encoding"];
h.on("data", q => r += q.byteLength);
h = n ? h.pipe(R()) : h;
g = await Q(h, {binary:d});
u = g.length;
}

@@ -134,19 +125,18 @@ v();

});
})).then(() => Object.assign({}, {body:q, headers:l}, n, {h:g, byteLength:t, f:null}));
})).then(() => ({body:g, headers:l, ...m, h:r, byteLength:u, f:null}));
return {i:k, c};
};
const V = (a = {}) => Object.keys(a).reduce((b, c) => {
const T = (a = {}) => Object.keys(a).reduce((b, c) => {
const f = a[c];
c = `${encodeURIComponent(c)}=${encodeURIComponent(f)}`;
return [...b, c];
}, []).join("&").replace(/%20/g, "+"), W = async(a, b, {data:c, justHeaders:f, binary:d, a:e = M(!0)}) => {
const {i:k, c:l} = U(a, b, {justHeaders:f, binary:d, a:e});
}, []).join("&").replace(/%20/g, "+"), U = async(a, b, {data:c, justHeaders:f, binary:d, a:e = L(!0)}) => {
const {i:k, c:l} = S(a, b, {justHeaders:f, binary:d, a:e});
k.end(c);
a = await l;
({"content-type":b = ""} = a.headers);
if ((b = b.startsWith("application/json")) && a.body) {
if ((a.headers["content-type"] || "").startsWith("application/json") && a.body) {
try {
a.f = JSON.parse(a.body);
} catch (n) {
throw e = e(n), e.response = a.body, e;
} catch (m) {
throw e = e(m), e.response = a.body, e;
}

@@ -156,37 +146,36 @@ }

};
let X;
let V;
try {
const {version:a, name:b} = require("../package.json");
X = "@rqt/aqt" == b ? `@rqt/aqt/${a}` : `@rqt/aqt via ${b}/${a}`;
V = "@rqt/aqt" == b ? `@rqt/aqt/${a}` : `@rqt/aqt via ${b}/${a}`;
} catch (a) {
X = "@aqt/rqt";
V = "@aqt/rqt";
}
const Y = z("aqt");
module.exports = async(a, b) => {
b = void 0 === b ? {} : b;
const {data:c, type:f = "json", headers:d = {"User-Agent":`Mozilla/5.0 (Node.JS) ${X}`}, compress:e = !0, binary:k = !1, justHeaders:l = !1, method:n, timeout:q} = b;
b = M(!0);
const {hostname:g, protocol:t, port:v, path:w} = N(a), h = "https:" === t ? u : y, p = {hostname:g, port:v, path:w, headers:Object.assign({}, d), timeout:q, method:n};
const W = y("aqt");
module.exports = async(a, b = {}) => {
const {data:c, type:f = "json", headers:d = {"User-Agent":`Mozilla/5.0 (Node.JS) ${V}`}, compress:e = !0, binary:k = !1, justHeaders:l = !1, method:m, timeout:g} = b;
b = L(!0);
const {hostname:r, protocol:u, port:v, path:w} = M(a), h = "https:" === u ? t : x, n = {hostname:r, port:v, path:w, headers:{...d}, timeout:g, method:m};
if (c) {
var r = f;
var m = c;
switch(r) {
var q = f;
var p = c;
switch(q) {
case "json":
m = JSON.stringify(m);
r = "application/json";
p = JSON.stringify(p);
q = "application/json";
break;
case "form":
m = V(m), r = "application/x-www-form-urlencoded";
p = T(p), q = "application/x-www-form-urlencoded";
}
m = {data:m, contentType:r};
({data:r} = m);
({contentType:m} = m);
p.method = n || "POST";
"Content-Type" in p.headers || (p.headers["Content-Type"] = m);
"Content-Length" in p.headers || (p.headers["Content-Length"] = Buffer.byteLength(r));
p = {data:p, contentType:q};
({data:q} = p);
p = p.contentType;
n.method = m || "POST";
"Content-Type" in n.headers || (n.headers["Content-Type"] = p);
"Content-Length" in n.headers || (n.headers["Content-Length"] = Buffer.byteLength(q));
}
!e || "Accept-Encoding" in p.headers || (p.headers["Accept-Encoding"] = "gzip, deflate");
const {body:x, headers:Z, byteLength:D, statusCode:aa, statusMessage:ba, h:E, f:F} = await W(h, p, {data:r, justHeaders:l, binary:k, a:b});
Y("%s %s B%s", a, D, `${D != E ? ` (raw ${E} B)` : ""}`);
return {body:F ? F : x, headers:Z, statusCode:aa, statusMessage:ba};
!e || "Accept-Encoding" in n.headers || (n.headers["Accept-Encoding"] = "gzip, deflate");
const {body:X, headers:Y, byteLength:C, statusCode:Z, statusMessage:aa, h:D, f:E} = await U(h, n, {data:q, justHeaders:l, binary:k, a:b});
W("%s %s B%s", a, C, `${C != D ? ` (raw ${D} B)` : ""}`);
return {body:E ? E : X, headers:Y, statusCode:Z, statusMessage:aa};
};

@@ -193,0 +182,0 @@

@@ -5,4 +5,4 @@ const _aqt = require('./aqt')

* Request a web page and return information including `headers`, `statusCode`, `statusMessage` along with the `body` (which is also parsed if JSON received).
* @param {string} address The URL such as http://example.com/api.
* @param {_rqt.AqtOptions} [options] Configuration for requests.
* @param {string} address The URL to request data from.
* @param {!_rqt.AqtOptions} [options] Configuration for requests.
* @param {!Object} [options.data] Optional data to send to the server with the request.

@@ -16,13 +16,14 @@ * @param {string} [options.type="json"] How to send data: `json` to serialise JSON data and add _Content-Type: application/json_ header, and `form` for url-encoded transmission with _Content-Type: application/x-www-form-urlencoded_. _Multipart/form-data_ must be implemented manually. Default `json`.

* @param {boolean} [options.justHeaders=false] Whether to stop the request after response headers were received, without waiting for the data. Default `false`.
* @return {Promise<!_rqt.AqtReturn>}
*/
async function aqt(address, options) {
const res = /** @type {_rqt.AqtReturn} */ (await _aqt(address, options))
return res
return _aqt(address, options)
}
/* typal types/index.xml closure noSuppress */
module.exports = aqt
/* typal types/index.xml namespace */
/**
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders
* @typedef {_rqt.AqtOptions} AqtOptions Configuration for requests.
*/
/**
* @typedef {Object} _rqt.AqtOptions Configuration for requests.

@@ -38,11 +39,7 @@ * @prop {!Object} [data] Optional data to send to the server with the request.

*/
/**
* @typedef {import('http').OutgoingHttpHeaders} http.OutgoingHttpHeaders
*/
/* typal types/return.xml closure noSuppress */
/* typal types/return.xml namespace */
/**
* @typedef {import('http').IncomingHttpHeaders} http.IncomingHttpHeaders
* @typedef {_rqt.AqtReturn} AqtReturn The return type of the function.
*/
/**
* @typedef {Object} _rqt.AqtReturn The return type of the function.

@@ -54,6 +51,1 @@ * @prop {!(string|Object|Buffer)} body The return from the server. In case the `json` content-type was set by the server, the response will be parsed into an object. If `binary` option was used for the request, a `Buffer` will be returned. Otherwise, a string response is returned.

*/
/**
* @typedef {import('http').IncomingHttpHeaders} http.IncomingHttpHeaders
*/
module.exports = aqt
{
"name": "@rqt/aqt",
"version": "1.3.0",
"version": "1.4.0",
"description": "An Advanced Network Request Package That Returns Body (Parsed As JSON If Needed), Headers And Status After Gzip Decompression.",

@@ -11,7 +11,8 @@ "main": "compile/index.js",

"test-compile": "ALAMODE_ENV=test-compile yarn test",
"compile": "depack-dev src/depack -o compile/aqt.js -c -a -p -s --source_map_include_content",
"doc": "NODE_DEBUG=doc doc -o README.md -n _rqt",
"d": "yarn-s d1 dc",
"d1": "typal types/index.js types/externs.js",
"dc": "typal compile/index.js -c -t types/index.xml",
"compile": "depack src/depack -o compile/aqt.js -c -a -p -s --source_map_include_content",
"doc": "NODE_DEBUG=doc doc -o README.md -n _rqt -a",
"d": "yarn-s template d1 externs",
"d1": "typal compile/index.js -u",
"template": "typal compile/template.js -T compile/index.js -t types",
"externs": "typal types/externs.js -e",
"lint": "eslint .",

@@ -24,2 +25,3 @@ "e": "alanode",

"src",
"typedefs.json",
"types"

@@ -32,2 +34,3 @@ ],

},
"typedefs": "typedefs.json",
"keywords": [

@@ -51,11 +54,13 @@ "request",

"devDependencies": {
"@idio/idio": "^0.1.0",
"alamode": "^2.3.4",
"@artdeco/clean-stack": "^1.1.1",
"@idio/idio": "^1.0.1",
"alamode": "^3.3.0",
"catchment": "^3.3.0",
"documentary": "^1.27.4",
"depack": "^1.0.1",
"documentary": "^1.35.9",
"erotic": "^2.1.1",
"eslint-config-artdeco": "1.0.1",
"https-context": "^1.0.3",
"yarn-s": "1.1.0",
"zoroaster": "^4.1.1-alpha"
"yarn-s": "1.2.1",
"zoroaster": "^4.1.2"
},

@@ -62,0 +67,0 @@ "srcDependencies": [

# @rqt/aqt
[![npm version](https://badge.fury.io/js/%40rqt%2Faqt.svg)](https://npmjs.org/package/@rqt/aqt)
[![npm version](https://badge.fury.io/js/%40rqt%2Faqt.svg)](https://www.npmjs.com/package/@rqt/aqt)

@@ -8,3 +8,5 @@ `aqt` is a network request package for Node.JS that returns the body (parsed if returned as _JSON_), headers and status after _gzip_ decompression when necessary.

```console
rqt:~$ \
yarn add @rqt/aqt
npm install @rqt/aqt
```

@@ -16,3 +18,3 @@

- [API](#api)
- [`aqt(url: string, options?: AqtOptions): AqtReturn`](#aqturl-stringoptions-aqtoptions-aqtreturn)
- [`async aqt(address: string, options=: !AqtOptions): !AqtReturn`](#async-aqtaddress-stringoptions-aqtoptions-aqtreturn)
* [`AqtOptions`](#type-aqtoptions)

@@ -26,3 +28,5 @@ - [`AqtReturn` Type](#aqtreturn-type)

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/0.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents">
<img src="/.documentary/section-breaks/0.svg?sanitize=true">
</a></p>

@@ -37,6 +41,12 @@ ## API

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/1.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents">
<img src="/.documentary/section-breaks/1.svg?sanitize=true">
</a></p>
## `aqt(`<br/>&nbsp;&nbsp;`url: string,`<br/>&nbsp;&nbsp;`options?: AqtOptions,`<br/>`): AqtReturn`
## <code>async <ins>aqt</ins>(</code><sub><br/>&nbsp;&nbsp;`address: string,`<br/>&nbsp;&nbsp;`options=: !AqtOptions,`<br/></sub><code>): <i>!AqtReturn</i></code>
Request a web page and return information including `headers`, `statusCode`, `statusMessage` along with the `body` (which is also parsed if JSON received).
- <kbd><strong>address*</strong></kbd> <em>`string`</em>: The URL to request data from.
- <kbd>options</kbd> <em><code><a href="#type-aqtoptions" title="Configuration for requests.">!AqtOptions</a></code></em> (optional): The options for the request.
Makes a request to the URL, either with or without options.

@@ -58,3 +68,5 @@

<tr>
<td>Optional data to send to the server with the request.</td>
<td>
Optional data to send to the server with the request.
</td>
</tr>

@@ -68,7 +80,9 @@ <tr>

<tr>
<td>How to send data: <code>json</code> to serialise JSON data and add <em>Content-Type: application/json</em> header, and <code>form</code> for url-encoded transmission with <em>Content-Type: application/x-www-form-urlencoded</em>. <em>Multipart/form-data</em> must be implemented manually.</td>
<td>
How to send data: <code>json</code> to serialise JSON data and add <em>Content-Type: application/json</em> header, and <code>form</code> for url-encoded transmission with <em>Content-Type: application/x-www-form-urlencoded</em>. <em>Multipart/form-data</em> must be implemented manually.
</td>
</tr>
<tr>
<td rowSpan="3" align="center">headers</td>
<td><em><a href="https://nodejs.org/api/http.html#http_class_http_outgoinghttpheaders" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc.">!http.OutgoingHttpHeaders</a></em></td>
<td><em><a href="https://nodejs.org/api/http.html" title="The headers hash map for making requests, including such properties as Content-Encoding, Content-Type, etc."><img src=".documentary/type-icons/node-odd.png" alt="Node.JS Docs">!http.OutgoingHttpHeaders</a></em></td>
<td rowSpan="3">-</td>

@@ -78,3 +92,5 @@ </tr>

<tr>
<td>Headers to use for the request. By default, a single User-Agent header with <em>Mozilla/5.0 (Node.JS) aqt/{version}</em> value is set.</td>
<td>
Headers to use for the request. By default, a single User-Agent header with <em>Mozilla/5.0 (Node.JS) aqt/{version}</em> value is set.
</td>
</tr>

@@ -88,3 +104,5 @@ <tr>

<tr>
<td>Add the <code>Accept-Encoding: gzip, deflate</code> header to indicate to the server that it can send a compressed response.</td>
<td>
Add the <code>Accept-Encoding: gzip, deflate</code> header to indicate to the server that it can send a compressed response.
</td>
</tr>

@@ -98,3 +116,5 @@ <tr>

<tr>
<td>The timeout after which the request should fail.</td>
<td>
The timeout after which the request should fail.
</td>
</tr>

@@ -108,3 +128,5 @@ <tr>

<tr>
<td>What HTTP method to use in making of the request. When no method is given and <code>data</code> is present, defaults to <code>POST</code>.</td>
<td>
What HTTP method to use in making of the request. When no method is given and <code>data</code> is present, defaults to <code>POST</code>.
</td>
</tr>

@@ -118,3 +140,5 @@ <tr>

<tr>
<td>Whether to return a buffer instead of a string.</td>
<td>
Whether to return a buffer instead of a string.
</td>
</tr>

@@ -128,3 +152,5 @@ <tr>

<tr>
<td>Whether to stop the request after response headers were received, without waiting for the data.</td>
<td>
Whether to stop the request after response headers were received, without waiting for the data.
</td>
</tr>

@@ -156,3 +182,3 @@ </table>

"content-type": "text/plain",
"date": "Mon, 29 Jul 2019 16:34:16 GMT",
"date": "Tue, 07 Jan 2020 22:25:31 GMT",
"connection": "close",

@@ -168,3 +194,5 @@ "transfer-encoding": "chunked"

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/2.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents">
<img src="/.documentary/section-breaks/2.svg?sanitize=true">
</a></p>

@@ -245,3 +273,5 @@ ## `AqtReturn` Type

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/3.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents">
<img src="/.documentary/section-breaks/3.svg?sanitize=true">
</a></p>

@@ -258,3 +288,3 @@ ## Copyright

</th>
<th>© <a href="https://artd.eco">Art Deco</a> for <a href="http://rqt.biz">Rqt</a> 2019</th>
<th>© <a href="https://artd.eco">Art Deco</a> for <a href="http://rqt.biz">Rqt</a> 2020</th>
<th>

@@ -270,2 +300,4 @@ <a href="https://www.technation.sucks" title="Tech Nation Visa">

<p align="center"><a href="#table-of-contents"><img src="/.documentary/section-breaks/-1.svg?sanitize=true"></a></p>
<p align="center"><a href="#table-of-contents">
<img src="/.documentary/section-breaks/-1.svg?sanitize=true">
</a></p>

@@ -66,3 +66,3 @@ import erotic from 'erotic'

*/
const { 'content-type': contentType = '' } = headers
const contentType = headers['content-type'] || ''
return contentType.startsWith('application/json')

@@ -69,0 +69,0 @@ }

@@ -13,3 +13,3 @@ import erotic from 'erotic'

*/
const { 'content-encoding': contentEncoding } = res.headers
const contentEncoding = res.headers['content-encoding']
return contentEncoding == 'gzip'

@@ -16,0 +16,0 @@ }

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc