You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
16 lines
484 B
JavaScript
16 lines
484 B
JavaScript
8 years ago
|
'use strict';
|
||
|
|
||
|
const inArray = require("in-array");
|
||
|
|
||
|
module.exports = function parseValue(item) {
|
||
|
/* We require() this here due to circular imports... */
|
||
|
const tableToStructure = require("./table-to-structure");
|
||
|
|
||
|
if (item.type === "TableConstructorExpression") {
|
||
|
return tableToStructure(item);
|
||
|
} else if (inArray(["BooleanLiteral", "NumericLiteral", "StringLiteral"], item.type)) {
|
||
|
return item.value;
|
||
|
} else {
|
||
|
throw new Error(`Unknown type ${item.type} encountered`);
|
||
|
}
|
||
|
}
|