Skip to content

Commit

Permalink
update sample
Browse files Browse the repository at this point in the history
  • Loading branch information
bsorrentino committed May 23, 2018
1 parent c67365d commit 886e225
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 3 deletions.
4 changes: 2 additions & 2 deletions sample/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ require.paths = [
"target/ts/target"
];

java.lang.System.setProperty( "jvm-npm.debug", "true");
java.lang.System.setProperty( "jvm-npm.debug", "false");


// PLOYFILL
Expand All @@ -21,4 +21,4 @@ print( "args", $ARG.length );
var process = { argv:$ARG, env:{TERM:'color'} } ;

var exports = {};
load('target/ts/src/main/ts/main.js');
load('target/ts/src/main/ts/stream.js');
3 changes: 2 additions & 1 deletion sample/src/main/java/org/bsc/java2ts/jdk8/package-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,15 @@
@Java2TS(declare = {
@Type(java.lang.System.class),

@Type(value=java.util.Collection.class),
@Type(value=java.util.List.class),
@Type(value=java.util.Arrays.class, export=true),

@Type(java.nio.file.Files.class),
@Type(java.nio.file.Path.class),
@Type(java.nio.file.Paths.class),
@Type(java.nio.file.AccessMode.class),

@Type(java.util.stream.Collector.class),

@Type(value=java.net.URI.class, export=true),
@Type(java.net.URL.class),
Expand Down
36 changes: 36 additions & 0 deletions sample/src/main/ts/stream.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

import {
Arrays,
Stream,
Collectors

} from "ts/jdk8-types";


let list = Arrays.asList( "A", "B", "C" );

Stream.of( 4, 10, 9, 7, 34, 100 )
.filter( n => n%2==0 )
.map( p => p/2 )
.reduce( (b,c:any) => b + c )
.ifPresent( v => print("LIST ELEMENT", v) )

type element = [ number, string];

let r = Stream.of<element>( [4, "Pari"], [10, "Pari"], [9, "Dispari"], [7,"Dispari"], [34, "Pari"], [100,"Pari"], [34, "Pari"] )
.collect( Collectors.groupingBy( ( [v,k] ) => v ) )
.values()
.stream()
.flatMap( list => list.stream().map( ([v,k]) => v ).distinct() )
.forEach( v => print(v) )

//print(r);

let s = list.stream()
.filter( c => c.charAt(0)!="B")
//.parallel()
.collect( Collectors.joining(","));


print("COMPLETE", s);

0 comments on commit 886e225

Please sign in to comment.