3.0.4 • Published 1 year ago

@gw2efficiency/recipe-nesting v3.0.4

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

Installation

yarn add @gw2efficiency/recipe-nesting

If you want to calculate the price of the tree generated from this, take a look at @gw2efficiency/recipe-calculation.

Usage

import { nestRecipes } from '@gw2efficiency/recipe-nesting'

// Expects a list of crafting recipes in the API format. This needs to include at least
// the recipe you want to transform and all sub-recipes including guild upgrade recipes.
const recipes = [
  {
    type: 'Refinement',
    output_item_id: 19713,
    output_item_count: 1,
    min_rating: 75,
    time_to_craft_ms: 2000,
    disciplines: ['Artificer', 'Weaponsmith', 'Scribe', 'Huntsman'],
    flags: ['AutoLearned'],
    ingredients: [
      {
        item_id: 19726,
        count: 2,
      },
    ],
    id: 1,
    chat_link: '[&CQEAAAA=]',
  },
  // ...
]

// This is a (optional) map of guild upgrade ids to item ids. This should only be used
// for type == Decoration, and resolves all the basic decorations needed for Scribing.
const decorationsToItemsMap = {
  42: 1337,
  // ...
}

const nestedRecipes = nestRecipes(recipes, decorationsToItemsMap)
// -> [
//   {
//     "id": 13243,
//     "quantity": 5,
//     "output": 1,
//     "components": [
//       {
//         "id": 19712,
//         "quantity": 2,
//         "output": 1,
//         "components": [
//           {
//             "id": 19725,
//             "quantity": 3
//           },
//           // ...
//         ]
//       },
//       // ...
//     ]
//   }
//   // ...
// ]

Contributors

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

License

MIT

3.0.4

1 year ago

3.0.3

1 year ago

3.0.2

2 years ago

3.0.1

2 years ago

3.0.1-alpha.0

2 years ago

3.0.0-alpha.2

2 years ago

3.0.0-alpha.1

2 years ago