Coder Social home page Coder Social logo

use in browser about node-taglib-sharp HOT 5 CLOSED

benrr101 avatar benrr101 commented on September 26, 2024
use in browser

from node-taglib-sharp.

Comments (5)

benrr101 avatar benrr101 commented on September 26, 2024

Hello! This library is meant to be consumed by node.js, so, no it isn't possible to use it in the browser. In particular, the node fs module would not be available for accessing a file.

I suppose the file abstraction concept could be expanded to operate on files that are purely in memory, similarly to how the test file object is used for unit tests. However, this doesn't exist today and the file abstraction is really only used to wrap around a file in the filesystem.

from node-taglib-sharp.

subframe7536 avatar subframe7536 commented on September 26, 2024

get it. thanks for your reply!

from node-taglib-sharp.

subframe7536 avatar subframe7536 commented on September 26, 2024

After a few attempts, I finally create a wrapper to read and write in the browser. but the main drawback currently is that the polyfill for node:crypto is a little big:

with crypto polyfill: 972.38 kB │ gzip: 391.16 kB
without crypto polyfill: 683.34 kB │ gzip: 297.25 kB

I find it is only used in matroskaAttachment.ts and generate random array by crypto.randomFillSyn. Is it equal to window.crypto.getRandomValue?

from node-taglib-sharp.

benrr101 avatar benrr101 commented on September 26, 2024

It looks like it's pretty much the same as window.crypto.getRandomValues. Though looking at the docs for that, it appears to only be supported in Node v15 and up. At the moment node-taglib-sharp maintains compatibility with Node v12 and up. Upgrading would be possible but would require a major version bump. I'm also not entirely sure if that's the only place crypto is used. The uuid package used in various places around the library is hopefully relying on cryptographically secure values.

I'm also curious:

  • Is 300k really that big of a difference? Modern web apps are colossal, and I'd suspect 300k is nothing to most browsers
  • What are you trying to build? This library really isn't intended to be used in a browser setting, especially with the filesystem functionality it uses. Has it been working with all the polyfills?

from node-taglib-sharp.

subframe7536 avatar subframe7536 commented on September 26, 2024

Thanks for your explain. The polyfill process is running at build time, so there is no need to modify the original code.

I am building a web app that manage audio files tags directly inside the browser using file system api. I used to choose music-metadata-browser, but its data is read-only and still have a long road to support write feature, so I write a wrapper for this. I will open source the package later.

300KB (100KB in gzip) data may not impact on most browsers. I personally consider it as an learning research and optimization. Build once and run everywhere without installation is wonderful

from node-taglib-sharp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.