MCPcopy Create free account
hub / github.com/microsoft/SandDance / fileLoader

Function fileLoader

docs/app/js/sanddance-app.js:109005–109012  ·  view source on GitHub ↗

* File system loader factory. * @param {object} fs - The file system interface. * @return {function} - A file loader with the following signature: * param {string} filename - The file system path to load. * param {string} filename - The file system path to load. * return {Promise} A promi

(fs)

Source from the content-addressed store, hash-verified

109003 * param {string} filename - The file system path to load.
109004 * return {Promise} A promise that resolves to the file contents.
109005 */ function fileLoader(fs) {
109006 return fs ? (filename)=>new Promise((accept, reject)=>{
109007 fs.readFile(filename, (error, data)=>{
109008 if (error) reject(error);
109009 else accept(data);
109010 });
109011 }) : fileReject;
109012}
109013/**
109014 * Default file system loader that simply rejects.
109015 */ async function fileReject() {

Callers 1

loaderFactoryFunction · 0.70

Calls 2

rejectFunction · 0.85
readFileMethod · 0.45

Tested by

no test coverage detected