Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Drop support for String constructor #1873

Merged
merged 3 commits into from Feb 11, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 1 addition & 3 deletions lib/back.js
@@ -1,7 +1,6 @@
'use strict'

const assert = require('assert')
const _ = require('lodash')
const recorder = require('./recorder')
const {
activate,
Expand Down Expand Up @@ -61,8 +60,7 @@ function Back(fixtureName, options, nockedFn) {
)
}

// TODO-12.x: Replace with `typeof fixtureName === 'string'`.
if (!_.isString(fixtureName)) {
if (typeof fixtureName !== 'string') {
throw new Error('Parameter fixtureName must be a string')
}

Expand Down
9 changes: 3 additions & 6 deletions lib/common.js
Expand Up @@ -174,8 +174,7 @@ function stringifyRequest(options, body) {

function isContentEncoded(headers) {
const contentEncoding = headers['content-encoding']
// TODO-12.x: Replace with `typeof contentEncoding === 'string'`.
return _.isString(contentEncoding) && contentEncoding !== ''
return typeof contentEncoding === 'string' && contentEncoding !== ''
}

function contentEncoding(headers, encoder) {
Expand Down Expand Up @@ -364,8 +363,7 @@ function deleteHeadersField(headers, fieldNameToDelete) {
throw Error('headers must be an object')
}

// TODO-12.x: Replace with `typeof fieldNameToDelete !== 'string'`.
if (!_.isString(fieldNameToDelete)) {
if (typeof fieldNameToDelete !== 'string') {
throw Error('field name must be a string')
}

Expand Down Expand Up @@ -446,8 +444,7 @@ function formatQueryValue(key, value, stringFormattingFn) {
case value === undefined:
value = ''
break
// TODO-12.x: Replace with `typeof value === 'string'`.
case _.isString(value):
case typeof value === 'string':
if (stringFormattingFn) {
value = stringFormattingFn(value)
}
Expand Down
4 changes: 1 addition & 3 deletions lib/intercept.js
Expand Up @@ -8,7 +8,6 @@ const { InterceptedRequestRouter } = require('./intercepted_request_router')
const common = require('./common')
const { inherits } = require('util')
const http = require('http')
const _ = require('lodash')
const debug = require('debug')('nock.intercept')
const globalEmitter = require('./global_emitter')

Expand Down Expand Up @@ -52,8 +51,7 @@ let allowNetConnect
* nock.enableNetConnect(/(google|amazon)/);
*/
function enableNetConnect(matcher) {
// TODO-12.x: Replace with `typeof matcher === 'string'`.
if (_.isString(matcher)) {
if (typeof matcher === 'string') {
allowNetConnect = new RegExp(matcher)
} else if (matcher instanceof RegExp) {
allowNetConnect = matcher
Expand Down