GithubHelp home page GithubHelp logo

Comments (5)

ljharb avatar ljharb commented on August 31, 2024

I don't see why it would be dead code. It works down to ES3, so it needs to polyfill Function#bind, and when shimmed onto the global object, it needs to conditionally check for property descriptor support.

When I run browserify locally, I do end up with a file that's 28K.

So part of the size is that there's an Object.keys polyfill included (object-keys), part is Function#bind (function-bind), part is Array#forEach (for-each).

One quick way to decrease the size if you don't target ES3 (say, if you target ES5 or above) would be to alias these three polyfills to simply module.exports = Object.keys, module.exports = Function.prototype.bind, and module.exports = Array.prototype.forEach. It's also likely that these modules will already dedupe with other things.

from object.entries.

ljharb avatar ljharb commented on August 31, 2024

(In other words, Object.entries is in no way a simple loop, and it needs to also be robust against someone deleting or overriding global builtins)

from object.entries.

slikts avatar slikts commented on August 31, 2024

FWIW istanbul cover suggests that about 60% code is not executed. In any case, there should be a warning that this isn't as small as it looks to avoid surprises.

from object.entries.

ljharb avatar ljharb commented on August 31, 2024

@slikts sure, it contains polyfills - in a given engine, 100% of the code is never executed. The point is that across all the engines it supports combined, it has 100% coverage.

from object.entries.

ljharb avatar ljharb commented on August 31, 2024

Also, if "as it looks" doesn't include dependencies, that's an issue with your expectations - any npm package might pull in a core module, or a lot of deps, or none.

from object.entries.

Related Issues (12)

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.