Add overload to getHandiworkInformation
parent
ffe9271bcf
commit
f4af0c43f1
|
@ -17,13 +17,22 @@ import { ILink, IPostElement } from "./post-parse.js";
|
||||||
*
|
*
|
||||||
* @todo It does not currently support assets.
|
* @todo It does not currently support assets.
|
||||||
*/
|
*/
|
||||||
export default async function getHandiworkInformation<T extends IBasic>(url: string): Promise<T> {
|
export async function getHandiworkInformation<T extends IBasic>(url: string): Promise<T>
|
||||||
shared.logger.info(`Obtaining handiwork from ${url}`);
|
|
||||||
|
|
||||||
|
export async function getHandiworkInformation<T extends IBasic>(url: string): Promise<T>
|
||||||
|
|
||||||
|
export default async function getHandiworkInformation<T extends IBasic>(arg: string | Thread): Promise<T> {
|
||||||
|
// Local variables
|
||||||
|
let thread: Thread = null;
|
||||||
|
|
||||||
|
if (typeof arg === "string") {
|
||||||
// Fetch thread data
|
// Fetch thread data
|
||||||
const id = extractIDFromURL(url);
|
const id = extractIDFromURL(arg);
|
||||||
const thread: Thread = new Thread(id);
|
thread = new Thread(id);
|
||||||
await thread.fetch();
|
await thread.fetch();
|
||||||
|
} else thread = arg;
|
||||||
|
|
||||||
|
shared.logger.info(`Obtaining handiwork from ${thread.url}`);
|
||||||
|
|
||||||
// Convert the info from thread to handiwork
|
// Convert the info from thread to handiwork
|
||||||
const hw: HandiWork = {} as HandiWork;
|
const hw: HandiWork = {} as HandiWork;
|
||||||
|
@ -42,7 +51,7 @@ export default async function getHandiworkInformation<T extends IBasic>(url: str
|
||||||
fillWithPostData(hw, post.body);
|
fillWithPostData(hw, post.body);
|
||||||
|
|
||||||
return <T><unknown>hw;
|
return <T><unknown>hw;
|
||||||
};
|
}
|
||||||
|
|
||||||
//#region Private methods
|
//#region Private methods
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue