Skip to content

Commit e3d4ef3

Browse files
authored
refactor: replace lodash isArray + assign (#2236)
- replace lodash.isArray for native Array.isArray - replace lodash.assign for native object destructuring or Object.assign Refs #2187
1 parent af2b86c commit e3d4ef3

File tree

4 files changed

+5
-9
lines changed

4 files changed

+5
-9
lines changed

src/execute/index.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import getIn from 'lodash/get';
22
import isPlainObject from 'lodash/isPlainObject';
3-
import isArray from 'lodash/isArray';
43
import url from 'url';
54
import cookie from 'cookie';
65

@@ -77,7 +76,7 @@ export function execute({
7776
...extras,
7877
});
7978

80-
if (request.body && (isPlainObject(request.body) || isArray(request.body))) {
79+
if (request.body && (isPlainObject(request.body) || Array.isArray(request.body))) {
8180
request.body = JSON.stringify(request.body);
8281
}
8382

src/execute/oas3/build-request.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// This function runs after the common function,
22
// `src/execute/index.js#buildRequest`
3-
import assign from 'lodash/assign';
43
import get from 'lodash/get';
54
import isPlainObject from 'lodash/isPlainObject';
65
import btoa from 'btoa';
@@ -88,7 +87,7 @@ export default function buildRequest(options, req) {
8887
// Add security values, to operations - that declare their need on them
8988
// Adapted from the Swagger2 implementation
9089
export function applySecurities({ request, securities = {}, operation = {}, spec }) {
91-
const result = assign({}, request);
90+
const result = { ...request };
9291
const { authorized = {} } = securities;
9392
const security = operation.security || spec.security || [];
9493
const isAuthorized = authorized && !!Object.keys(authorized).length;

src/execute/swagger2/build-request.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
import btoa from 'btoa';
2-
import assign from 'lodash/assign';
32

43
// This function runs after the common function,
54
// `src/execute/index.js#buildRequest`
@@ -57,7 +56,7 @@ export default function buildRequest(options, req) {
5756

5857
// Add security values, to operations - that declare their need on them
5958
export function applySecurities({ request, securities = {}, operation = {}, spec }) {
60-
const result = assign({}, request);
59+
const result = { ...request };
6160
const { authorized = {}, specSecurity = [] } = securities;
6261
const security = operation.security || specSecurity;
6362
const isAuthorized = authorized && !!Object.keys(authorized).length;

src/index.js

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import assign from 'lodash/assign';
21
import startsWith from 'lodash/startsWith';
32
import Url from 'url';
43

@@ -34,11 +33,11 @@ function Swagger(url, opts = {}) {
3433
return new Swagger(opts);
3534
}
3635

37-
assign(this, opts);
36+
Object.assign(this, opts);
3837

3938
const prom = this.resolve().then(() => {
4039
if (!this.disableInterfaces) {
41-
assign(this, Swagger.makeApisTagOperation(this));
40+
Object.assign(this, Swagger.makeApisTagOperation(this));
4241
}
4342
return this;
4443
});

0 commit comments

Comments
 (0)