Skip to content

Commit

Permalink
remove lodash dependency
Browse files Browse the repository at this point in the history
  • Loading branch information
eshanholtz committed Mar 13, 2020
1 parent f47f1ef commit 2206818
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 63 deletions.
3 changes: 0 additions & 3 deletions packages/helpers/classes/request.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,4 @@ declare namespace Request {

export default class Request<TData = any> {
constructor(opts: Request.RequestOptions<TData>);
private attributeEqual(lhs: any, rhs: any): boolean;
isEqual(other: Request<any>): boolean;
toString(): string;
}
60 changes: 0 additions & 60 deletions packages/helpers/classes/request.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
'use strict';

var _ = require('lodash');

class Request {
constructor(opts) {
opts = opts || {};
Expand All @@ -14,64 +12,6 @@ class Request {
this.data = opts.data || this.ANY;
this.headers = opts.headers || this.ANY;
}

attributeEqual(lhs, rhs) {
if (lhs === this.ANY || rhs === this.ANY) {
return true;
}

lhs = lhs || undefined;
rhs = rhs || undefined;

return _.isEqual(lhs, rhs);
}

isEqual(other) {
return (attributeEqual(this.method, other.method) &&
attributeEqual(this.url, other.url) &&
attributeEqual(this.auth, other.auth) &&
attributeEqual(this.params, other.params) &&
attributeEqual(this.data, other.data) &&
attributeEqual(this.headers, other.headers));
}

toString() {
var auth = '';
if (this.auth && this.auth !== this.ANY) {
auth = this.auth + ' ';
}

var params = '';
if (this.params && this.params !== this.ANY) {
params = '?' + _.join(_.chain(_.keys(this.params))
.map(function(key) {
return key + '=' + this.params[key];
}.bind(this))
.value(), '&');
}

var data = '';
if (this.data && this.data !== this.ANY) {
if (this.method === 'GET') {
data = '\n -G';
}

data = data + '\n' + _.join(
_.map(this.data, function(value, key) {
return ' -d ' + key + '=' + value;
}), '\n');
}

var headers = '';
if (this.headers && this.headers !== this.ANY) {
headers = '\n' + _.join(
_.map(this.headers, function(value, key) {
return ' -H ' + key + '=' + value;
}), '\n');
}

return auth + this.method + ' ' + this.url + params + data + headers;
}
}

module.exports = Request;

0 comments on commit 2206818

Please sign in to comment.