MCPcopy Create free account
hub / github.com/Snowflyt/tinyeffect / withPrefix

Function withPrefix

test/README.example.spec.ts:1813–1825  ·  view source on GitHub ↗
(prefixFactory: (level: LogLevel) => string)

Source from the content-addressed store, hash-verified

1811 const logError = logEffect("error");
1812
1813 function withPrefix(prefixFactory: (level: LogLevel) => string) {
1814 return defineHandlerFor<Logging>().with((self) =>
1815 self.handle(
1816 (name): name is Logging["name"] => typeof name === "string" && name.startsWith("logging."),
1817 function* ({ effect, resume }): Generator<Logging, void> {
1818 const prefix = prefixFactory(effect.name.slice("logging.".length) as LogLevel);
1819 effect.payloads.splice(0, 0, prefix);
1820 yield effect;
1821 resume();
1822 },
1823 ),
1824 );
1825 }
1826
1827 function withMinimumLogLevel(level: LogLevel | "none") {
1828 return defineHandlerFor<Logging>().with((self) => {

Callers 1

Calls 4

defineHandlerForFunction · 0.90
resumeFunction · 0.85
withMethod · 0.65
handleMethod · 0.65

Tested by

no test coverage detected