Skip to content

Commit

Permalink
remove item
Browse files Browse the repository at this point in the history
  • Loading branch information
kemsky committed Nov 9, 2015
1 parent 6cbbed3 commit ab0490e
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 3 deletions.
19 changes: 18 additions & 1 deletion source/com/kemsky/Stream.as
Original file line number Diff line number Diff line change
Expand Up @@ -449,6 +449,23 @@ package com.kemsky
}
}

/**
* Removes item at specified position.
* @param index An integer that specifies the position in the list.
* @example
* <pre>
* var s:Stream = $(1, 2, 3);
* s.removeItem(0);
* trace(s);
* //Stream{2, 3}
* </pre>
* @internal mutable
*/
public function removeItem(index:int):void
{
delete this[index];
}

/**
* Executes a test function on each item and calculates number of successful tests.
* @param callback The function to run on each item in the list.
Expand Down Expand Up @@ -1957,7 +1974,7 @@ package com.kemsky
{
}

if(!(index <= 0) && !(index > 0))
if(index != index)
{
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,7 @@ package com.kemsky.filters
{
import com.kemsky.support.toValue;

//todo test
public function exists(val:*):Function
public function existing(val:*):Function
{
return function (item:*):Boolean
{
Expand Down
11 changes: 11 additions & 0 deletions testSrc/com/kemsky/TestStream.as
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,17 @@ package com.kemsky
assertTrue(s.getItem(3) === undefined);
}


[Test]
public function testRemove():void
{
var s:Stream = $(1, 2, 3);
s.removeItem(0);
assertEquals(s.length, 2);
assertEquals(s[0], 2);
assertEquals(s[1], 3);
}

[Test]
public function testGroup():void
{
Expand Down
15 changes: 15 additions & 0 deletions testSrc/com/kemsky/filters/TestFilters.as
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,21 @@ package com.kemsky.filters
}


[Test]
public function testExisting():void
{
var s:Stream = $();
s[0] = 0;
s[3] = null;
s[6] = NaN;
s[10] = "";

var r:Stream = s.filter(existing(_));
assertEquals(r.length, 2);
assertEquals(r.first, 0);
assertEquals(r.second, "");
}

[Test]
public function testUnderscore():void
{
Expand Down

0 comments on commit ab0490e

Please sign in to comment.