Skip to content

Commit

Permalink
convert to vector
Browse files Browse the repository at this point in the history
  • Loading branch information
kemsky committed Nov 23, 2015
1 parent b949c55 commit b884bcd
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
16 changes: 16 additions & 0 deletions source/com/kemsky/Stream.as
Original file line number Diff line number Diff line change
Expand Up @@ -1184,6 +1184,22 @@ package com.kemsky
return source.concat();
}

/**
* Creates a new Vector.<Object> from items of current stream
* @example
* <pre>
* var s:Stream = $(1, 2, 3);
* var c:Vector.&lt;Object&gt; = s.vector();
* trace(c);
* //[1, 2, 3]
* </pre>
* @internal immutable
*/
public function vector():Vector.<Object>
{
return Vector.<Object>(source.concat());
}

/**
* Creates a new Dictionary from the current list using specified property values as keys
* @param property The name of the property to be used as key.
Expand Down
14 changes: 14 additions & 0 deletions testSrc/com/kemsky/TestStream.as
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,20 @@ package com.kemsky
{
}


[Test]
public function testVector():void
{
var s:Stream = $(1, 2, 3);
var v:Vector.<Object> = s.vector();
assertEquals(v.length, 3);
assertEquals(v[0], 1);
assertEquals(v[1], 2);
assertEquals(v[2], 3);

assertEquals($().vector().length, 0);
}

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

0 comments on commit b884bcd

Please sign in to comment.