Skip to content
This repository has been archived by the owner on Feb 19, 2018. It is now read-only.

CS2 Discussion: Output: Remove unnecessary polyfills #65

Closed
GeoffreyBooth opened this issue Dec 15, 2016 · 2 comments
Closed

CS2 Discussion: Output: Remove unnecessary polyfills #65

GeoffreyBooth opened this issue Dec 15, 2016 · 2 comments

Comments

@GeoffreyBooth
Copy link
Collaborator

See jashkenas/coffeescript#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.

@connec
Copy link

connec commented Dec 15, 2016

Heh, I was just about to make the same issue after reading jashkenas/coffeescript#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'

@coffeescriptbot
Copy link
Collaborator

Migrated to jashkenas/coffeescript#4958

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

No branches or pull requests

3 participants