Function createEmptyCard

  • Create an empty card

    Type Parameters

    Parameters

    • Optionalnow: DateInput

      Current time

    • OptionalafterHandler: ((card: Card) => R)

      Convert the result to another type. (Optional)

        • (card): R
        • Parameters

          Returns R

    Returns R

    const card: Card = createEmptyCard(new Date());
    
    interface CardUnChecked
    extends Omit<Card, "due" | "last_review" | "state"> {
    cid: string;
    due: Date | number;
    last_review: Date | null | number;
    state: StateType;
    }

    function cardAfterHandler(card: Card) {
    return {
    ...card,
    cid: "test001",
    state: State[card.state],
    last_review: card.last_review ?? null,
    } as CardUnChecked;
    }

    const card: CardUnChecked = createEmptyCard(new Date(), cardAfterHandler);