CachierFiles

CachierFiles

Node.js file persistence manager that uses the file system for improved debugging/caching capabilities

Constructor

new CachierFiles(optsopt, readFormatteropt, writeFormatteropt, logopt)

Constructor

Source:
Parameters:
Name Type Attributes Description
opts TemplateFileOpts <optional>

The TemplateFileOpts

readFormatter function <optional>

The function(string, readFormatOptions) that will return a formatted string for reading data using the options.readFormatOptions from TemplateOpts as the formatting options. Typically reads are for HTML minification and/or beautifying. NOTE: Use with caution as syntax errors may result depending on the formatter used and the complexity of the data being formatted!

writeFormatter function <optional>

The function(string, writeFormatOptions) that will return a formatted string for writting data using the options.writeFormatOptions from TemplateOpts as the formatting options. Typically reads are for JS minification and/or beautifying. NOTE: Use with caution as syntax errors may result depending on the formatter used and the complexity of the data being formatted!

log Object <optional>

The log for handling logging output

Name Type Attributes Description
debug function <optional>

A function that will accept debug level logging messages (i.e. debug('some message to log'))

info function <optional>

A function that will accept info level logging messages (i.e. info('some message to log'))

warn function <optional>

A function that will accept warning level logging messages (i.e. warn('some message to log'))

error function <optional>

A function that will accept error level logging messages (i.e. error('some message to log'))

Members

metadata

Source:

operations

Source:

readWriteNames

Source:

Methods

(async) clear(allopt)

Clears the output directories and any file watchers

Source:
Parameters:
Name Type Attributes Default Description
all Boolean <optional>
false

true to clear all temporary directories created over multiple instances

(async) compile()

Source:

(async) read()

Source:

(async) register(readopt, dataopt, readopt, writeopt) → {Object}

Registers and caches the tempalte, one or more partials and/or context within the internal file system. Also creates any missing directories/sub-directories within the TemplateFileOpts outputPath directory from partialsPath sub-directories.

Source:
Parameters:
Name Type Attributes Description
read Boolean <optional>

When true, an attempt will be made to also read any partials using option parameter

data Array.<Object> <optional>

The template, partials and/or context to register.

partials[].name String

The name that uniquely identifies the template, partial or context

partials[].content String <optional>

The raw content that will be registered. Omit when read === true to read content from cache.

partials[].params URLSearchParams <optional>

The URLSearchParams that will be passed during the content read (ignored when content is specified).

partials[].extension String <optional>

Optional override for a file extension designated for a template, partial or context.

read Boolean <optional>

When true, an attempt will be made to also Cachier.read the template, partials and context that do not have a content property set.

write Boolean <optional>

When true, an attempt will be made to also Cachier.write the template, partials and context that have a content property set.

Returns:
Type:
Object

An object that contains the registration results:

  • data The object that contains the template, partial fragments and/or context that have been registered
    • name The name that uniquely identifies the template, partial or context
    • content The raw content of the template, partial or context
    • extension The template file extension designation
    • params The URLSearchParams passed during the initial content read
    • fromRead A flag that indicates that the data was set from a read operation
    • overrideFromFileRead A flag that indicates if the passed partial content was overridden by content from a file read
  • dirs Contains the directories/sub-directories that were created

(async) write()

Source:

1.0.0 (2019-12-16)

Full Changelog