-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
31 lines (29 loc) · 997 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
'use strict';
const { File } = require('super-sources');
const { LocalTime } = require('./dates/local-time');
const { LocalDate } = require('./dates/local-date');
const { LocalDateTime } = require('./dates/local-date-time');
const { OffsetDateTime } = require('./dates/offset-date-time');
const { SourceTracker } = require('./source-tracker');
const parseAST = require('./parse');
const interpret = require('./interpret');
function parse(toml, filename = 'TOML document', tracker = null) {
if (typeof toml !== 'string') {
throw new TypeError('Expected toml to be a string');
}
if (typeof filename !== 'string') {
throw new TypeError('Expected filename to be a string');
}
if (tracker !== null && !(tracker instanceof SourceTracker)) {
throw new TypeError('Expected tracker to be a SourceTracker object');
}
return interpret(parseAST(new File(filename, toml)), tracker);
}
Object.assign(exports, {
parse,
LocalTime,
LocalDate,
LocalDateTime,
OffsetDateTime,
SourceTracker,
});