File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 4
4
"access" : " public" ,
5
5
"@shopify:registry" : " https://registry.npmjs.org/"
6
6
},
7
- "version" : " 0.3 .0" ,
7
+ "version" : " 1.0 .0" ,
8
8
"description" : " " ,
9
9
"main" : " index.ts" ,
10
10
"keywords" : [],
16
16
"@graphql-codegen/typescript-operations" : " ^2.5.5" ,
17
17
"graphql" : " ^16.6.0" ,
18
18
"typescript" : " ^4.8.4"
19
- },
20
- "peerDependencies" : {
21
- "javy" : " ^0.1.0"
22
19
}
23
20
}
Original file line number Diff line number Diff line change 1
- import * as fs from "javy/fs" ;
2
-
3
1
export type ShopifyFunction < Input extends { } , Output extends { } > = (
4
2
input : Input
5
3
) => Output ;
6
4
5
+ interface Javy {
6
+ JSON : {
7
+ fromStdin ( ) : any ;
8
+ toStdout ( val : any ) ;
9
+ }
10
+ }
11
+
12
+ declare global {
13
+ const Javy : Javy ;
14
+ }
15
+
7
16
export default function < I extends { } , O extends { } > ( userfunction : ShopifyFunction < I , O > ) {
8
- const input_data = fs . readFileSync ( fs . STDIO . Stdin ) ;
9
- const input_str = new TextDecoder ( "utf-8" ) . decode ( input_data ) ;
10
- const input_obj = JSON . parse ( input_str ) ;
17
+ const input_obj = Javy . JSON . fromStdin ( ) ;
11
18
const output_obj = userfunction ( input_obj ) ;
12
- const output_str = JSON . stringify ( output_obj ) ;
13
- const output_data = new TextEncoder ( ) . encode ( output_str ) ;
14
- fs . writeFileSync ( fs . STDIO . Stdout , output_data ) ;
19
+ Javy . JSON . toStdout ( output_obj )
15
20
}
You can’t perform that action at this time.
0 commit comments