Inventory reader

Functions:

inventory.isPresent(side)
Checks whether there is a inventory reader finding an in inventory attached on the given side.

inventory.open(side)
returns an inventory object, or nil if there is no readable inventory. It throws an error if there is no inventory Reader Peripheral on the specified side.

The Inventory object has the following methods and properties:

inv.name
The inventory type, eg. Furnace, Chest, or Turtle

inv.size
number of available inventory slots

inv.stackLimit
how many items can be stored in one slot

inv[i]
returns the item stack in slot i. For item stack objects, see db.stack(...)

inv:list([includeall])
same as inventory.listContents(inv, includeall)

inv:isValid()
same as inventory.isPresent(inv.side)

inv:contains(item, [amount])
same as inventory.contains(inv, item, amount)

inv:getStoredAmount(item)
same as inventory.getStoredAmount(inv, item)

inventory.getStoredAmount(inv, item)
Returns the total amount of items of the given type in the inventory (across stacks)

inventory.contains(inv, item, [n])
Checks whether there are at least n items of the specified type in the inventory.

inventory.listContents(inv, [includeall])
Unfortunately, it is not possible to iterate over an inventory object with 
for slot, stack in ipairs(inv) do ...

As workaround, you can write:
for slot, stack in inventory.listContents(inv) do ...

Note that this functions skips empty slots. to include them all, you have to call inventory.listContents(inv, true)