Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CS2 Discussion: Output: Remove unnecessary polyfills #4958

Closed
coffeescriptbot opened this issue Feb 19, 2018 · 1 comment
Closed

CS2 Discussion: Output: Remove unnecessary polyfills #4958

coffeescriptbot opened this issue Feb 19, 2018 · 1 comment

Comments

@coffeescriptbot
Copy link
Collaborator

From @GeoffreyBooth on 2016-12-15 06:39

See #2562, to take just one example. CoffeeScript 2 can assume that browsers have indexOf, includes and other modern prototype methods. We can streamline our output by using them.

@coffeescriptbot
Copy link
Collaborator Author

From @connec on 2016-12-15 14:45

Heh, I was just about to make the same issue after reading #4268 😄

I just had a quick glance and I think the only non-shortcut ones we will need are modulo and, possibly, extend:

UTILITIES =
  # `extend` has been replaced by ES inheritance for class declaration, but can still
  # appear standalone, e.g. `A extends B` is valid CS. We could drop standalone `extends`
  # and eliminate this helper.
  extend: (o) -> ...

  # We can probably rely on the existence of `Function#bind` in modern environments, so
  # this could become a shortcut (call-sites need to change to use `utility(...).call`).
  bind: -> '(() => {}).bind'

  # We can certainly rely on the existence of `Array#indexOf`.
  indexOf: -> '[].indexOf'

  # This is still needed.
  modulo: -> 'function(a, b) { return (+a % (b = +b) + b) % b; }'

  # These are already just shortcuts and should probably remain.
  hasProp: -> '{}.hasOwnProperty'
  slice  : -> '[].slice'

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant