diff --git a/CHANGELOG.md b/CHANGELOG.md index f250ade..74fa765 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,10 @@ +# [0.6.0](https://github.com/suzuki3jp/youtubes.js/compare/v0.5.0...v0.6.0) (2025-01-28) + + +### Features + +* Migrate from result4js to neverthrow ([f1e3c5a](https://github.com/suzuki3jp/youtubes.js/commit/f1e3c5acbde71c5f2c2b690ab88eb6c2d5da8e1c)) + # [0.5.0](https://github.com/suzuki3jp/youtubes.js/compare/v0.4.5...v0.5.0) (2025-01-22) diff --git a/docs/api/youtubes.js.pagination.all.md b/docs/api/youtubes.js.pagination.all.md index 2c66155..14ec4cd 100644 --- a/docs/api/youtubes.js.pagination.all.md +++ b/docs/api/youtubes.js.pagination.all.md @@ -32,8 +32,11 @@ const oauth = new StaticOAuthProvider({ }); const client = new ApiClient({ oauth }); -// THIS IS UNSAFE ERROR HANDLING. See the safe error handling in the README.md Introduction. -const playlists = (await client.playlists.getMine()).throw(); -const allPlaylists = (await playlists.all()).throw().flat(); +const playlists = await client.playlists.getMine(); +if (playlists.isErr()) { + // Handle the error + return; +} +const allPlaylists = (await playlists.all()).flat(); ``` diff --git a/docs/api/youtubes.js.pagination.next.md b/docs/api/youtubes.js.pagination.next.md index b47c559..3c0659b 100644 --- a/docs/api/youtubes.js.pagination.next.md +++ b/docs/api/youtubes.js.pagination.next.md @@ -32,11 +32,11 @@ const oauth = new StaticOAuthProvider({ }); const client = new ApiClient({ oauth }); - -// THIS IS UNSAFE ERROR HANDLING. See the safe error handling in the README.md Introduction. -const playlists = (await client.playlists.getMine()).throw(); -console.log(playlists.data); // The first page of playlists -const nextPage = (await playlists.next()).throw(); -console.log(nextPage?.data); // The second page of playlists or null if there is no next page +const playlists = await client.playlists.getMine(); +if (playlists.isErr()) return; +console.log(playlists.value); // The first page of playlists +const nextPage = await playlists.next(); +if (nextPage?.isErr()) return; +console.log(nextPage?.value); // The second page of playlists or null if there is no next page ``` diff --git a/docs/api/youtubes.js.pagination.prev.md b/docs/api/youtubes.js.pagination.prev.md index 89bec5f..6a204b6 100644 --- a/docs/api/youtubes.js.pagination.prev.md +++ b/docs/api/youtubes.js.pagination.prev.md @@ -32,11 +32,11 @@ const oauth = new StaticOAuthProvider({ }); const client = new ApiClient({ oauth }); - -// THIS IS UNSAFE ERROR HANDLING. See the safe error handling in the README.md Introduction. -const playlists = (await client.playlists.getMine()).throw(); -console.log(playlists.data); // The first page of playlists -const prevPage = (await playlists.prev()).throw(); -console.log(prevPage?.data); // The previous page of playlists or null if there is no previous page +const playlists = await client.playlists.getMine(); +if (playlists.isErr()) return; +console.log(playlists.value); // The first page of playlists +const prevPage = await playlists.prev(); +if (prevPage?.isErr()) return; +console.log(prevPage?.value); // The previous page of playlists or null if there is no previous page ``` diff --git a/docs/api/youtubes.js.playlistmanager.getbychannelid.md b/docs/api/youtubes.js.playlistmanager.getbychannelid.md index 6092b50..746cb1e 100644 --- a/docs/api/youtubes.js.playlistmanager.getbychannelid.md +++ b/docs/api/youtubes.js.playlistmanager.getbychannelid.md @@ -83,8 +83,6 @@ const oauth = new StaticOAuthProvider({ accessToken: "ACCESS_TOKEN", }); const client = new ApiClient({ oauth }); - -// THIS IS UNSAFE ERROR HANDLING. See the safe error handling in the README.md Introduction. -const playlists = (await client.playlists.getByChannelId("CHANNEL_ID")).throw(); // Pagination +const playlists = await client.playlists.getByChannelId("CHANNEL_ID"); // Result, YouTubesJsErrors> ``` diff --git a/docs/api/youtubes.js.playlistmanager.getbyids.md b/docs/api/youtubes.js.playlistmanager.getbyids.md index 3fb1166..54a1ae4 100644 --- a/docs/api/youtubes.js.playlistmanager.getbyids.md +++ b/docs/api/youtubes.js.playlistmanager.getbyids.md @@ -83,8 +83,6 @@ const oauth = new StaticOAuthProvider({ accessToken: "ACCESS_TOKEN", }); const client = new ApiClient({ oauth }); - -// THIS IS UNSAFE ERROR HANDLING. See the safe error handling in the README.md Introduction. -const playlists = (await client.playlists.getByIds(["ID1", "ID2"])).throw(); // Pagination +const playlists = await client.playlists.getByIds(["ID1", "ID2"]) // Result, YouTubesJsErrors> ``` diff --git a/docs/api/youtubes.js.playlistmanager.getmine.md b/docs/api/youtubes.js.playlistmanager.getmine.md index 156dc70..240d78d 100644 --- a/docs/api/youtubes.js.playlistmanager.getmine.md +++ b/docs/api/youtubes.js.playlistmanager.getmine.md @@ -68,7 +68,6 @@ const oauth = new StaticOAuthProvider({ }); const client = new ApiClient({ oauth }); -// THIS IS UNSAFE ERROR HANDLING. See the safe error handling in the README.md Introduction. -const playlists = (await client.playlists.getMine()).throw(); // Pagination +const playlists = await client.playlists.getMine(); // Result, YouTubesJsErrors> ``` diff --git a/package-lock.json b/package-lock.json index 916eacc..cf53fe0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "youtubes.js", - "version": "0.5.0", + "version": "0.6.0", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "youtubes.js", - "version": "0.5.0", + "version": "0.6.0", "license": "MIT", "dependencies": { "googleapis": "^144.0.0", diff --git a/package.json b/package.json index a54a2bd..709bca1 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "youtubes.js", "description": "A JavaScript client for YouTube Data API v3.", - "version": "0.5.0", + "version": "0.6.0", "main": "dist/index.js", "types": "dist/index.d.ts", "keywords": [