JSPM

@sanity/mutator

2.11.3-block-tools-var-fix.4+88bfdc8d0
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 253479
  • Score
    100M100P100Q175561F
  • License MIT

A set of models to make it easier to utilize the powerful real time collaborative features of Sanity

Package Exports

  • @sanity/mutator

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@sanity/mutator) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@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'
  }
}