MCPcopy Create free account
hub / github.com/Effect-TS/effect / fromGlob

Function fromGlob

packages/effect/src/unstable/sql/Migrator.ts:337–352  ·  view source on GitHub ↗
(
  migrations: Record<string, () => Promise<any>>
)

Source from the content-addressed store, hash-verified

335 * @since 4.0.0
336 */
337export const fromGlob = (
338 migrations: Record<string, () => Promise<any>>
339): Loader =>
340 pipe(
341 Object.keys(migrations),
342 Arr.flatMapNullishOr((_) => _.match(/^(?:.*\/)?(\d+)_([^.]+)\.(js|ts|mjs|mts)$/)),
343 Arr.map(
344 ([key, id, name]): ResolvedMigration => [
345 Number(id),
346 name,
347 Effect.promise(() => migrations[key]())
348 ]
349 ),
350 Arr.sort(migrationOrder),
351 Effect.succeed
352 )
353
354/**
355 * Creates a migration loader from a Babel-style glob record, parsing keys such

Callers

nothing calls this directly

Calls 3

pipeFunction · 0.90
NumberInterface · 0.50
mapMethod · 0.45

Tested by

no test coverage detected