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

Function withPrefix

test/README.example.proof.ts:1147–1159  ·  view source on GitHub ↗
(prefixFactory: (level: LogLevel) => string)

Source from the content-addressed store, hash-verified

1145 const logError = logEffect("error");
1146
1147 function withPrefix(prefixFactory: (level: LogLevel) => string) {
1148 return defineHandlerFor<Logging>().with((self) =>
1149 self.handle(
1150 (name): name is Logging["name"] => typeof name === "string" && name.startsWith("logging."),
1151 function* ({ effect, resume }): Generator<Logging, void> {
1152 const prefix = prefixFactory(effect.name.slice("logging.".length) as LogLevel);
1153 effect.payloads.splice(0, 0, prefix);
1154 yield effect;
1155 resume();
1156 },
1157 ),
1158 );
1159 }
1160
1161 function withMinimumLogLevel(level: LogLevel | "none") {
1162 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