Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
async function flatten (json, url): Promise {
const opts: FlattenOptions = {}
if (url) {
opts.base = url
}
const expanded = await jsonld.expand(json, opts)
const flattened = await jsonld.flatten(expanded, {})
return flattened[Constants.JsonLd.Graph]
}
.forEach(name => {
let str = fs.readFileSync('..' + sep + name, { encoding: 'utf-8' });
let def = JSON.parse(str);
jsonld.flatten(def)
.then(g => {
g.forEach(n => generate(n));
})
.then(() => {
let actionData = JSON.stringify({ '@context': ctx, '@graph': actions }, null, '\t');
fs.writeFileSync('..' + sep + 'property-actions.jsonld', actionData, { encoding: 'utf-8' });
let eventData = JSON.stringify({ '@context': ctx, '@graph': events }, null, '\t');
fs.writeFileSync('..' + sep + 'property-events.jsonld', eventData, { encoding: 'utf-8' });
});
});
.forEach(name => {
let str = fs.readFileSync('..' + sep + name, { encoding: 'utf-8' });
let def = JSON.parse(str);
jsonld.flatten(def)
.then(g => {
g.forEach(n => check(n, name));
});
});