Permalink
Browse files

playing around

  • Loading branch information...
1 parent cac3045 commit 33f7cfb225ac284d6ed5f783caa54552b0c0248e @drewlesueur committed Jun 8, 2011
Showing with 66 additions and 12 deletions.
  1. +30 −4 drews-mixins.coffee
  2. +24 −8 drews-mixins.js
  3. +12 −0 test.coffee
View
@@ -97,7 +97,7 @@ goAndDo = (exports, _) ->
exports.on = (obj, ev, callback) ->
calls = obj._callbacks || obj._callbacks = {}
- list = calls[ev] || (calls[ev] = {})
+ list = calls[ev] || (calls[ev] = [])
list.push callback
obj._events = obj._callbacks
obj
@@ -117,16 +117,19 @@ goAndDo = (exports, _) ->
# list[i] = null #backbone.js
break
obj
-
+ #TODO async events? wait 0, ->
exports.emit = (obj, eventName, args...) ->
both = 2
+ id = _.uniqueId()
if !(calls = obj._callbacks) then return obj
while both--
- ev = both ? eventName : "all"
+ ev = if both then eventName else "all"
+ list = calls[ev]
+
if list=calls[ev]
for item, i in list
callback = list[i]
- args = both ? args : args.unshift(eventName)
+ args = if both then args else args.unshift(eventName)
# maby have obj as the first param?
callback.apply obj, args
exports.trigger = exports.emit
@@ -256,6 +259,29 @@ goAndDo = (exports, _) ->
obj[key] = []
obj[key].push value
+
+ #maybe to one for add to array
+ addToObject = (obj, key, value) ->
+ obj[key] = value
+ addToObjectMaker = (obj) ->
+ (key, value) ->
+ addToObject obj, key, value
+ exports.addToObjectMaker = addToObjectMaker
+
+ # asyncTests = (batches, tests) ->
+ # before = addToObjectMaker()
+ # test = addToObjectMaker()
+ # prepareTests = () ->
+ # _.series batches
+ ###
+ do ->
+ giveBackTheCard = takeACard()
+
+
+
+ giveBackTheCard()
+ ###
+
exports.getAssertCount = -> count
exports.getFailCount = -> failCount
exports.getPassCount = -> passCount
View

Some generated files are not rendered by default. Learn more.

Oops, something went wrong.
View
@@ -11,7 +11,19 @@ _.mixin nimble
asyncEx
wait
isEqual
+ addToObjectMaker
} = _
+tests = {}
+befores = {}
+test = addToObjectMaker tests
+before = addToObjectMaker befores
+
+stuff = {}
+addToObj = addToObjectMaker stuff
+addToObj "name", "aterciopelados"
+addToObj "cd", "rio"
+eq stuff.name, "aterciopelados", "name should be aterciopelados"
+
str = "this is a test"
sub = s str, 2, 2
eq sub, "is"

0 comments on commit 33f7cfb

Please sign in to comment.