Skip to content
This repository was archived by the owner on Oct 10, 2022. It is now read-only.

Commit 69b39fe

Browse files
committed
Remove existy helper function
1 parent 1b2815d commit 69b39fe

File tree

4 files changed

+6
-12
lines changed

4 files changed

+6
-12
lines changed

src/deploy/util.js

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,9 @@ const path = require('path')
33
const pWaitFor = require('p-wait-for')
44
const flatten = require('lodash.flatten')
55

6-
function existy(x) {
7-
return x != null
8-
}
9-
106
// Default filter when scanning for files
117
exports.defaultFilter = filename => {
12-
if (!existy(filename)) return false
8+
if (filename == null) return false
139
const n = path.basename(filename)
1410
switch (true) {
1511
case n === 'node_modules':

src/index.test.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ const body = promisify(require('body'))
66
const fromString = require('from2-string')
77
const { TextHTTPError } = require('micro-api-client')
88

9-
const { existy, unixNow } = require('./open-api/util')
9+
const { unixNow } = require('./open-api/util')
1010

1111
const NetlifyAPI = require('./index')
1212

@@ -254,7 +254,7 @@ test.serial('test rate-limiting', async t => {
254254

255255
try {
256256
server = createServer(async (req, res) => {
257-
if (!existy(retryAt)) {
257+
if (retryAt == null) {
258258
retryAt = unixNow() + randomInt(1, 5) //ms
259259

260260
requestRateLimit(res, retryAt)

src/open-api/index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const { JSONHTTPError, TextHTTPError } = require('micro-api-client')
1010
const debug = require('debug')('netlify:open-api')
1111
const isStream = require('is-stream')
1212

13-
const { existy, sleep, unixNow } = require('./util')
13+
const { sleep, unixNow } = require('./util')
1414

1515
exports.methods = require('./shape-swagger')
1616

@@ -29,7 +29,7 @@ exports.generateMethod = method => {
2929
// Path parameters
3030
Object.values(method.parameters.path).forEach(param => {
3131
const val = params[param.name] || params[camelCase(param.name)]
32-
if (existy(val)) {
32+
if (val != null) {
3333
path = path.replace(`{${param.name}}`, val)
3434
debug(`replacing {${param.name}} with ${val}`)
3535
} else if (param.required) {
@@ -41,7 +41,7 @@ exports.generateMethod = method => {
4141
let qs
4242
Object.values(method.parameters.query).forEach(param => {
4343
const val = params[param.name] || params[camelCase(param.name)]
44-
if (existy(val)) {
44+
if (val != null) {
4545
if (!qs) qs = {}
4646
qs[param.name] = val
4747
} else if (param.required) {

src/open-api/util.js

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,6 @@ exports.mergeParams = (...params) => {
3030
return merged
3131
}
3232

33-
exports.existy = val => val != null
34-
3533
// Async sleep. A whole new WORLD!
3634
exports.sleep = ms => new Promise(resolve => setTimeout(resolve, ms))
3735

0 commit comments

Comments
 (0)