You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tapestry.apache.org by hl...@apache.org on 2011/07/01 01:59:00 UTC
svn commit: r1141759 - in /tapestry/tapestry5/trunk/tapestry-core/src:
main/resources/org/apache/tapestry5/t5-arrays.js
test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml
Author: hlship
Date: Thu Jun 30 23:59:00 2011
New Revision: 1141759
URL: http://svn.apache.org/viewvc?rev=1141759&view=rev
Log:
TAP5-999: Add a function for extracting a named property from the elements of an array
Modified:
tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-arrays.js
tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml
Modified: tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-arrays.js
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-arrays.js?rev=1141759&r1=1141758&r2=1141759&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-arrays.js (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/main/resources/org/apache/tapestry5/t5-arrays.js Thu Jun 30 23:59:00 2011
@@ -208,8 +208,16 @@ T5.define("arrays", function() {
}
}
+ /**
+ * Extracts the named property from each element in the input array.
+ */
+ function extract(propertyName, array) {
+ return map(extractProperty(propertyName), array);
+ }
+
return {
each : each,
+ extract : extract,
extractProperty : extractProperty,
filter : filter,
first : first,
Modified: tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml
URL: http://svn.apache.org/viewvc/tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml?rev=1141759&r1=1141758&r2=1141759&view=diff
==============================================================================
--- tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml (original)
+++ tapestry/tapestry5/trunk/tapestry-core/src/test/resources/org/apache/tapestry5/integration/app1/pages/JavaScriptTests.tml Thu Jun 30 23:59:00 2011
@@ -205,6 +205,16 @@
</pre>
</div>
+ <div>
+ <p>
+ Extract a property from an array.
+</p>
+
+ <pre>
+ assertEqual(extract('id', [ { id: 7, name: "Fred" }, { id: 22, name: "Barney" }]), [7, 22])
+ </pre>
+ </div>
+
</div>
<h2>Publish / Subscribe</h2>
@@ -338,7 +348,7 @@
<script>
<![CDATA[
isEmpty = T5.arrays.isEmpty
- isNonEmpty = T5.arrays.isNonEmpty;
+ isNonEmpty = T5.arrays.isNonEmpty
map = T5.arrays.map
mapcat = T5.arrays.mapcat
reduce = T5.arrays.reduce
@@ -346,6 +356,7 @@
filter = T5.arrays.filter
remove = T5.arrays.remove
first = T5.arrays.first
+ extract = T5.arrays.extract
pub = T5.pub
sub = T5.sub