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

muhb

Package Overview
Dependencies
Maintainers
1
Versions
39
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

muhb - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

53

lib/index.js
const http = require('http');
const assert = require('assert');

@@ -31,2 +32,48 @@ function request(url, headers, method, data){

class Suite{
constructor(response){
this.response = response;
}
status(s){
let status = this.response.status;
switch(typeof s){
case 'number': assert.deepEqual(s, status); break;
}
return this;
}
json(cb){
let body = JSON.parse(this.response.body);
assert(cb(body));
return this;
}
}
class Endpoint{
constructor(method, url){
this.method = method;
this.url = url;
}
async query(params, headersOrBody, body){
let oldURL = this.url;
this.url += '?' + params;
let r = await this.reach(headersOrBody, body);
this.url = oldURL;
return r;
}
async reach(headersOrBody, body){
body = body || headersOrBody;
let r = await request(this.url, headersOrBody, this.method, body);
return new Suite(r);
}
}
module.exports = {

@@ -64,3 +111,7 @@ get(url, headers){

request: request
request: request,
Endpoint: Endpoint
};
module.exports.del = module.exports.delete;

2

package.json
{
"name": "muhb",
"version": "0.0.1",
"version": "0.0.2",
"description": "A simple set of functions for coding easy to read HTTP requests.",

@@ -5,0 +5,0 @@ "main": "lib/index.js",

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