LaurenceJJones / dbfstreamMemo

Fork of MichaelQQ / dbfstream with added Memo support
MIT License
0 stars 0 forks source link

Memo File Issue #2

Open Youssef93 opened 4 years ago

Youssef93 commented 4 years ago

1- You can no longer pass a stream to the function because of the line

let path = `${source.slice(0, source.indexOf('.'))}.fpt`;

Suggested Solution:

  const filePath = (isStream.readable(source))? source.path: source;
  let path = `${filePath.slice(0, filePath.indexOf('.'))}.fpt`;

2- if the .fpt file does not exist you get

Cannot read property 'getBlockContentAt' of null

because the memofile does not exist

Suggested Solution:

Make it optional & if it does not exist just return empty string the corresponding column

LaurenceJJones commented 4 years ago

I didn 't use the package as a stream so didn't catch this issue: but here an idea?

const isReadable = isStream.readable(source)
const readStream = isReadable  ? source : fs.createReadStream(source);
const filePath = isReadable ? source.path : source;
let path = `${filePath.slice(0, filePath.indexOf('.'))}.fpt`;

I will work on the memofile null issue as it needs to be improved