can-symbol
Version:
Well known symbols used to detail how to operate on different objects
75 lines (48 loc) • 2.04 kB
Markdown
Object} can-symbol/types/Patch Patch
can-symbol/types
A patch object that describes a mutation on an object.
`{type: "add", key, value}`
`add` patches signal that a key was added to an object.
```js
{ type: "add", key: "b", value: 1 }
```
{String} key The name of the key that was added to the object.
{Any} value The value of the key after it was added.
`{type: "delete", key}`
`delete` patches signal that a key was deleted from an object.
```js
{ type: "delete", key: "a" }
```
{String} key The name of the key that was deleted from the object.
`{type: "set", key, value}`
`set` patches signal that an existing key's value was set to another value.
```js
{ type: "set", key: "c", value: 2 }
```
{String} key The name of the key that was update on the object.
{Any} value The value of the key after it was set.
`{type: "splice", index, deleteCount, insert}`
`splice` patches signal a list-like object had enumerable values added, removed
or both at a specific index.
```js
{ type: "splice", index: 0, deleteCount: 10, insert: [ item1, item2 ] }
````
{Number} index The index where values were added, removed, or both.
{Number} deleteCount The number of items removed at the index.
{Array<Any>} insert An array of items inserted.
`{type: "move", fromIndex, toIndex}`
`move` patches signal a list-like object had an enumerable value move from one
position to another.
```js
{ type: "move", fromIndex: 1, toIndex: 2 }
```
{Number} fromIndex The starting index of the value.
{Number} toIndex The index the value was moved to.
`{type: "values", delete, insert}`
`values` patches signal a container-like object (like `Set`) has
had items added or removed.
```js
{ type: "values", delete: [ item0 ], insert: [ item1, item2 ] }
```
{Array<Any>} [delete] The items added to the object.
{Array<Any>} [insert] The items removed from the object.
{