parseCollection関数
リファレンスの説明と例は英語です。見出しと目次は日本語です。
Check a collection and make it the shape the element draws: an array of cards, or an object with a cards array. A card without an id is numbered by its place.
インポート
import { parseCollection } from "@johnmorrisdotca/fuda-cards/collection";
定義
function parseCollection(input: unknown): CollectionCard[]
引数
| 名前 | 型 | 説明 |
|---|---|---|
input | unknown | An array of items, or |
戻り値
CollectionCard[]
A new array of cards; the input is not changed.
例
import { parseCollection } from "@johnmorrisdotca/fuda-cards/collection";
console.log(parseCollection([{ name: "Card", image: "front.jpg" }])); // [ { id: '0', name: 'Card', image: 'front.jpg' } ]
try {
parseCollection([{ name: "Card" }]);
} catch (error) {
console.log((error as Error).message); // Card 1 needs a name and image URL.
}[ { id: '0', name: 'Card', image: 'front.jpg' } ]
Card 1 needs a name and image URL.出力(このページを作ったときに実行した結果)
この日本語は、まだ日本語を母語とする方の確認を受けていません。訂正を歓迎します。