@raycast/utils
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -24,2 +24,3 @@ import type { Image } from "@raycast/api"; | ||
}): Image.Asset; | ||
export declare function singletonPromise<T>(promise: () => Promise<T>): T | Promise<T>; | ||
//# sourceMappingURL=avatar.d.ts.map |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.getAvatarIcon = void 0; | ||
exports.singletonPromise = exports.getAvatarIcon = void 0; | ||
const color_1 = require("./color"); | ||
@@ -114,1 +114,20 @@ function getWholeCharAndI(str, i) { | ||
exports.getAvatarIcon = getAvatarIcon; | ||
const cache = new Map(); | ||
function singletonPromise(promise) { | ||
const cached = cache.get(promise); | ||
if (cached) { | ||
return cached.result || cached.inFlight; | ||
} | ||
const inFlight = promise() | ||
.then((result) => { | ||
cache.set(promise, { result }); | ||
return result; | ||
}) | ||
.catch((err) => { | ||
cache.delete(promise); | ||
throw err; | ||
}); | ||
cache.set(promise, { inFlight }); | ||
return inFlight; | ||
} | ||
exports.singletonPromise = singletonPromise; |
@@ -167,7 +167,8 @@ "use strict"; | ||
const reset = (0, react_1.useCallback)((initialValues = {}) => { | ||
setErrors(initialValues); | ||
setValues; | ||
}, []); | ||
// @ts-expect-error it's fine if we don't specify all the values | ||
setValues(initialValues); | ||
setErrors({}); | ||
}, [setValues, setErrors]); | ||
return { handleSubmit, setValidationError, setValue, values, itemProps, focus, reset }; | ||
} | ||
exports.useForm = useForm; |
{ | ||
"name": "@raycast/utils", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "Set of utilities to streamline building Raycast extensions", | ||
@@ -5,0 +5,0 @@ "author": "Raycast Technologies Ltd.", |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
108059
2363