Skip to content

Commit b555cf9

Browse files
committed
upgraded to jasmine 2.0 with newer grunt-contrib-jasmine stack
1 parent 5d46d4c commit b555cf9

File tree

7 files changed

+96
-97
lines changed

7 files changed

+96
-97
lines changed

dist/angular-google-maps.js

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/*! angular-google-maps 1.1.1-SNAPSHOT 2014-05-25
1+
/*! angular-google-maps 1.1.1-SNAPSHOT 2014-05-26
22
* AngularJS directives for Google Maps
33
* git: https://github.com/nlaplante/angular-google-maps.git
44
*/
@@ -242,14 +242,21 @@ Nicholas McCready - https://twitter.com/nmccready
242242
var async;
243243

244244
async = {
245-
each: function(array, callback, doneCallBack, pausedCallBack, chunk, index) {
245+
each: function(array, callback, doneCallBack, pausedCallBack, chunk, index, pause) {
246246
var doChunk;
247247
if (chunk == null) {
248-
chunk = 100;
248+
chunk = 20;
249249
}
250250
if (index == null) {
251251
index = 0;
252252
}
253+
if (pause == null) {
254+
pause = 1;
255+
}
256+
if (!pause) {
257+
throw "pause (delay) must be set from _async!";
258+
return;
259+
}
253260
if (array === void 0 || (array != null ? array.length : void 0) <= 0) {
254261
doneCallBack();
255262
return;
@@ -258,18 +265,22 @@ Nicholas McCready - https://twitter.com/nmccready
258265
var cnt, i;
259266
cnt = chunk;
260267
i = index;
261-
while (cnt-- && i < array.length) {
262-
callback(array[i]);
268+
while (cnt-- && i < (array ? array.length : i + 1)) {
269+
callback(array[i], i);
263270
++i;
264271
}
265-
if (i < array.length) {
266-
index = i;
267-
if (pausedCallBack != null) {
268-
pausedCallBack();
272+
if (array) {
273+
if (i < array.length) {
274+
index = i;
275+
if (pausedCallBack != null) {
276+
pausedCallBack();
277+
}
278+
return setTimeout(doChunk, pause);
279+
} else {
280+
if (doneCallBack) {
281+
return doneCallBack();
282+
}
269283
}
270-
return setTimeout(doChunk, 1);
271-
} else {
272-
return doneCallBack();
273284
}
274285
};
275286
return doChunk();

dist/angular-google-maps.min.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,15 @@
2525
"grunt-contrib-concat": "~0.3.0",
2626
"grunt-contrib-connect": "~0.5.0",
2727
"grunt-contrib-copy": "~0.4.1",
28-
"grunt-contrib-jasmine": "~0.5.2",
28+
"grunt-contrib-jasmine": "~0.6.4",
2929
"grunt-contrib-jshint": "~0.7.2",
3030
"grunt-contrib-uglify": "~0.2.6",
3131
"grunt-contrib-watch": "~0.5.3",
3232
"grunt-conventional-changelog": "~1.1.0",
3333
"grunt-mkdir": "~0.1.1",
3434
"grunt-open": "~0.2.2",
35-
"grunt-template-jasmine-istanbul": "~0.2.5",
36-
"grunt-template-jasmine-requirejs": "~0.1.8",
35+
"grunt-template-jasmine-istanbul": "~0.3.1",
36+
"grunt-template-jasmine-requirejs": "~0.2.0",
3737
"lodash": "^2.4.1",
3838
"mocha": "~1.9.0",
3939
"should": "~1.2.0"

spec/coffee/directives/api/utils/_async.spec.coffee

Lines changed: 28 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -2,76 +2,59 @@ describe "_async", ->
22
beforeEach ->
33
@subject = _async
44

5-
it "handle array of 101 outputs 101 elements equal to the original, with 1 pauses", ->
5+
it "handle callback passes an index", (done) ->
6+
_async.each [1], (thing,index)->
7+
expect(thing).toEqual 1
8+
expect(index).toEqual 0
9+
done()
10+
11+
it "handle array of 101 outputs 101 elements equal to the original, with 1 pauses", (done) ->
612
known = _.range(101)
713
test = []
814
pauses = 1
9-
running = true
10-
runs ->
11-
@subject.each(known,((num) -> test.push(num)),(()-> running = false),(()-> pauses++))
12-
13-
waitsFor =>
14-
return !running
15-
,'Failed to wait!',1000
16-
runs ->
17-
expect(running).toEqual(false)
15+
@subject.each(known,((num) -> test.push(num)),()->
16+
done()
1817
expect(pauses).toEqual(2)
1918
expect(test.length).toEqual(known.length)
2019
expect(test).toEqual(known)
20+
,(()-> pauses++),100)
2121

22-
it "handle array of 200 outputs 200 elements equal to the original, with 2 pauses", ->
22+
it "handle array of 200 outputs 200 elements equal to the original, with 2 pauses", (done) ->
2323
known = _.range(200)
2424
test = []
2525
pauses = 1
2626
running = true
27-
runs ->
28-
@subject.each(known,((num) -> test.push(num)),(()-> running = false),(()-> pauses++))
29-
waitsFor =>
30-
return !running
31-
,'Failed to wait!',1000
32-
runs ->
33-
expect(running).toEqual(false)
27+
@subject.each(known,((num) -> test.push(num)),()->
28+
done()
3429
expect(pauses).toEqual(2)
3530
expect(test.length).toEqual(known.length)
3631
expect(test).toEqual(known)
32+
,(()-> pauses++),100)
3733

38-
39-
it "handle array of 1000 outputs 1000 elements equal to the original, with 10 pauses", ->
34+
it "handle array of 1000 outputs 1000 elements equal to the original, with 10 pauses", (done) ->
4035
known = _.range(1000)
4136
test = []
4237
pauses = 1
43-
running = true
44-
runs ->
45-
@subject.each(known,((num) -> test.push(num)),(()-> running = false),(()-> pauses++))
46-
waitsFor =>
47-
!running
48-
,1000
49-
runs ->
50-
expect(running).toEqual(false)
38+
@subject.each(known,((num) -> test.push(num)),()->
39+
done()
5140
expect(pauses).toEqual(10)
5241
expect(test.length).toEqual(known.length)
5342
expect(test).toEqual(known)
54-
55-
it "handle map of 1000 outputs 1000 elements equal to the original, with 10 pauses", ->
43+
,(()-> pauses++),100)
44+
45+
46+
it "handle map of 1000 outputs 1000 elements equal to the original, with 10 pauses", (done) ->
5647
known = _.range(1000)
5748
test = []
5849
pauses = 1
5950
running = true
60-
runs( ->
61-
@subject.map(known,((num) ->
62-
num += 1
63-
"$#{num.toString()}"),(mapped)->
64-
test = mapped
65-
running = false
66-
,(()-> pauses++))
67-
)
68-
waitsFor =>
69-
!running
70-
,1000
71-
runs ->
72-
73-
expect(running).toEqual(false)
51+
@subject.map(known,((num) ->
52+
num += 1
53+
"$#{num.toString()}"),(mapped)->
54+
test = mapped
55+
done()
7456
expect(pauses).toEqual(10)
7557
expect(test[999]).toEqual("$1000")
7658
expect(test.length).toEqual(known.length)
77-
expect(test).toEqual(_.map(known,((n)-> n+=1; "$#{n.toString()}")))
59+
expect(test).toEqual(_.map(known,((n)-> n+=1; "$#{n.toString()}")))
60+
,(()-> pauses++),100)

spec/coffee/directives/api/utils/prop-map.spec.coffee

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,11 @@ describe "PropMap tests", ->
3434
@propMap.put('baz', 'biz')
3535
values = @propMap.values()
3636
expected = ['bar', 'biz']
37-
@expect(values[i]).toEqual(item) for item, i in expected
37+
expect(values[i]).toEqual(item) for item, i in expected
3838

3939
it "should return all put keys", ->
4040
@propMap.put('foo', 'bar')
4141
@propMap.put('baz', 'biz')
4242
keys = @propMap.keys()
4343
expected = ['foo', 'baz']
44-
@expect(keys[i]).toEqual(item) for item, i in expected
44+
expect(keys[i]).toEqual(item) for item, i in expected

spec/coffee/usage/underscore.intersection.spec.coffee

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,4 @@ describe "_.intersectionObjects", ->
117117
]
118118
interArray = _.intersectionObjects @objArray,difArray
119119
expect(interArray.length).toEqual(1)
120-
expect(interArray.length).toNotEqual(@objArray.length)
120+
expect(interArray.length).not.toEqual(@objArray.length)

src/coffee/directives/api/utils/_async.coffee

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,39 +9,44 @@
99
TODO: Handle Object iteration like underscore and lodash as well.. not that important right now
1010
###
1111
async =
12-
each: (array, callback, doneCallBack, pausedCallBack, chunk = 100, index = 0) ->
13-
if array == undefined or array?.length <= 0
14-
doneCallBack()
15-
return
16-
# set this to whatever number of items you can process at once
17-
doChunk = () ->
18-
cnt = chunk
19-
i = index
12+
each: (array, callback, doneCallBack, pausedCallBack, chunk = 20, index = 0, pause = 1) ->
13+
unless pause
14+
throw "pause (delay) must be set from _async!"
15+
return
16+
if array == undefined or array?.length <= 0
17+
doneCallBack()
18+
return
19+
# set this to whatever number of items you can process at once
20+
doChunk = () ->
21+
cnt = chunk
22+
i = index
2023

21-
while cnt-- and i < array.length
22-
# process array[index] here
23-
callback(array[i])
24-
++i
25-
if i < array.length
26-
index = i
27-
pausedCallBack() if pausedCallBack?
28-
setTimeout(doChunk, 1)
29-
else
30-
doneCallBack()
31-
doChunk()
24+
while cnt-- and i < (if array then array.length else i + 1)
25+
# process array[index] here
26+
callback(array[i],i)
27+
++i
3228

33-
#copied from underscore but to use the async each above
34-
map: (objs, iterator, doneCallBack, pausedCallBack, chunk) ->
35-
results = []
36-
return results unless objs?
37-
_async.each objs, (o) ->
38-
results.push iterator o
39-
, () ->
40-
doneCallBack(results)
41-
, pausedCallBack, chunk
29+
if array
30+
if i < array.length
31+
index = i
32+
pausedCallBack() if pausedCallBack?
33+
setTimeout(doChunk, pause)
34+
else
35+
doneCallBack() if doneCallBack
36+
doChunk()
37+
38+
#copied from underscore but w/ async each above
39+
map: (objs, iterator, doneCallBack, pausedCallBack, chunk) ->
40+
results = []
41+
return results unless objs?
42+
_async.each objs, (o) ->
43+
results.push iterator o
44+
, () ->
45+
doneCallBack(results)
46+
, pausedCallBack, chunk
4247

4348
window._async = async
4449

4550
angular.module("google-maps.directives.api.utils")
4651
.factory "async", ->
47-
window._async
52+
window._async

0 commit comments

Comments
 (0)