JS and file Blobs

Posted on October 2, 2021
Tags: javascript
function newFile(data) {
  var json = JSON.stringify(data);
  var blob = new Blob([json], {type: "octet/stream"});
  var url  = window.URL.createObjectURL(blob);
  window.location.assign(url);
}
const fetchin = () => {
  const fetchCPS = url => (cbs) => {
    fetch(url).then(cbs)
  }
  const ff = CPS(fetchCPS('https://jsonplaceholder.typicode.com/todos/1')).map(x=>x.json())
  // const b = ff(
  //   cbs => console.log(cbs)
  // )
  ff(x => x.then(console.log))
  // b('https://jsonplaceholder.typicode.com/todos/1')
  const cpsFun = cb => cb(42)
  const cpsWrapped = CPS(cpsFun)
  const cpsNew = cpsWrapped.map(y => y + 1)
  cpsNew((console.log))

  // fetch('https://jsonplaceholder.typicode.com/todos/1')
  // .then(response => response.json())
  // .then(json => console.log(json))
};