nickradford / zeit

Manage time in javascript.
Other
1 stars 1 forks source link

Use es7 function binding syntax #8

Open nickradford opened 8 years ago

nickradford commented 8 years ago

Just a thought, but this seems like a potentially awesome syntax. @aeharding whatcha think?

function seconds() {
  return this * 1000
}

function minutes () {
  return (this * 60)::seconds()
}

console.log(3::minutes())
aeharding commented 8 years ago

It's definitely cleaner than messing with Number, that's for sure. Maybe to avoid global clutter... This is more production friendly, but more annoying for prototyping:

let z = {
  seconds() {
    return this * 1000;
  },
 minutes() {
    return (this * 60)::z.seconds();
  }
}

console.log(3::z.minutes());
nickradford commented 8 years ago

Yeah, thought a module system would be even better.

import {minutes} from 'Z';

console.log(4::minutes())
aeharding commented 8 years ago

:+1: I like that