Skip to content

Instantly share code, notes, and snippets.

@jjt
Forked from arboleya/microevent.coffee
Created July 20, 2014 06:18
Show Gist options
  • Select an option

  • Save jjt/40c70d97546da131b62f to your computer and use it in GitHub Desktop.

Select an option

Save jjt/40c70d97546da131b62f to your computer and use it in GitHub Desktop.

Revisions

  1. @arboleya arboleya revised this gist Jan 13, 2013. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion microevent.coffee
    Original file line number Diff line number Diff line change
    @@ -12,4 +12,4 @@ class MicroEvent
    off:(e, f)-> (t.splice (t.indexOf f), 1) if (t = @_init()[e])?
    once:(e, f)-> @on e, (t = => (@off e, t) && f.apply @, arguments)
    emit:(e)-> l.apply @, ([].slice 1) for l in t if (t = @_init()[e])?; 0
    @mixin=(t)-> t::[p] = @::[p] for p, v of @::; 0
    @mixin=(t)-> t::[p] = @::[p] for p of @::; 0
  2. @arboleya arboleya revised this gist Jan 13, 2013. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions microevent.coffee
    Original file line number Diff line number Diff line change
    @@ -7,9 +7,9 @@ https://github.com/jeromeetienne/microevent.js
    ###
    class MicroEvent
    _init:-> @_listn or @_listn = {}
    _create:(e)-> @_init()[e] or @init()[e] = []
    _create:(e)-> @_init()[e] or @_init()[e] = []
    on:(e, f)-> (@_create e).push f
    off:(e, f)-> (t.splice (t.indexOf f), 1) if (t = @_init()[e])?
    once:(e, f)-> @on e, (t = => (@off e, t) && f.apply @, arguments)
    emit:(e)-> l.apply @, ([].slice 1) for l in t if (t = @_init()[e])?; 0
    @mixin=(t)-> (t.prototype[p] = @::[p]) for p in ('on off emit'.split ' '); 0
    @mixin=(t)-> t::[p] = @::[p] for p, v of @::; 0
  3. @arboleya arboleya revised this gist Jan 13, 2013. 1 changed file with 4 additions and 3 deletions.
    7 changes: 4 additions & 3 deletions microevent.coffee
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,6 @@
    ###
    MicroEvent in Coffeescript.
    Port of MicroEvent in Coffeescript with some naming modifications
    and a new 'once' method.
    Original project:
    https://github.com/jeromeetienne/microevent.js
    @@ -8,7 +9,7 @@ class MicroEvent
    _init:-> @_listn or @_listn = {}
    _create:(e)-> @_init()[e] or @init()[e] = []
    on:(e, f)-> (@_create e).push f

    off:(e, f)-> (t.splice (t.indexOf f), 1) if (t = @_init()[e])?
    once:(e, f)-> @on e, (t = => (@off e, t) && f.apply @, arguments)
    emit:(e)-> l.apply @, ([].slice 1) for l in t if (t = @_init()[e])?; 0
    @mixin=(t)-> (t::[p] = @::[p]) for p in ('on off emit'.split ' '); 0
    @mixin=(t)-> (t.prototype[p] = @::[p]) for p in ('on off emit'.split ' '); 0
  4. @arboleya arboleya revised this gist Jan 13, 2013. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion microevent.coffee
    Original file line number Diff line number Diff line change
    @@ -8,6 +8,7 @@ class MicroEvent
    _init:-> @_listn or @_listn = {}
    _create:(e)-> @_init()[e] or @init()[e] = []
    on:(e, f)-> (@_create e).push f

    off:(e, f)-> (t.splice (t.indexOf f), 1) if (t = @_init()[e])?
    emit:(e)-> l.apply @, ([].slice 1) for l in t if (t = @_init()[e])?; 0
    @mixin=(t)-> (t.prototype[p] = @[p]) for p in ('on off emit'.split ' '); 0
    @mixin=(t)-> (t::[p] = @::[p]) for p in ('on off emit'.split ' '); 0
  5. @arboleya arboleya created this gist Jan 12, 2013.
    13 changes: 13 additions & 0 deletions microevent.coffee
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,13 @@
    ###
    MicroEvent in Coffeescript.
    Original project:
    https://github.com/jeromeetienne/microevent.js
    ###
    class MicroEvent
    _init:-> @_listn or @_listn = {}
    _create:(e)-> @_init()[e] or @init()[e] = []
    on:(e, f)-> (@_create e).push f
    off:(e, f)-> (t.splice (t.indexOf f), 1) if (t = @_init()[e])?
    emit:(e)-> l.apply @, ([].slice 1) for l in t if (t = @_init()[e])?; 0
    @mixin=(t)-> (t.prototype[p] = @[p]) for p in ('on off emit'.split ' '); 0