Resource

@ui5/fs. Resource

Resource

Constructor

new Resource(parameters)

Source:
The constructor.
Parameters:
Name Type Description
parameters object Parameters
Properties
Name Type Attributes Description
path string Virtual path
statInfo fs.Stats | object <optional>
File information. Instance of fs.Stats or similar object
buffer Buffer <optional>
Content of this resources as a Buffer instance (cannot be used in conjunction with parameters string, stream or createStream)
string string <optional>
Content of this resources as a string (cannot be used in conjunction with parameters buffer, stream or createStream)
stream Stream <optional>
Readable stream of the content of this resource (cannot be used in conjunction with parameters buffer, string or createStream)
createStream module:@ui5/fs.Resource~createStream <optional>
Function callback that returns a readable stream of the content of this resource (cannot be used in conjunction with parameters buffer, string or stream). In some cases this is the most memory-efficient way to supply resource content
project object <optional>
Experimental, internal parameter. Do not use

Methods

clone() → {Promise.<module:@ui5/fs.Resource>}

Source:
Returns a clone of the resource. The clones content is independent from that of the original resource
Returns:
Promise resolving with the clone
Type
Promise.<module:@ui5/fs.Resource>

(async) getBuffer() → {Promise.<Buffer>}

Source:
Gets a buffer with the resource content.
Returns:
Promise resolving with a buffer of the resource content.
Type
Promise.<Buffer>

getPath() → {string}

Source:
Gets the resources path
Returns:
(Virtual) path of the resource
Type
string

getStatInfo() → {fs.Stats|object}

Source:
Gets the resources stat info. Note that a resources stat information is not updated when the resource is being modified. Also, depending on the used adapter, some fields might be missing which would be present for a fs.Stats instance.
Returns:
Instance of fs.Stats or similar object
Type
fs.Stats | object

getStream() → {stream.Readable}

Source:
Gets a readable stream for the resource content. Repetitive calls of this function are only possible if new content has been set in the meantime (through setStream, setBuffer or setString). This is to prevent consumers from accessing drained streams.
Returns:
Readable stream for the resource content.
Type
stream.Readable

getString() → {Promise.<string>}

Source:
Gets a string with the resource content.
Returns:
Promise resolving with the resource content.
Type
Promise.<string>

setBuffer(buffer)

Source:
Sets a Buffer as content.
Parameters:
Name Type Description
buffer Buffer Buffer instance

setPath(path)

Source:
Sets the resources path
Parameters:
Name Type Description
path string (Virtual) path of the resource

setStream(stream)

Source:
Sets a readable stream as content.
Parameters:
Name Type Description
stream stream.Readable | module:@ui5/fs.Resource~createStream Readable stream of the resource content or callback for dynamic creation of a readable stream

setString(string)

Source:
Sets a String as content
Parameters:
Name Type Description
string string Resource content

Type Definitions

createStream() → {stream.Readable}

Source:
Function for dynamic creation of content streams
Returns:
A readable stream of a resources content
Type
stream.Readable