Skip to content

Commit

Permalink
filter by type
Browse files Browse the repository at this point in the history
  • Loading branch information
kemsky committed Nov 17, 2015
1 parent 5858d4b commit c407d19
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 0 deletions.
11 changes: 11 additions & 0 deletions .idea/inspectionProfiles/Project_Default.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 7 additions & 0 deletions .idea/inspectionProfiles/profiles_settings.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions source/com/kemsky/filters/type.as
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
package com.kemsky.filters
{
import com.kemsky.support.toValue;

public function type(val1:*, clazz:Class):Function
{
return function (item:*):Boolean
{
return toValue(item, val1) is clazz;
};
}
}
12 changes: 12 additions & 0 deletions testSrc/com/kemsky/filters/TestFilters.as
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,18 @@ package com.kemsky.filters
{
}

[Test]
public function testType():void
{
var stream:Stream = new Stream();

var s:Stream = $("test", 123, stream);

var d:Stream = s.filter(type(_, Stream));
assertEquals(d.length, 1);
assertEquals(d.first, stream);
}


[Test]
public function testExisting():void
Expand Down

0 comments on commit c407d19

Please sign in to comment.