API reference
Every public function with its arguments, return values and a short example.
formatRecord(record, template)
Renders a record using a template string with named placeholders.
const { formatRecord } = require("stackwise");
const result = formatRecord(data, { strict: true });
console.log(result);createStore(options)
Creates a store from the given options and returns an object with read and write methods.
const { createStore } = require("stackwise");
const result = createStore(config, { strict: true });
console.log(result);parseInput(value, schema)
Validates a value against a schema and returns the cleaned result or a list of errors.
const { parseInput } = require("stackwise");
const result = parseInput(data, { strict: true });
console.log(result);mergeConfig(base, overrides)
Combines two configuration objects, giving priority to the second and keeping types intact.
const { mergeConfig } = require("stackwise");
const result = mergeConfig(config, { strict: true });
console.log(result);retryTask(task, attempts)
Runs an asynchronous task again if it fails, with a short delay between attempts.
const { retryTask } = require("stackwise");
const result = retryTask(items, { strict: true });
console.log(result);batchUpdate(items, size)
Splits a list into groups of the given size and processes them in order.
const { batchUpdate } = require("stackwise");
const result = batchUpdate(data, { strict: true });
console.log(result);serializeState(state)
Converts the current state to a compact string that can be restored later.
const { serializeState } = require("stackwise");
const result = serializeState(config, { strict: true });
console.log(result);watchChanges(target, handler)
Calls the handler every time the target changes and returns a function to stop watching.
const { watchChanges } = require("stackwise");
const result = watchChanges(items, { strict: true });
console.log(result);