Coder Social home page Coder Social logo

Localize all vars about esomath.js HOT 5 CLOSED

Rudxain avatar Rudxain commented on May 26, 2024
Localize all vars

from esomath.js.

Comments (5)

fitiskin avatar fitiskin commented on May 26, 2024 1

Just an idea. Perhaps it would be more convenient to organize the library as a npm package? So that all functions would be available without monkey patching, touching globalThis object and expanding native prototypes such as Number or BigInt.

import { Numeric, Float } from 'well-named-enhanced-js-math-library'

or even

import { modPow } from 'well-named-enhanced-js-math-library/math'

It will allow users to safely use the code in their projects without fear of breaking them with a new suddenly adopted ECMAscript standard.

I would help you with package building, refactoring, and so on.

What do you think?

from esomath.js.

Rudxain avatar Rudxain commented on May 26, 2024 1

I realized this library wouldn't be useless even after removing everything that is not a Stage +1 proposal. I still haven't made the decision about the future of this library. I'll open a new Issue about this

from esomath.js.

Rudxain avatar Rudxain commented on May 26, 2024 1

For consistency, I decided that the only global values and fns that should be encapsulated/localized, should be everything but prototype methods, because of the call problem (infinite regress), and because using call makes the code less "elegant". So this library will do the assumption that all prototypes are immutable (even if they aren't)

from esomath.js.

Rudxain avatar Rudxain commented on May 26, 2024

@fitiskin I've been considering doing that. This library includes a lot of stuff that would probably never be added to the official ES spec (like Fibonacci, and inverse factorials), so it shouldn't be used as a polyfill, but rather as a standalone library. Another solution is to remove anything/everything that is not strictly and definitely included in a Stage [1, 4] proposal, ensuring there's more safety about using this as a polyfill. All of the removed functions can then be migrated to my "Useless-Math" repo, and then I would turn that into a non-polyfill standalone library distributed using NPM.

Also, IIFE polyfills ensure everything behaves exactly like built-in methods, so using ESM may not be a good idea for this. I need more info to take a better decision about it.

The problem with my "solution" to remove stuff is that the library would become useless very fast, because core-js already has better polyfills for future JS math, but I want this library to add more stuff because it makes it more unique.

Maybe I should completely abandon the polyfill library concept, and just turn this into a normal library. I could still make polyfills for future stuff, but in smaller quantities, which would make it easier to maintain and change, and I could post them as Gists instead of dedicating entire repos to them.

Thank you for your insight, I'll start thinking more about this

from esomath.js.

Rudxain avatar Rudxain commented on May 26, 2024

I've given up on JS, so I'll 🦀RIIR in the future.

I'll keep the JS commit history in a secondary branch, for archiving purposes

from esomath.js.

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.