Internal API
Considered stable unless denoted with "**".
NOTE: Unlike the rest of the spirit API, there are no camelCase variants.
Returns true
or false
depending on if v
is a instance of Response
Does not return true for a response map, this is a specific check.
Source: src/http/response-class.js (is_Response)
- v {*}
{boolean}
Returns the size of v
in bytes, utf-8 is assumed.
It only returns a size for a string or buffer. Otherwise it returns undefined.
This function is useful for determining the "Content-Length" of a response body that is a string or buffer.
Source: src/http/utils.js (size_of)
- v {string|buffer} A string or buffer to check
{number} The size of the v
(string or buffer)
** This function is expected to change in the future
Returns a string representation of the type of v
. It is similar to typeof
but it will also correctly detect and report types for: null, array, buffer, stream, file-stream.
As well as all types that typeof
already identifies (undefined, string, number, etc.)
Example:
type_of([1, 2, 3]) // "array"
type_of(new Buffer("hi")) // "buffer"
type_of(null) // "null"
Source: src/http/utils.js (type_of)
- v {*} value or object to check
{string} A string representation of the type of v
Works similarly to spirit.callp
. Except it adds special handling when the function being called returns a response map but with a response body that is a Promise.
When this occurs, resolves the response's body first instead of passing along a Promise of a response map which has a Promise as it's body that may not be resolved yet.
Additionally it surpresses Promise warnings regarding async error handling.
This is mostly used internally.
Source: src/core/promise_utils.js (resolve_response)
- p {Promise}
{Promise}
REMOVED IN v0.6.0
Resolves a response's body if it's a Promise.
This is mostly used internally.
- p {Promise}
{Promise}