From 07c37e2c06c37df3a4fa57333e0d51c648477d8c Mon Sep 17 00:00:00 2001 From: Ethan Lane Date: Fri, 15 Sep 2023 15:15:34 +0100 Subject: [PATCH] Add default value to sortBy variable (#87) # Description - Add default value to the sortBy variable ('hot') #50 ## Type of change Please delete options that are not relevant. - [x] New feature (non-breaking change which adds functionality) # How Has This Been Tested? Please describe the tests that you ran to verify the changes. Provide instructions so we can reproduce. Please also list any relevant details to your test configuration. # Checklist - [ ] My code follows the style guidelines of this project - [ ] I have performed a self-review of my own code - [ ] I have commented my code, particularly in hard-to-understand areas - [ ] I have made corresponding changes to the documentation - [ ] My changes generate no new warnings - [ ] I have added tests that provde my fix is effective or that my feature works - [ ] New and existing unit tests pass locally with my changes - [ ] Any dependent changes have been merged and published in downstream modules Reviewed-on: https://gitea.vylpes.xyz/RabbitLabs/random-bunny/pulls/87 Co-authored-by: Ethan Lane Co-committed-by: Ethan Lane --- src/index.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/index.ts b/src/index.ts index 400567e..f6e7b3c 100644 --- a/src/index.ts +++ b/src/index.ts @@ -10,8 +10,8 @@ const sortable = [ 'top' ]; -export default async function randomBunny(subreddit: string, sortBy?: string): Promise { - if (!sortBy || !sortable.includes(sortBy)) sortBy = 'hot'; +export default async function randomBunny(subreddit: string, sortBy: string = 'hot'): Promise { + if (!sortable.includes(sortBy)) sortBy = 'hot'; const result = await fetch(`https://reddit.com/r/${subreddit}/${sortBy}.json`);