1
1
const path = require ( 'path' ) ;
2
- const v8 = require ( 'v8' ) ;
2
+ // const v8 = require('v8');
3
3
const vm = require ( 'vm' ) ;
4
4
const sortKeys = require ( 'sort-keys' ) ;
5
5
const TOML = require ( '@iarna/toml' ) ;
@@ -40,7 +40,7 @@ class Sheet extends Configurable
40
40
}
41
41
}
42
42
43
- #recordCache;
43
+ // #recordCache;
44
44
45
45
constructor ( { workspace, name, dataTree = null , configPath = null } ) {
46
46
if ( ! workspace ) {
@@ -57,7 +57,7 @@ class Sheet extends Configurable
57
57
this . configPath = configPath || `.gitsheets/${ name } .toml` ;
58
58
this . dataTree = dataTree || workspace . root ;
59
59
60
- this . #recordCache = new Map ( ) ;
60
+ // this.#recordCache = new Map();
61
61
62
62
Object . freeze ( this ) ;
63
63
}
@@ -116,22 +116,28 @@ class Sheet extends Configurable
116
116
}
117
117
118
118
async readRecord ( blob , path = null ) {
119
- const cache = this . #recordCache. get ( blob . hash ) ;
119
+ /**
120
+ * caching is disabled for now, because v8.serialize doesn't
121
+ * preserve the custom Date classes that iarna/toml uses to
122
+ * preserve extended date types
123
+ */
124
+
125
+ // const cache = this.#recordCache.get(blob.hash);
120
126
121
127
let record ;
122
128
123
- if ( cache ) {
124
- record = v8 . deserialize ( cache ) ;
125
- } else {
126
- const toml = await blob . read ( ) ;
129
+ // if (cache) {
130
+ // record = v8.deserialize(cache);
131
+ // } else {
132
+ const toml = await blob . read ( ) ;
127
133
128
- try {
129
- record = TOML . parse ( toml ) ;
130
- } catch ( err ) {
131
- err . file = path ;
132
- throw err ;
133
- }
134
+ try {
135
+ record = TOML . parse ( toml ) ;
136
+ } catch ( err ) {
137
+ err . file = path ;
138
+ throw err ;
134
139
}
140
+ // }
135
141
136
142
// annotate with gitsheets keys
137
143
record [ RECORD_SHEET_KEY ] = this . name ;
@@ -140,9 +146,9 @@ class Sheet extends Configurable
140
146
}
141
147
142
148
// fill cache
143
- if ( ! cache ) {
144
- this . #recordCache. set ( blob . hash , v8 . serialize ( record ) ) ;
145
- }
149
+ // if (!cache) {
150
+ // this.#recordCache.set(blob.hash, toml );
151
+ // }
146
152
147
153
return record ;
148
154
}
0 commit comments