OLD | NEW |
| (Empty) |
1 | |
2 function playback(opts) { | |
3 var records = []; | |
4 var seen = {}; | |
5 | |
6 function record(key, data) { | |
7 if (seen[key]) return; | |
8 records.push({key: key, data: data}); | |
9 seen[key] = true; | |
10 } | |
11 | |
12 function playback() { | |
13 var lines = [ | |
14 'library angular.core.service.playback_data;', | |
15 '', | |
16 'import "dart:convert";', | |
17 '', | |
18 '// Auto-generated by record-playback', | |
19 '', | |
20 'Map<String, String> playbackData = {' | |
21 ]; | |
22 | |
23 records.forEach(function(r) { | |
24 var keyString = JSON.stringify(r.key).replace(/\$/g, '\\$'); | |
25 var valueString = JSON.stringify(r.data).replace(/\$/g, '\\$'); | |
26 lines.push(' ' + keyString + ': JSON.decode(' + valueString + '),'); | |
27 }); | |
28 | |
29 lines.push('};'); | |
30 | |
31 return lines.join('\n'); | |
32 } | |
33 | |
34 return { | |
35 record: record, | |
36 playback: playback | |
37 } | |
38 } | |
39 | |
40 module.exports = { | |
41 playback: playback | |
42 }; | |
OLD | NEW |