Reader

Reader

Constructor

new Reader()

Source:

Methods

read(optionsopt) → {Promise.<Buffer>}

Read the given amount of bytes from the network

Parameters:
Name Type Attributes Description
options Object <optional>
Properties
Name Type Attributes Default Description
offset Number <optional>
0

start position

end Number <optional>
size

end position or end of data

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    const readOptions =
    {
        offset: 0, // starts reading from this byte position
        end: null // ends reading at this byte position
    };
    try {
        const iDataReader = await app.immutableData.fetch(iDataAddress)
        const data = await iDataReader.read(readOptions)
    } catch(err) {
      throw err;
    }
};

size() → {Promise.<Number>}

The size of the immutable data on the network

Source:
Example
// Assumes SAFEApp interface has been obtained
const asyncFn = async () => {
    try {
             const size = await iDataReader.size()
    } catch(err) {
      throw err;
    }
};