File tree Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Expand file tree Collapse file tree 2 files changed +45
-1
lines changed Original file line number Diff line number Diff line change 1
1
2
2
let php = require ( './../unv/grect/backend/Transpiled/php.js' ) ;
3
+ let php2 = require ( '../php.js' ) ;
3
4
const ApoPnrParser = require ( "../unv/grect/backend/Transpiled/Gds/Parsers/Apollo/Pnr/PnrParser" ) ;
4
5
const SabPnrParser = require ( "../unv/grect/backend/Transpiled/Gds/Parsers/Sabre/Pnr/PnrParser" ) ;
5
6
const AmaPnrParser = require ( "../unv/grect/backend/Transpiled/Gds/Parsers/Amadeus/Pnr/PnrParser" ) ;
6
7
const GalPnrParser = require ( "../unv/grect/backend/Transpiled/Gds/Parsers/Galileo/Pnr/PnrParser" ) ;
7
- const Fp = require ( '../unv/grect/backend/Transpiled/Lib/Utils/Fp.js' ) ;
8
8
9
9
exports . provideAsyncPromise = async ( ) => {
10
10
return Promise . resolve ( {
@@ -46,6 +46,13 @@ exports.provideParseGalPnr = () => {
46
46
return parsed ;
47
47
} ;
48
48
49
+
50
+ class Fp {
51
+ static map ( $function , $arr ) {
52
+ return php2 . array_map ( $function , $arr ) ;
53
+ }
54
+ }
55
+
49
56
exports . provideFfInfoStackOverflow = ( ) => {
50
57
// taken from Sabre PNR parser
51
58
let $result , $sections ;
Original file line number Diff line number Diff line change
1
+
2
+ let php = { } ;
3
+
4
+ php . array_combine = ( keys , values ) => {
5
+ keys = Object . values ( keys ) ;
6
+ values = Object . values ( values ) ;
7
+ if ( keys . length !== values . length ) {
8
+ throw new Error ( 'array_combine passed key count ' + keys . length +
9
+ ' does not match value count ' + values . length ) ;
10
+ }
11
+ let result = { } ;
12
+ for ( let i = 0 ; i < keys . length ; ++ i ) {
13
+ result [ keys [ i ] ] = values [ i ] ;
14
+ }
15
+ return result ;
16
+ } ;
17
+
18
+ let normFunc = ( func ) => {
19
+ if ( typeof func === 'string' ) {
20
+ if ( func in php ) {
21
+ func = php [ func ] ;
22
+ } else {
23
+ throw Error ( 'Unsupported built-in function - ' + func ) ;
24
+ }
25
+ }
26
+ return func ;
27
+ } ;
28
+ php . array_map = ( func , obj , additionalValues = [ ] ) => {
29
+ func = normFunc ( func ) ;
30
+ let newObj = Array . isArray ( obj ) ? [ ] : { } ;
31
+ for ( let [ key , val ] of Object . entries ( obj ) ) {
32
+ newObj [ key ] = func ( val , additionalValues [ key ] ) ;
33
+ }
34
+ return newObj ;
35
+ } ;
36
+
37
+ module . exports = php ;
You can’t perform that action at this time.
0 commit comments