From 22068186da90d69dffe5377ad3dce2a6bc10f59a Mon Sep 17 00:00:00 2001 From: Elise Shanholtz Date: Fri, 13 Mar 2020 10:19:39 -0700 Subject: [PATCH] remove lodash dependency --- packages/helpers/classes/request.d.ts | 3 -- packages/helpers/classes/request.js | 60 --------------------------- 2 files changed, 63 deletions(-) diff --git a/packages/helpers/classes/request.d.ts b/packages/helpers/classes/request.d.ts index 1af6cc882..3a475d9ef 100644 --- a/packages/helpers/classes/request.d.ts +++ b/packages/helpers/classes/request.d.ts @@ -14,7 +14,4 @@ declare namespace Request { export default class Request { constructor(opts: Request.RequestOptions); - private attributeEqual(lhs: any, rhs: any): boolean; - isEqual(other: Request): boolean; - toString(): string; } diff --git a/packages/helpers/classes/request.js b/packages/helpers/classes/request.js index f11eb92c8..edefd30db 100644 --- a/packages/helpers/classes/request.js +++ b/packages/helpers/classes/request.js @@ -1,7 +1,5 @@ 'use strict'; -var _ = require('lodash'); - class Request { constructor(opts) { opts = opts || {}; @@ -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;