@sanity/mutator
    TypeScript icon, indicating that this package has built-in type declarations

    2.29.3 • Public • Published

    @sanity/mutator

    Features

    • Sanity flavored jsonpath matching engine with flexible interface that plays well with React
    • An implementation of the mutation operations of Sanity that can be applied to vanilla javascript objects, or through a flexible interface: any weird document representation you may require
    • TODO: A model to track documents as they are mutated both locally and remotely through the real time query feature of Sanity
    • Note: If patch.id doesn't match document._id, the patch will be ignored during apply.

    Usage

    import {Patcher} from '@sanity/mutator'
    
    const document = {
      _id: 'a1b2c3',
      a: {}
    }
    
    const patcher = new Patcher({
      id: 'a1b2c3',
      set: {
        'a.b': 'My new value'
      }
    })
    
    console.log(patcher.apply(document))
    
    => {
      _id: 'a1b2c3',
      a: {
        b: 'My new value'
      }
    }

    Install

    npm i @sanity/mutator

    DownloadsWeekly Downloads

    64,661

    Version

    2.29.3

    License

    MIT

    Unpacked Size

    403 kB

    Total Files

    172

    Last publish

    Collaborators

    • nina.andal
    • rankers
    • snorreeb
    • mattcraig
    • vincentquigley
    • stipsan
    • michael-sanity
    • rubioz
    • tonina
    • ritasdias
    • simeonsanity
    • kmelve
    • bjoerge
    • rexxars
    • skogsmaskin
    • simenss
    • robinpyon
    • mariuslundgard
    • sanity-io
    • evenw
    • radhe_sanity
    • rbotten
    • vicbergquist
    • judofyr
    • obliadp
    • dcilke
    • fredcarlsen
    • jorn_georg
    • hermanw
    • svirs
    • mikolajsanity
    • sgulseth
    • atombender