Skip to content

Commit

Permalink
refactor: drop isTruthy; use Predicate module
Browse files Browse the repository at this point in the history
  • Loading branch information
patroza committed Dec 7, 2023
1 parent 1963df6 commit 169ccb0
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .changeset/chatty-tomatoes-taste.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"@effect-app/infra-adapters": minor
"@effect-app/core": minor
---

drop isTruthy; use Predicate module
1 change: 0 additions & 1 deletion packages/core/_src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ export function toString(v: unknown) {
return `${v}`
}

export const isTruthy = <T>(item: T | null | undefined): item is T => Boolean(item)
export const typedKeysOf = <T extends {}>(obj: T) => Object.keys(obj) as (keyof T)[]
// eslint-disable-next-line @typescript-eslint/no-unnecessary-type-assertion
export const typedValuesOf = <T extends {}>(obj: T) => Object.values(obj) as ValueOf<T>[]
Expand Down
4 changes: 2 additions & 2 deletions packages/infra-adapters/_src/CUPS/live.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import cp from "child_process"
import util from "util"
import { tempFile } from "../fileUtil.js"

import { isTruthy, pretty } from "@effect-app/core/utils"
import { pretty } from "@effect-app/core/utils"
import { NonEmptyString255 } from "@effect-app/schema"
import fs from "fs"
import os from "os"
Expand Down Expand Up @@ -92,7 +92,7 @@ function getAvailablePrinters(host?: string) {
const { stdout } = $(exec(["lpstat", ...buildListArgs({ host }), "-s"].join(" ")))
return [...stdout.matchAll(/device for (\w+):/g)]
.map((_) => _[1])
.filter(isTruthy)
.filter(Predicate.isNotNullable)
.map(NonEmptyString255)
})
}
Expand Down

0 comments on commit 169ccb0

Please sign in to comment.