Rust implementation of NextGraph, a Decentralized and local-first web 3.0 ecosystem https://nextgraph.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
nextgraph-rs/sdk/js/shex-orm/dist/util/forAllShapes.js

17 lines
728 B

import fs from "fs";
import path from "node:path";
export async function forAllShapes(shapePath, callback) {
const shapeDir = await fs.promises.readdir(shapePath, {
withFileTypes: true,
});
// Filter out non-shex documents
const shexFiles = shapeDir.filter((file) => file.isFile() && file.name.endsWith(".shex"));
const shexPromise = Promise.all(shexFiles.map(async (file) => {
const fileName = path.parse(file.name).name;
// Get the content of each document
const shexC = await fs.promises.readFile(path.join(shapePath, file.name), "utf8");
await callback(fileName, shexC);
}));
// Note: SHACL conversion omitted here.
await Promise.all([shexPromise]);
}