Scrubbr class¶
Signature:
export default class Scrubbr
Constructors¶
Constructor | Modifiers | Description |
---|---|---|
(constructor)(schema, options) | Create new scrubbr serializer |
Properties¶
Property | Modifiers | Type | Description |
---|---|---|---|
options | ScrubbrOptions |
Methods¶
Method | Modifiers | Description |
---|---|---|
addGenericSerializer(serializer) | Add a generic custom serializer function that's called for each node in the object. | |
addTypeSerializer(typeName, serializer) | Add a function to serialize a schema type | |
clone(options) | Create a duplicate version of this scrubbr with all the same serializers, global context, and options.This is useful to create a global scrubbr with serializer that should be used on all data, and all other scrubbrs are created from it for more specific use-cases. | |
getGlobalContext() | Retrieve the global context object. | |
getSchema() | Return the entire generated schema for the loaded TypeScript file. | |
getSchemaFor(typeName) | Get the the generated JSON schema for a TypeScript type. | |
loadSchema(schema) | Replace the schema with a new one | |
serialize(schemaType, data, context, options) | Serialize data based on a TypeScript type.You can influence the return type by using the generic angle brackets: | |
setGlobalContext(context, merge) | Set the global context object, that will be automatically merged with the context passed to the serialize function. You can use this for setting things like the logged-in user, at a global level. |