import { Observable, Subject } from "threads/observable";
import { expose } from "threads/worker";
import { checkFiles, checkURLs } from "@guardianproject/proofmode";

let subject = new Subject();

const sendMessage = (type, message) => {
  subject.next({ type, message });
};

const check = {
  checkFiles: (files) => {
    return checkFiles(files, sendMessage);
  },
  checkURLs: (urls) => {
    return checkURLs(urls, sendMessage);
  },
  values: () => {
    return Observable.from(subject);
  },
};

expose(check);
