cudr_slate-collaborative/src/bridge/convert/create.ts

17 lines
386 B
TypeScript
Raw Normal View History

2019-10-06 20:56:27 +00:00
import * as Automerge from 'automerge'
2021-01-29 14:02:01 +00:00
import { CollabMap, CollabOperation } from '../model'
2019-10-06 20:56:27 +00:00
const createByType = (type: Automerge.CollectionType) =>
type === 'map' ? {} : type === 'list' ? [] : ''
2019-10-05 08:44:49 +00:00
2021-01-29 14:02:01 +00:00
const opCreate = (
{ obj, type }: Automerge.Diff,
[map, ops]: [CollabMap, CollabOperation[]]
) => {
2019-10-05 08:44:49 +00:00
map[obj] = createByType(type)
return [map, ops]
}
export default opCreate