UNPKG

dog-breeds-group

Version:

A library to find dog breed groups

143 lines (100 loc) 5.71 kB
# Dog Breeds Group Library A JavaScript library that helps you determine which dog breed belongs to which group, based on the FCI classification system. This library categorizes dog breeds into 10 groups, such as Sheepdogs, Terriers, Sighthounds, and more. ## Features - Find the group of a specific dog breed. - Find all breeds in a specific group. - Supports 10 different groups of dog breeds. - Simple to use and easy to integrate into any JavaScript project. ## Installation You can install this package via npm: ```bash npm install dog-breeds-group ``` Alternatively, if you prefer, you can download the code manually or clone this repository. ## Usage ### Example Usage: You can use the `findGroupByBreed()` function to easily find out which group a specific dog breed belongs to, and the `findBreedsByGroup()` function to find all breeds in a specific group. Both functions are case-insensitive. #### Example Code: ```javascript const { findGroupByBreed, findBreedsByGroup } = require('dog-breeds-group'); // Example 1: Find the group of a dog breed const breed = "English Cocker Spaniel"; const group = findGroupByBreed(breed); console.log(group); // Output: "Group 8 - Retrievers, Flushing Dogs and Water Dogs" // Example 2: Another breed search const breed2 = "Border Collie"; const group2 = findGroupByBreed(breed2); console.log(group2); // Output: "Group 1 - Sheepdogs and Cattle Dogs (excluding Swiss Cattle Dogs)" // Example 3: Find all breeds in a group const groupNumber = 1; const breedsInGroup = findBreedsByGroup(groupNumber); console.log(breedsInGroup); // Output: List of all breeds in Group 1 ``` ### Function Explanations: #### `findGroupByBreed(breedName)` This function takes a breed name as input and returns the corresponding group. It searches through a predefined list of groups and dog breeds, and if a match is found, it returns the group name. If the breed is not found in any group, it returns `undefined`. ##### Parameters: - **breedName**: A string representing the name of the dog breed you are searching for. It can be provided in any case (upper or lower). ##### Returns: - A string representing the group that the breed belongs to (e.g., "Group 1 - Sheepdogs and Cattle Dogs"). - If the breed is not found in any group, it returns `undefined`. #### `findBreedsByGroup(groupNumber)` This function allows you to find all the breeds within a specific group. It takes a group number (from 1 to 10) and returns an array of dog breeds that belong to that group. ##### Parameters: - **groupNumber**: A number (1 to 10) representing the group you are searching for. ##### Returns: - An array of dog breeds belonging to the specified group. If the group number is invalid or not found, it returns `undefined`. #### Example of function behavior: ```javascript findGroupByBreed("Golden Retriever"); // Returns: "Group 8 - Retrievers, Flushing Dogs and Water Dogs" findGroupByBreed("Rottweiler"); // Returns: "Group 2 - Pinscher and Schnauzer type dogs, Molossoids and Swiss Cattle Dogs" findGroupByBreed("Shih Tzu"); // Returns: "Group 9 - Companion Dogs" findGroupByBreed("Unicorn Dog"); // Returns: undefined (since it's not a valid breed) findBreedsByGroup(1); // Returns an array of breeds in Group 1 findBreedsByGroup(8); // Returns an array of breeds in Group 8 ``` ## Data Structure The dog breeds are categorized into 10 different groups, each containing a list of breed names. Each group corresponds to a specific type of dog, for example, Sheepdogs, Terriers, Sighthounds, and more. ### Example Group Structure: ```javascript const dogBreedsByGroup = [ { group: "Group 1 - Sheepdogs and Cattle Dogs (excluding Swiss Cattle Dogs)", breeds: [ "Australian Kelpie", "Australian Cattle Dog", "Australian Shepherd", "Bearded Collie", "Border Collie", // Additional breeds... ] }, { group: "Group 2 - Pinscher and Schnauzer type dogs, Molossoids and Swiss Cattle Dogs", breeds: [ "Bernese Mountain Dog", "Boxer", "Cane Corso", "Dobermann", "Rottweiler", // Additional breeds... ] }, // Additional groups... ] ``` ### Data Breakdown of Dog Breeds Groups: 1. **Group 1 - Sheepdogs and Cattle Dogs**: Includes breeds like the **Australian Kelpie**, **Border Collie**, **German Shepherd**, and **Maremma-Abruzzese Sheepdog**. 2. **Group 2 - Pinscher and Schnauzer type dogs, Molossoids and Swiss Cattle Dogs**: Includes breeds like the **Boxer**, **Saint Bernard**, **Cane Corso**, and **Rottweiler**. 3. **Group 3 - Terriers**: Includes breeds like the **Airedale Terrier**, **Bull Terrier**, **Jack Russell Terrier**, and **West Highland White Terrier**. 4. **Group 4 - Dachshunds**: Includes **Short-Haired Dachshund**, **Wire-Haired Dachshund**, and **Miniature Long-Haired Dachshund**. 5. **Group 5 - Spitz-type and Primitive-type Dogs**: Includes breeds like the **Alaskan Malamute**, **Akita Inu**, **Siberian Husky**, and **Shiba Inu**. 6. **Group 6 - Scenthounds and Bloodhounds**: Includes the **Beagle**, **Bloodhound**, and **Rhodesian Ridgeback**. 7. **Group 7 - Pointing Dogs**: Includes the **German Short-Haired Pointer**, **Weimaraner**, and **English Setter**. 8. **Group 8 - Retrievers, Flushing Dogs and Water Dogs**: Includes the **Golden Retriever**, **Labrador Retriever**, and **Irish Water Spaniel**. 9. **Group 9 - Companion Dogs**: Includes the **Pug**, **Shih Tzu**, and **French Bulldog**. 10. **Group 10 - Sighthounds**: Includes the **Greyhound**, **Whippet**, and **Afghan Hound**. ## License This project is licensed under the ISC License. ## Author **Antonella Schillaci**