Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const parseString = (string, filename, sourcePaths) => {
try {
const IncludeYamlType = includeYamlType(filename, sourcePaths)
const DataYamlType = dataYamlType(filename, sourcePaths)
const schema = yaml.Schema.create([IncludeYamlType, DataYamlType, MarkdownYamlType])
const json = true // duplicate keys in a mapping will override values rather than throwing an error
return yaml.safeLoad(string.trim(), { schema, filename, json })
} catch (err) {
throw new UiengineInputError(['Could not parse YAML!', markSample(string)], err)
}
}
const fromFileSync = R.partial(parsing.fromFileSync, [parseString])
const fromFile = R.partial(parsing.fromFile, [parseString])
const fromString = R.partial(parsing.fromString, [parseString])
module.exports = {
parseString,
fromFileSync,
fromFile,
fromString
}
}
if (i === lines.length) { // second '---' is missing; assume entire `str` is body
return bodyOnly
}
return {
attributes: attributes.length ? YamlUtil.parseString(attributes.join(NEWLINE), filename, sourcePaths) : {},
body: lines.slice(i + 1).join(NEWLINE)
}
}
const parseString = (string, filename, sourcePaths) =>
fastmatter(string.trim(), filename, sourcePaths)
const fromFile = R.partial(ParsingUtil.fromFile, [parseString])
const fromString = R.partial(ParsingUtil.fromString, [parseString])
module.exports = {
parseString,
fromFile,
fromString
}