Skip to content
This repository has been archived by the owner on May 22, 2024. It is now read-only.

Commit

Permalink
chore: replace removeFalsy with the more idiomatic removeUndefined (#756
Browse files Browse the repository at this point in the history
)

context: #753 (comment)

Co-authored-by: Netlify Team Account 1 <netlify-team-account-1@users.noreply.github.com>
Co-authored-by: kodiakhq[bot] <49736102+kodiakhq[bot]@users.noreply.github.com>
  • Loading branch information
3 people authored Oct 21, 2021
1 parent 776545e commit 4167cfc
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 17 deletions.
11 changes: 7 additions & 4 deletions src/utils/format_result.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,18 @@
import { FunctionArchive } from '../function'
import { RuntimeName } from '../runtimes/runtime'

import { removeFalsy } from './remove_falsy'
import { removeUndefined } from './remove_undefined'

type FunctionResult = FunctionArchive & { runtime: RuntimeName }
type FunctionResult = Omit<FunctionArchive, 'runtime'> & { runtime: RuntimeName }

// Takes the result of zipping a function and formats it for output.
const formatZipResult = (archive: FunctionArchive) => {
const result = removeFalsy({ ...archive, runtime: archive.runtime.name }) as FunctionResult
const functionResult: FunctionResult = {
...archive,
runtime: archive.runtime.name,
}

return result
return removeUndefined(functionResult)
}

export { formatZipResult }
Expand Down
13 changes: 0 additions & 13 deletions src/utils/remove_falsy.ts

This file was deleted.

7 changes: 7 additions & 0 deletions src/utils/remove_undefined.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import filterObj from 'filter-obj'

const removeUndefined = function <T>(obj: T): T {
return filterObj(obj, (key, value) => value !== undefined) as T
}

export { removeUndefined }

1 comment on commit 4167cfc

@github-actions
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⏱ Benchmark results

largeDepsEsbuild: 7.8s

largeDepsNft: 50.3s

largeDepsZisi: 1m 7.3s

Please sign in to comment.