Skip to content

Commit

Permalink
refactor: replace lodash isObject/isPlainObject with alternatives (#2309
Browse files Browse the repository at this point in the history
)

Refs #2187
  • Loading branch information
gabrielsimongianotti authored Nov 10, 2021
1 parent 7d8792c commit 067229e
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 6 deletions.
5 changes: 5 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,7 @@
"fast-json-patch": "^3.0.0-1",
"form-data-encoder": "^1.4.3",
"formdata-node": "^4.0.0",
"is-plain-object": "^5.0.0",
"js-yaml": "^4.1.0",
"lodash": "^4.17.21",
"qs": "^6.9.4",
Expand Down
2 changes: 1 addition & 1 deletion src/execute/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import getIn from 'lodash/get';
import isPlainObject from 'lodash/isPlainObject';
import url from 'url';
import cookie from 'cookie';
import { isPlainObject } from 'is-plain-object';

import stockHttp, { mergeInQueryOrForm } from '../http/index.js';
import createError from '../specmap/lib/create-error.js';
Expand Down
2 changes: 1 addition & 1 deletion src/execute/oas3/build-request.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// This function runs after the common function,
// `src/execute/index.js#buildRequest`
import { isPlainObject } from 'is-plain-object';
import get from 'lodash/get';
import isPlainObject from 'lodash/isPlainObject';
import btoa from 'btoa';

export default function buildRequest(options, req) {
Expand Down
6 changes: 2 additions & 4 deletions src/helpers.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
import isObject from 'lodash/isObject';

const toLower = (str) => String.prototype.toLowerCase.call(str);
const escapeString = (str) => str.replace(/[^\w]/gi, '_');

Expand Down Expand Up @@ -136,7 +134,7 @@ export function normalizeSwagger(parsedSpec) {
for (const pathName in paths) {
const path = paths[pathName];

if (!isObject(path)) {
if (path == null || !['object', 'function'].includes(typeof path)) {
continue; // eslint-disable-line no-continue
}

Expand All @@ -145,7 +143,7 @@ export function normalizeSwagger(parsedSpec) {
// eslint-disable-next-line no-restricted-syntax, guard-for-in
for (const method in path) {
const operation = path[method];
if (!isObject(operation)) {
if (path == null || !['object', 'function'].includes(typeof path)) {
continue; // eslint-disable-line no-continue
}

Expand Down

0 comments on commit 067229e

Please sign in to comment.