Skip to content

Instantly share code, notes, and snippets.

@HenriqueSilverio
Created June 13, 2022 12:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save HenriqueSilverio/580ce4a970041bb621d1b7777c3d8a8f to your computer and use it in GitHub Desktop.
Save HenriqueSilverio/580ce4a970041bb621d1b7777c3d8a8f to your computer and use it in GitHub Desktop.
function run(opts) {
const result = {}
if (isPlainObject(opts?.tags) === false || isPlainEmptyObject(opts?.tags)) {
result.tags = {}
result.tags.latest = null
} else {
if (opts.tags.latest === undefined) {
result.tags = {
latest: null,
...opts.tags,
}
}
}
return result
}
function isPlainObject(value) {
if (!value) return false
return Object.getPrototypeOf(value) === Object.prototype
}
function isPlainEmptyObject(value) {
if (!isPlainObject(value)) return false
if (Object.keys(value).length === 0) return true
return false
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment