Methods
(static) add_custom(recipe_hash)
mark a recipe as custom
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string |
- Source:
(static) add_favorite(recipe_hash)
mark a recipe as favorite
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string |
- Source:
(static) add_recipe(recipe) → {Object}
Parameters:
| Name | Type | Description |
|---|---|---|
recipe |
Object | a custom recipe whose name, steps, ingredients, and cooktime are populated. note that it is not necessary to populate the hash and difficulty since they will be done for you |
- Source:
Returns:
- a copy of the added recipe for testing purpose
- Type
- Object
(static) edit_recipe(recipe_hash, recipe, custom)
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string | |
recipe |
Object | |
custom |
boolean |
- Source:
(static) fetch_recipe(name) → {Promise}
search a recipe by its name and keep only the parts we need according to the global variable keep_fields
we then remap the field names by the rule fields_remap
afterwards, it saves all filtered recipes to the localstore
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | name of the recipe |
- Source:
Returns:
returns a list of fetched recipe for testing purpose
- Type
- Promise
(static) filter_intolerance(recipe_hashes) → {Array.<string>}
filter the intolerance follow the user preferences
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hashes |
Array.<string> | a list of recipe_hashes on which to apply the filter |
- Source:
Returns:
- a list of filtered recipe hashes
- Type
- Array.<string>
(static) get_custom() → {Array.<string>}
get an array of recipe that are custom
- Source:
Returns:
an array of custom item, empty if non exisit
- Type
- Array.<string>
(static) get_favorite() → {Array.<string>}
get a list of starred recipe
- Source:
Returns:
an array of favorite item, empty if non exisit
- Type
- Array.<string>
(static) get_intolerance() → {Array.<string>}
- Source:
Returns:
an array of intolerance, empty if non
- Type
- Array.<string>
(static) get_recipe(recipe_hash) → {Object}
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string | the key to the recipe entry in localstore |
- Source:
Returns:
- the recipe object if found, null otherwise
- Type
- Object
(static) recipe_field_check(recipe)
check the values of a recipe's fields are valid before beginning processing
Parameters:
| Name | Type | Description |
|---|---|---|
recipe |
recipe Object whose fields are to be checked |
- Source:
Throws:
- an error if any field is empty or contains invalid values
(static) remove_custom(recipe_hash)
unmark a recipe as custom
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string |
- Source:
(static) remove_favorite(recipe_hash)
unfavorite a recipe
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string |
- Source:
(static) remove_recipe(recipe_hash)
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string |
- Source:
(static) remove_recipe_forIntolerance(recipe_hash)
Remove the recipe temporaly, just for deleting the api's intolerance tags
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string |
- Source:
(static) search_recipe(name, online, match_tolerance, intolerances) → {Promise}
search recipe in the localstore and as well as an option to auto fetch from the internet
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | name of the recipe you want to search |
online |
boolean | whether you want to pull in online results (local search by default) |
match_tolerance |
float | max distance between two strings that the fuzzy search allows |
intolerances |
Array.<string> | a list of intolerances |
- Source:
Returns:
a list of recipe_hash
- Type
- Promise
(static) search_suggest(name, match_tolerance, return_size)
suggest some recipes a user might be looking for
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | user input |
match_tolerance |
float | max distance between two strings that the fuzzy search allows |
return_size |
float | max length of the return array |
- Source:
Returns:
an array of recipe names that might be the thing you are searching for sorted by relavance
(static) set_intolerance(intolerance_list)
Parameters:
| Name | Type | Description |
|---|---|---|
intolerance_list |
Array.<string> | a list of intolerance that user applied |
- Source:
(inner) add_hash_to_arr(recipe_hash, arr_name)
add a recipe hash to an array. helper function for add favorite/custom
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string | |
arr_name |
string |
- Source:
(inner) compute_difficulty(recipe) → {float}
computes the difficulty of a recipe
Parameters:
| Name | Type | Description |
|---|---|---|
recipe |
Object | a recipe object whose steps, ingredients, and cooktime are populated |
- Source:
Returns:
- a difficulty rating as #ingredients * #steps / cooktime
- Type
- float
(inner) compute_hash(recipe) → {string}
compute the hash of a recipe by hashing its steps as a string
Parameters:
| Name | Type | Description |
|---|---|---|
recipe |
Object | a recipe object whose name and steps are populated |
- Source:
Returns:
- hash of its steps as a string
- Type
- string
(async, inner) fetch_recipe_raw(name) → {Promise}
search a recipe by its name and return a promise of list of raw json
Parameters:
| Name | Type | Description |
|---|---|---|
name |
string | name of the recipe |
- Source:
Returns:
- a list of unfiltered recipe, empty if non found
- Type
- Promise
(inner) get_localstore(key) → {object}
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string |
- Source:
Returns:
value associated with the key, null if not found
- Type
- object
(inner) min_edit_dist(str1, str2, del_cost, add_cost, sub_cost)
calculate the minimum edit distance to edit the first string to be the second
Parameters:
| Name | Type | Default | Description |
|---|---|---|---|
str1 |
string | ||
str2 |
string | ||
del_cost |
float | 1 | |
add_cost |
float | 1 | |
sub_cost |
float |
- Source:
(inner) recalculate_intolerances(recipe)
recalculates the intolerences list for the recipe. modifies in-place
Parameters:
| Name | Type | Description |
|---|---|---|
recipe |
* | the recipe object |
- Source:
(inner) remove_hash_in_arr(recipe_hash, arr_name)
remove a recipe hash in an array. helper function for remove favorite/custom
Parameters:
| Name | Type | Description |
|---|---|---|
recipe_hash |
string | |
arr_name |
string |
- Source:
(inner) set_localstore(key, value)
Parameters:
| Name | Type | Description |
|---|---|---|
key |
string | |
value |
Object |
- Source:
(inner) sub_cost(c1, c2)
helper function that returns the cost of turning c1 -> c2
this is related to how far apart the characters are on the keyboard
Parameters:
| Name | Type | Description |
|---|---|---|
c1 |
char | |
c2 |
char |
- Source: