1- import { Model } from " ../model" ;
2- import { PatchLog } from " ./PatchLog" ;
3- import { FileModelEncoding } from " ./constants" ;
1+ import { Model } from ' ../model' ;
2+ import { PatchLog } from ' ./PatchLog' ;
3+ import { FileModelEncoding } from ' ./constants' ;
44import { Encoder as SidecarEncoder } from '../codec/sidecar/binary/Encoder' ;
55import { Encoder as StructuralEncoderCompact } from '../codec/structural/compact/Encoder' ;
66import { Encoder as StructuralEncoderVerbose } from '../codec/structural/verbose/Encoder' ;
77import { encode as encodeCompact } from '../../json-crdt-patch/codec/compact/encode' ;
88import { encode as encodeVerbose } from '../../json-crdt-patch/codec/verbose/encode' ;
9- import { printTree } from " ../../util/print/printTree" ;
10- import type * as types from " ./types" ;
11- import type { Printable } from " ../../util/print/types" ;
9+ import { printTree } from ' ../../util/print/printTree' ;
10+ import type * as types from ' ./types' ;
11+ import type { Printable } from ' ../../util/print/types' ;
1212
1313export class File implements Printable {
1414 public static fromModel ( model : Model < any > ) : File {
1515 return new File ( model , PatchLog . fromModel ( model ) ) ;
1616 }
1717
18- constructor (
19- public readonly model : Model ,
20- public readonly history : PatchLog ,
21- ) { }
18+ constructor ( public readonly model : Model , public readonly history : PatchLog ) { }
2219
2320 public serialize ( params : types . FileSerializeParams = { } ) : types . FileWriteSequence {
2421 const view = this . model . view ( ) ;
25- const metadata : types . FileMetadata = [
26- { } ,
27- FileModelEncoding . SidecarBinary ,
28- ] ;
22+ const metadata : types . FileMetadata = [ { } , FileModelEncoding . SidecarBinary ] ;
2923 let model : Uint8Array | unknown | null = null ;
3024 const modelFormat = params . model ?? 'sidecar' ;
3125 switch ( modelFormat ) {
@@ -54,10 +48,7 @@ export class File implements Printable {
5448 default :
5549 throw new Error ( `Invalid model format: ${ modelFormat } ` ) ;
5650 }
57- const history : types . FileWriteSequenceHistory = [
58- null ,
59- [ ] ,
60- ] ;
51+ const history : types . FileWriteSequenceHistory = [ null , [ ] ] ;
6152 const patchFormat = params . history ?? 'binary' ;
6253 switch ( patchFormat ) {
6354 case 'binary' : {
@@ -84,21 +75,12 @@ export class File implements Printable {
8475 default :
8576 throw new Error ( `Invalid history format: ${ patchFormat } ` ) ;
8677 }
87- return [
88- view ,
89- metadata ,
90- model ,
91- history ,
92- ] ;
78+ return [ view , metadata , model , history ] ;
9379 }
9480
9581 // ---------------------------------------------------------------- Printable
9682
9783 public toString ( tab ?: string ) {
98- return `file` + printTree ( tab , [
99- ( tab ) => this . model . toString ( tab ) ,
100- ( ) => '' ,
101- ( tab ) => this . history . toString ( tab ) ,
102- ] ) ;
84+ return `file` + printTree ( tab , [ ( tab ) => this . model . toString ( tab ) , ( ) => '' , ( tab ) => this . history . toString ( tab ) ] ) ;
10385 }
10486}
0 commit comments