@@ -18,7 +18,7 @@ import { EvaluateExpressionDelegate, ExpressionEvaluator, ValidateExpressionDele
1818import { ExpressionType } from './expressionType' ;
1919import { Extensions } from './extensions' ;
2020import { TimeZoneConverter } from './timeZoneConverter' ;
21- import { convertCSharpDateTimeToMomentJS } from './formatConverter ' ;
21+ import { convertCSharpDateTimeToMomentJS } from './datetimeFormatConverter ' ;
2222import { MemoryInterface , SimpleObjectMemory , StackedMemory } from './memory' ;
2323
2424/**
@@ -531,7 +531,6 @@ export class ExpressionFunctions {
531531 ( args : any [ ] ) : any => {
532532 const binaryArgs : any [ ] = [ undefined , undefined ] ;
533533 let soFar : any = args [ 0 ] ;
534- // tslint:disable-next-line: prefer-for-of
535534 for ( let i = 1 ; i < args . length ; i ++ ) {
536535 binaryArgs [ 0 ] = soFar ;
537536 binaryArgs [ 1 ] = args [ i ] ;
@@ -557,7 +556,6 @@ export class ExpressionFunctions {
557556 let soFar : any = args [ 0 ] ;
558557 let value : any ;
559558 let error : string ;
560- // tslint:disable-next-line: prefer-for-of
561559 for ( let i = 1 ; i < args . length ; i ++ ) {
562560 binaryArgs [ 0 ] = soFar ;
563561 binaryArgs [ 1 ] = args [ i ] ;
@@ -602,7 +600,7 @@ export class ExpressionFunctions {
602600 * @param func Function to apply.
603601 */
604602 public static multivariateNumeric ( type : string , func : ( arg0 : any [ ] ) => any , verify ?: VerifyExpression ) : ExpressionEvaluator {
605- return new ExpressionEvaluator ( type , ExpressionFunctions . applySequence ( func , verify !== undefined ? verify : ExpressionFunctions . verifyNumber ) ,
603+ return new ExpressionEvaluator ( type , ExpressionFunctions . applySequence ( func , verify || ExpressionFunctions . verifyNumber ) ,
606604 ReturnType . Number , ExpressionFunctions . validateTwoOrMoreThanTwoNumbers ) ;
607605 }
608606 /**
@@ -692,7 +690,6 @@ export class ExpressionFunctions {
692690 return { value : result , error } ;
693691 } ,
694692 ReturnType . String ,
695- // tslint:disable-next-line: no-void-expression
696693 ( expr : Expression ) : void => ExpressionFunctions . validateArityAndAnyType ( expr , 2 , 3 , ReturnType . String , ReturnType . Number ) ) ;
697694 }
698695
@@ -770,7 +767,6 @@ export class ExpressionFunctions {
770767 private static newGuid ( ) : string {
771768 return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx' . replace ( / [ x y ] / g, ( c : any ) : string => {
772769 const r : number = Math . random ( ) * 16 | 0 ;
773- // tslint:disable-next-line: no-bitwise
774770 const v : number = c === 'x' ? r : ( r & 0x3 | 0x8 ) ;
775771
776772 return v . toString ( 16 ) ;
@@ -1006,13 +1002,12 @@ export class ExpressionFunctions {
10061002 }
10071003
10081004 if ( ! error ) {
1009- // 2nd parameter has been rewrite to $local.item
10101005 const iteratorName = ( expression . children [ 1 ] . children [ 0 ] as Constant ) . value as string ;
10111006 let arr = [ ] ;
10121007 if ( Array . isArray ( instance ) ) {
10131008 arr = instance ;
10141009 } else if ( typeof instance === 'object' ) {
1015- Object . keys ( instance ) . forEach ( u => arr . push ( { key : u , value : instance [ u ] } ) ) ;
1010+ Object . keys ( instance ) . forEach ( ( u ) : number => arr . push ( { key : u , value : instance [ u ] } ) ) ;
10161011 } else {
10171012 error = `${ expression . children [ 0 ] } is not a collection or structure object to run foreach` ;
10181013 }
@@ -1054,7 +1049,7 @@ export class ExpressionFunctions {
10541049 arr = instance ;
10551050 isInstanceArray = true ;
10561051 } else if ( typeof instance === 'object' ) {
1057- Object . keys ( instance ) . forEach ( u => arr . push ( { key : u , value : instance [ u ] } ) ) ;
1052+ Object . keys ( instance ) . forEach ( ( u ) : number => arr . push ( { key : u , value : instance [ u ] } ) ) ;
10581053 } else {
10591054 error = `${ expression . children [ 0 ] } is not a collection or structure object to run foreach` ;
10601055 }
@@ -1116,8 +1111,7 @@ export class ExpressionFunctions {
11161111
11171112 const second : Expression = expression . children [ 1 ] ;
11181113 if ( second . returnType === ReturnType . String && second . type === ExpressionType . Constant ) {
1119- // tslint:disable-next-line: restrict-plus-operands
1120- CommonRegex . CreateRegex ( ( second as Constant ) . value + '' ) ;
1114+ CommonRegex . CreateRegex ( ( second as Constant ) . value . toString ( ) ) ;
11211115 }
11221116 }
11231117
@@ -1389,7 +1383,7 @@ export class ExpressionFunctions {
13891383 ( { value : propertyName , error} = expression . children [ 1 ] . tryEvaluate ( state ) ) ;
13901384
13911385 if ( ! error ) {
1392- propertyName = propertyName === undefined ? '' : propertyName ;
1386+ propertyName = propertyName || '' ;
13931387 }
13941388 if ( isDescending ) {
13951389 result = lodash . sortBy ( arr , propertyName ) . reverse ( ) ;
@@ -1439,7 +1433,6 @@ export class ExpressionFunctions {
14391433 let result = '' ;
14401434 for ( const element of stringToConvert ) {
14411435 const binaryElement : string = element . charCodeAt ( 0 ) . toString ( 2 ) ;
1442- // tslint:disable-next-line: prefer-array-literal
14431436 result += new Array ( 9 - binaryElement . length ) . join ( '0' ) . concat ( binaryElement ) ;
14441437 }
14451438
@@ -1784,9 +1777,8 @@ export class ExpressionFunctions {
17841777 }
17851778
17861779 private static flatten ( arr : any [ ] , dept : number ) : any [ ] {
1787- dept = typeof dept === 'undefined' ? 1 : dept ;
1788- if ( typeof dept !== 'number' ) {
1789- return ;
1780+ if ( ! ExpressionFunctions . isNumber ( dept ) || dept < 1 ) {
1781+ dept = 1 ;
17901782 }
17911783
17921784 let res = JSON . parse ( JSON . stringify ( arr ) ) ;
@@ -1802,11 +1794,7 @@ export class ExpressionFunctions {
18021794 return res ;
18031795 }
18041796
1805-
1806-
1807- // tslint:disable-next-line: max-func-body-length
18081797 private static getStandardFunctions ( ) : ReadonlyMap < string , ExpressionEvaluator > {
1809- // tslint:disable-next-line: no-unnecessary-local-variable
18101798 const functions : ExpressionEvaluator [ ] = [
18111799 //Math
18121800 new ExpressionEvaluator ( ExpressionType . Element , ExpressionFunctions . extractElement , ReturnType . Object , this . validateBinary ) ,
@@ -1961,7 +1949,6 @@ export class ExpressionFunctions {
19611949 error = 'Second paramter must be more than zero' ;
19621950 }
19631951
1964- // tslint:disable-next-line: prefer-array-literal
19651952 const result : number [ ] = [ ...Array ( args [ 1 ] ) . keys ( ) ] . map ( ( u : number ) : number => u + Number ( args [ 0 ] ) ) ;
19661953
19671954 return { value : result , error } ;
@@ -2034,7 +2021,7 @@ export class ExpressionFunctions {
20342021 new ExpressionEvaluator (
20352022 ExpressionType . Flatten ,
20362023 ExpressionFunctions . apply (
2037- args => {
2024+ ( args : any [ ] ) : any [ ] => {
20382025 let array = args [ 0 ] ;
20392026 let depth = args . length > 1 ? args [ 1 ] : 100 ;
20402027 return ExpressionFunctions . flatten ( array , depth ) ;
@@ -2044,7 +2031,7 @@ export class ExpressionFunctions {
20442031 ) ,
20452032 new ExpressionEvaluator (
20462033 ExpressionType . Unique ,
2047- ExpressionFunctions . apply ( args => [ ... new Set ( args [ 0 ] ) ] ) ,
2034+ ExpressionFunctions . apply ( ( args : any [ ] ) : any [ ] => [ ... new Set ( args [ 0 ] ) ] ) ,
20482035 ReturnType . Object ,
20492036 ( expression : Expression ) : void => ExpressionFunctions . validateOrder ( expression , [ ] , ReturnType . Object )
20502037 ) ,
@@ -2175,7 +2162,7 @@ export class ExpressionFunctions {
21752162 ( expression : Expression ) : void => ExpressionFunctions . validateArityAndAnyType ( expression , 3 , 3 , ReturnType . String ) ) ,
21762163 new ExpressionEvaluator (
21772164 ExpressionType . Split ,
2178- ExpressionFunctions . apply ( ( args : any [ ] ) : string [ ] => ExpressionFunctions . parseStringOrNull ( args [ 0 ] ) . split ( ExpressionFunctions . parseStringOrNull ( args [ 1 ] ? args [ 1 ] : '' ) ) , ExpressionFunctions . verifyStringOrNull ) ,
2165+ ExpressionFunctions . apply ( ( args : any [ ] ) : string [ ] => ExpressionFunctions . parseStringOrNull ( args [ 0 ] ) . split ( ExpressionFunctions . parseStringOrNull ( args [ 1 ] || '' ) ) , ExpressionFunctions . verifyStringOrNull ) ,
21792166 ReturnType . Object ,
21802167 ( expression : Expression ) : void => ExpressionFunctions . validateArityAndAnyType ( expression , 1 , 2 , ReturnType . String ) ) ,
21812168 new ExpressionEvaluator (
@@ -2823,7 +2810,6 @@ export class ExpressionFunctions {
28232810 error = `Min value ${ args [ 0 ] } cannot be greater than max value ${ args [ 1 ] } .` ;
28242811 }
28252812
2826- // tslint:disable-next-line: insecure-random
28272813 const value : any = Math . floor ( Math . random ( ) * ( Number ( args [ 1 ] ) - Number ( args [ 0 ] ) ) + Number ( args [ 0 ] ) ) ;
28282814
28292815 return { value, error } ;
@@ -2855,7 +2841,6 @@ export class ExpressionFunctions {
28552841 ExpressionFunctions . validateUnary ) ,
28562842 new ExpressionEvaluator (
28572843 ExpressionType . DataUriToString ,
2858- // tslint:disable-next-line: restrict-plus-operands
28592844 ExpressionFunctions . apply ( ( args : Readonly < any > ) : string => Buffer . from ( args [ 0 ] . slice ( args [ 0 ] . indexOf ( ',' ) + 1 ) , 'base64' ) . toString ( ) , ExpressionFunctions . verifyString ) ,
28602845 ReturnType . String ,
28612846 ExpressionFunctions . validateUnary ) ,
0 commit comments