magic-bytes icon indicating copy to clipboard operation
magic-bytes copied to clipboard

No browser.js file in /dist folder

Open jankapunkt opened this issue 4 years ago • 1 comments

Hi, I just tried 1.0.6 and according to the docs there should be a module in node_modules/magic-bytes.js/dist/browser.js but there isn't. Has this changed and you forgot to update the docs or is something else wrong here?

jankapunkt avatar Dec 15 '21 10:12 jankapunkt

Yes, I deleted it when refactoring to typescript.

Previously I used webpack to bundle the whole library into a single file. I dropped the whole build system because nowadays I think it's something that's more up to the user using the library on how to bundle the modules.

LarsKoelpin avatar Dec 15 '21 18:12 LarsKoelpin

Yes, I deleted it when refactoring to typescript.

Previously I used webpack to bundle the whole library into a single file. I dropped the whole build system because nowadays I think it's something that's more up to the user using the library on how to bundle the modules.

So the documentation for html is outdated.

// import magic-bytes.js
import { filetypename } from 'magic-bytes.js';

// add an event listener to the file input
document.getElementById("file").addEventListener('change', (event, x) => {
  const fileReader = new FileReader();
  fileReader.onloadend = (f) => {
    // convert the file to a Uint8Array
    const bytes = new Uint8Array(f.target.result);
    // console.log the file type
    console.log("Possible filetypes: " + filetypename(bytes))
  }
  fileReader.readAsArrayBuffer(event.target.files[0])
})

XiaoSong-CPE avatar Sep 24 '23 11:09 XiaoSong-CPE

I've updated the readme to reflect a new npm goal npm run example which runs the example

LarsKoelpin avatar Sep 25 '23 18:09 LarsKoelpin