Middleware
Defined in: astrobase/src/middleware/types.ts:5
A middleware that hooks into the transformation process of structured data.
Properties
Section titled “Properties”replacer()
Section titled “replacer()”replacer: (
key,value,instance) =>unknown
Defined in: astrobase/src/middleware/types.ts:20
A function that may alter the value that ends up in the stringified output. This function
behaves similarly to the replacer function that can be provided to JSON.stringify. (See:
MDN)
Parameters
Section titled “Parameters”If the value is part of an object, this will be the value’s key string. If the value
is part of an array, this will be the value’s index number. Otherwise this will be
undefined.
undefined | string | number
unknown
The value.
instance
Section titled “instance”The Instance config.
Returns
Section titled “Returns”unknown
A value to replace the value within the stringified output. If not replacing the value, the input value should be returned.
Throws
Section titled “Throws”If performing some validation and it fails, an error should be thrown.
reviver()
Section titled “reviver()”reviver: (
key,value,instance) =>unknown
Defined in: astrobase/src/middleware/types.ts:40
A function that may alter the value that ends up in the parsed output. This function behaves
similarly to the reviver function that can be provided to JSON.parse. (See:
MDN)
Parameters
Section titled “Parameters”If the value is part of an object, this will be the value’s key string. If the value
is part of an array, this will be the value’s index number. Otherwise this will be
undefined.
undefined | string | number
unknown
The value.
instance
Section titled “instance”The Instance config.
Returns
Section titled “Returns”unknown
A value to replace the value within the parsed output. If not replacing the value, the input value should be returned.
Throws
Section titled “Throws”If performing some validation and it fails, an error should be thrown.