diff --git a/.idea/inspectionProfiles/Project_Default.xml b/.idea/inspectionProfiles/Project_Default.xml new file mode 100644 index 0000000..b6390fd --- /dev/null +++ b/.idea/inspectionProfiles/Project_Default.xml @@ -0,0 +1,11 @@ + + + + \ No newline at end of file diff --git a/.idea/inspectionProfiles/profiles_settings.xml b/.idea/inspectionProfiles/profiles_settings.xml new file mode 100644 index 0000000..3b31283 --- /dev/null +++ b/.idea/inspectionProfiles/profiles_settings.xml @@ -0,0 +1,7 @@ + + + + \ No newline at end of file diff --git a/source/com/kemsky/filters/type.as b/source/com/kemsky/filters/type.as new file mode 100644 index 0000000..04acb64 --- /dev/null +++ b/source/com/kemsky/filters/type.as @@ -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; + }; + } +} diff --git a/testSrc/com/kemsky/filters/TestFilters.as b/testSrc/com/kemsky/filters/TestFilters.as index c160be6..dd2fd21 100644 --- a/testSrc/com/kemsky/filters/TestFilters.as +++ b/testSrc/com/kemsky/filters/TestFilters.as @@ -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