Comparing version 0.0.6 to 0.0.7
@@ -1,3 +0,4 @@ | ||
export declare const findByGlass: (input: string) => (string | any[]); | ||
export declare const findByLiquor: (input: string) => (string | string[]); | ||
export declare const findByIngredients: (input: any[]) => string[]; | ||
import { DrinkInterface } from '../interfaces/drinkInterface'; | ||
export declare const findByGlass: (input: string) => DrinkInterface[]; | ||
export declare const findByLiquor: (input: string) => DrinkInterface[]; | ||
export declare const findByIngredients: (input: string[]) => DrinkInterface[]; |
@@ -8,3 +8,2 @@ "use strict"; | ||
const prefix = 'You need to supply a type of'; | ||
// todo fix any | ||
const findByGlass = (input) => { | ||
@@ -25,3 +24,3 @@ if (input) { | ||
logUtils_1.log(errorString); | ||
return errorString; | ||
return []; | ||
} | ||
@@ -34,7 +33,7 @@ }; | ||
// Check the entire list of ingredients (normalized) and push to new array if found | ||
cocktails_1.data.map(drink => { var _a; return (_a = drink.ingredients) === null || _a === void 0 ? void 0 : _a.map(ingredientList => ingredientList.ingredient && (utils_1.normalizeLiquor(ingredientList.ingredient) === utils_1.normalizeLiquor(input)) && drinkArray.push(drink.name)); }); | ||
cocktails_1.data.map(drink => { var _a; return (_a = drink.ingredients) === null || _a === void 0 ? void 0 : _a.map(ingredientList => ingredientList.ingredient && (utils_1.normalizeLiquor(ingredientList.ingredient) === utils_1.normalizeLiquor(input)) && drinkArray.push(drink)); }); | ||
// The array of found pushes every time it is found, so dedupe list before logging | ||
const dedeupeDrinkArray = [...new Set(drinkArray)]; | ||
if (drinkArray.length) { | ||
dedeupeDrinkArray.map(drink => logUtils_1.log(drink)); | ||
dedeupeDrinkArray.map(drink => logUtils_1.log(drink.name)); | ||
} | ||
@@ -49,3 +48,3 @@ else { | ||
logUtils_1.log(errorString); | ||
return errorString; | ||
return []; | ||
} | ||
@@ -69,3 +68,3 @@ }; | ||
}); | ||
ingredientArray.every(i => inputArrayWithoutHyphens.includes(i)) && outputArray.push(drink.name); | ||
ingredientArray.every(i => inputArrayWithoutHyphens.includes(i)) && outputArray.push(drink); | ||
}); | ||
@@ -75,5 +74,5 @@ logUtils_1.logTitle(`Using these ingredients:`); | ||
logUtils_1.logTitle(`\n You can make:`); | ||
outputArray.map(d => logUtils_1.logBody(d)); | ||
outputArray.map(drink => logUtils_1.logBody(drink.name)); | ||
return outputArray; | ||
}; | ||
exports.findByIngredients = findByIngredients; |
@@ -71,5 +71,6 @@ #!/usr/bin/env node | ||
case 'i': | ||
argv.ingredients && find_1.findByIngredients(argv.ingredients); | ||
argv.ingredients && find_1.findByIngredients(argv.ingredients.map(String)); | ||
} | ||
} | ||
// Debug with this | ||
// console.log('All of the args', argv); |
#!/usr/bin/env node | ||
export declare const makeByName: (input: string, amount: number) => any; | ||
export declare const makeByRandom: (amount: number) => any; | ||
import { DrinkInterface } from '../interfaces/drinkInterface'; | ||
export declare const makeByName: (input: string, amount: number) => DrinkInterface | DrinkInterface[]; | ||
export declare const makeByRandom: (amount: number) => DrinkInterface; |
@@ -12,3 +12,3 @@ #!/usr/bin/env node | ||
const logUtils_1 = require("../utils/logUtils"); | ||
// todo fix any | ||
const string_similarity_1 = __importDefault(require("string-similarity")); | ||
const makeByName = (input, amount) => { | ||
@@ -22,9 +22,22 @@ const drinkInput = input.toLowerCase(); | ||
else { | ||
const errorString = "I don't know that one 😭"; | ||
logUtils_1.log(errorString); | ||
return (errorString); | ||
const errorString = "I don't know that one"; | ||
const similarDrinkReceipes = []; | ||
// find similar strings, if above .6, log it | ||
cocktails_1.data.map(x => { | ||
if (string_similarity_1.default.compareTwoStrings(x.name.toLowerCase(), drinkInput) > .6) { | ||
similarDrinkReceipes.push(x); | ||
} | ||
}); | ||
// output for similar drinks | ||
if (similarDrinkReceipes.length) { | ||
logUtils_1.log(`${errorString}, but I did find some similar drinks:`); | ||
similarDrinkReceipes.map(drink => logUtils_1.logBody(drink.name)); | ||
} | ||
else { | ||
logUtils_1.log(errorString); | ||
} | ||
return (similarDrinkReceipes); | ||
} | ||
}; | ||
exports.makeByName = makeByName; | ||
// todo fix any | ||
const makeByRandom = (amount) => { | ||
@@ -31,0 +44,0 @@ const drinkInput = utils_1.getRandomInt(cocktails_1.data.length); |
@@ -1,17 +0,3 @@ | ||
export interface Result { | ||
name: string; | ||
glass: string; | ||
category?: string | null; | ||
ingredients?: (IngredientsEntity)[] | null; | ||
garnish?: string | null; | ||
preparation?: string | null; | ||
} | ||
export interface IngredientsEntity { | ||
unit?: string | null; | ||
amount?: number | null; | ||
ingredient?: string | null; | ||
label?: string | null; | ||
special?: string | null; | ||
} | ||
declare const logMakeOutput: (result: Result, inputAmount: number) => (string | string[])[]; | ||
import { DrinkInterface } from '../interfaces/drinkInterface'; | ||
declare const logMakeOutput: (result: DrinkInterface, inputAmount: number) => (string | string[])[]; | ||
export default logMakeOutput; |
export declare const getRandomInt: (max: number) => number; | ||
export declare const getCocktailName: (input: any) => string; | ||
export declare const getCocktailName: (input: (string | number)[]) => string; | ||
export declare const normalizeLiquor: (input: string) => string; | ||
export declare function capitalizeFirstLetter(string: string): string; |
@@ -8,3 +8,2 @@ "use strict"; | ||
exports.getRandomInt = getRandomInt; | ||
// todo fix any | ||
const getCocktailName = (input) => { | ||
@@ -11,0 +10,0 @@ let drinkInput = `${input[1]}`; |
{ | ||
"name": "barcart", | ||
"version": "0.0.6", | ||
"version": "0.0.7", | ||
"description": "find cocktails based on what you have", | ||
@@ -28,2 +28,3 @@ "main": "cli.js", | ||
"@types/node": "^14.14.31", | ||
"@types/string-similarity": "^4.0.0", | ||
"@types/yargs": "^16.0.0", | ||
@@ -39,4 +40,5 @@ "@typescript-eslint/eslint-plugin": "^4.15.2", | ||
"chalk": "^3.0.0", | ||
"string-similarity": "^4.0.4", | ||
"yargs": "^16.2.0" | ||
} | ||
} |
@@ -31,2 +31,4 @@ # barcart | ||
All functions should return the array declared in [drinkInterfaces](https://github.com/drinkingandcoding/barcart/blob/main/src/interfaces/drinkInterface.ts) | ||
### Make | ||
@@ -33,0 +35,0 @@ ```js |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
67384
20
1768
48
3
9
+ Addedstring-similarity@^4.0.4
+ Addedstring-similarity@4.0.4(transitive)