import { IEnumerable , EqualityComparer , enumerateObject , flatten , initializeLinq } from "linq-to-typescript" ; initializeLinq ( ) ; declare global { interface Array < T > extends IEnumerable < T > { } interface Uint8Array extends IEnumerable < number > { } interface Uint8ClampedArray extends IEnumerable < number > { } interface Uint16Array extends IEnumerable < number > { } interface Uint32Array extends IEnumerable < number > { } interface Int8Array extends IEnumerable < number > { } interface Int16Array extends IEnumerable < number > { } interface Int32Array extends IEnumerable < number > { } interface Float32Array extends IEnumerable < number > { } interface Float64Array extends IEnumerable < number > { } interface Map < K , V > extends IEnumerable < [ K , V ] > { } interface Set < T > extends IEnumerable < T > { } interface String extends IEnumerable < string > { } } [ 1 , 2 ] . aggregate ( ( x , y ) => x + y ) ; [ "f" , "o" , "o" ] . aggregate ( ( x , y ) => x + y ) ; [ 1 , 2 , 3 ] . aggregate ( 4 , ( acc , x ) => acc + x ) ; [ 1 , 2 , 3 ] . aggregate ( "seed" , ( acc , y ) => acc + y , acc => acc + "result" ) ; [ 1 , 2 ] . all ( ( x ) => x < 3 ) ; [ 1 , 2 ] . all ( ( x ) => x < 2 ) ; [ 0 ] . any ( ) ; [ true ] . any ( ( x ) => ! x ) ; [ 1 , 2 ] . concatenate ( [ 2 , 3 ] ) ; [ 1 , 2 , 3 ] . contains ( 1 ) ; [ 1 , "2" , "3" ] . contains ( 2 , EqualityComparer ) ; [ 1 , 2 , 3 ] . count ( ) ; [ true , true , false ] . count ( x => x ) ; [ "f" , "o" , "o" ] . distinct ( ) ; [ "1" , 1 , 2 , 2 , 3 , "3" ] . distinct ( EqualityComparer ) ; for ( let item of enumerateObject ( { cat : "catto" , dog : "doggo" } ) ) { console . log ( item ) ; } let y = 0 ; [ 1 , 2 ] . each ( x => y += x ) ; [ 1 , 2 ] . elementAt ( 1 ) ; [ 1 , 2 ] . elementAtOrDefault ( 3 ) ; [ 1 , 2 ] . except ( [ 1 ] ) ; ( [ 1 , 2 ] as IEnumerable < string | number > ) . except ( [ "1" ] , EqualityComparer ) ; [ 1 , 2 ] . first ( ) ; [ 1 , 2 ] . first ( ( x ) => x === 2 ) ; [ ] . firstOrDefault ( ) ; flatten ( [ 1 , [ 2 , 3 ] ] ) ; const cats = [ ] as Array < { breed : string ; age : number ; } > ; const groupByBreed = cats . groupBy ( ( cat ) => cat . breed ) ; [ 1 , 2 , 3 ] . intersect ( [ 1 , 2 ] ) ; [ 1 , 2 , "3" ] . intersect ( [ "1" , "2" ] , EqualityComparer ) ; [ 1 , 2 , 3 , 4 , 5 ] . take ( 2 ) ; [ 1 , 2 ] . last ( ) ; [ 1 , 2 ] . last ( ( x ) => x === 1 ) ; [ ] . lastOrDefault ( ) ; [ 1 , 2 , 3 ] . lastOrDefault ( ( x ) => x === 4 ) ; [ 1 , 2 , 3 ] . max ( ) ; [ 1 , 2 , 3 ] . max ( ( x ) => x * x ) ; [ 1 , 2 , 3 , - 7 ] . min ( ) ; [ 1 , 2 , 3 , - 7 ] . min ( Math . abs ) ; [ "str" , "str2" , 1 , 2 , 3 , { } ] . ofType ( "string" ) ; [ 1 , 2 , "4" , false , true ] . ofType ( "boolean" ) ; [ 3 , 4 , 7 , 0 , 1 ] . orderBy ( ( x ) => x ) ; [ 1 , 2 , 3 ] . reverse ( ) ; [ 1 , 2 , 3 ] . select ( ( x ) => x * 10 ) ; [ 1 , 2 , 3 ] . selectMany ( ( x ) => [ x , x * x ] ) ; [ 1 , 2 , 3 ] . skip ( 2 ) ; [ 1 , 2 , 3 ] . union ( [ 4 , 5 , 6 ] ) ;