This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Calls `callback`, catches any errors and returns `returnValue | Error` | |
* | |
* TODO: create npm package | |
* | |
* See: https://dev.to/devinrhode2/comment/1fcga | |
*/ | |
export const safeCall = < | |
TCallback extends ( | |
...args: unknown[] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { execaCommandSync } from 'execa' | |
/** @type {(cmdString: string, debug?: 'debug') => [string | undefined, string | unknown]} */ | |
export const exec = (cmdString, debug) => { | |
let exception | |
let result | |
try { | |
result = execaCommandSync(cmdString, { | |
env: { | |
// @ts-expect-error - not application code |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { useCallback, useState } from "react"; | |
import { z, ZodType } from "zod"; | |
type Value<S extends ZodType> = z.infer<S>; | |
type ValueSetter<S extends ZodType> = (currentValue: Value<S>) => void; | |
type UseZodls<S extends ZodType> = [ | |
/** | |
* The current value of the data from local storage | |
* Will default to the defaultValue if not found in local storage |
OlderNewer