Packages

effect

4.1.4 · 11 Nov 2026MIT67.1M / weekRepositoryHomepagenpmAtom feed

Your version

3.12.3

14 Jan 2025Where it was published

3.22.5 is the newest release of 3.x.

In short

3 fixed

Security

2 advisories affect 3.12.3; 3.22.1 fixes them

Release note

Patch Changes

  • Improve pattern handling by merging multiple patterns into a union, closes #4243.

    Previously, the algorithm always prioritized the first pattern when multiple patterns were encountered.

    This fix introduces a merging strategy that combines patterns into a union (e.g., (?:${pattern1})|(?:${pattern2})). By doing so, all patterns have an equal chance to generate values when using FastCheck.stringMatching.

    Example

    import { Arbitrary, FastCheck, Schema } from "effect"
    
    // /^[^A-Z]*$/ (given by Lowercase) + /^0x[0-9a-f]{40}$/
    const schema = Schema.Lowercase.pipe(Schema.pattern(/^0x[0-9a-f]{40}$/))
    
    const arb = Arbitrary.make(schema)
    
    // Before this fix, the first pattern would always dominate,
    // making it impossible to generate values
    const sample = FastCheck.sample(arb, { numRuns: 100 })
    
    console.log(sample)
  • Correct Arbitrary.make to support nested TemplateLiterals.

    Previously, Arbitrary.make did not properly handle nested TemplateLiteral schemas, resulting in incorrect or empty outputs. This fix ensures that nested template literals are processed correctly, producing valid arbitrary values.

    Before

    import { Arbitrary, FastCheck, Schema as S } from "effect"
    
    const schema = S.TemplateLiteral(
      "<",
      S.TemplateLiteral("h", S.Literal(1, 2)),
      ">"
    )
    
    const arb = Arbitrary.make(schema)
    
    console.log(FastCheck.sample(arb, { numRuns: 10 }))
    /*
    Output:
    [
      '<>', '<>', '<>',
      '<>', '<>', '<>',
      '<>', '<>', '<>',
      '<>'
    ]
    */

    After

    import { Arbitrary, FastCheck, Schema as S } from "effect"
    
    const schema = S.TemplateLiteral(
      "<",
      S.TemplateLiteral("h", S.Literal(1, 2)),
      ">"
    )
    
    const arb = Arbitrary.make(schema)
    
    console.log(FastCheck.sample(arb, { numRuns: 10 }))
    /*
    Output:
    [
      '<h2>', '<h2>',
      '<h2>', '<h2>',
      '<h2>', '<h1>',
      '<h2>', '<h1>',
      '<h1>', '<h1>'
    ]
    */
  • Allow Schema.TemplateLiteral to handle strings with linebreaks, closes #4251.

    Before

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteral("a: ", Schema.String)
    
    console.log(Schema.decodeSync(schema)("a: b \n c"))
    // throws: ParseError: Expected `a: ${string}`, actual "a: b \n c"

    After

    import { Schema } from "effect"
    
    const schema = Schema.TemplateLiteral("a: ", Schema.String)
    
    console.log(Schema.decodeSync(schema)("a: b \n c"))
    /*
    Output:
    a: b
     c
    */

A whole project to check? Paste its package.json in the dependency check: every deprecated, outdated or vulnerable dependency, with what to upgrade to. Free, no account.