File tree Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Expand file tree Collapse file tree 2 files changed +10
-16
lines changed Original file line number Diff line number Diff line change 44 "access" : " public" ,
55 "@shopify:registry" : " https://registry.npmjs.org/"
66 },
7- "version" : " 0.2 .0" ,
7+ "version" : " 0.1 .0" ,
88 "description" : " " ,
99 "main" : " index.ts" ,
1010 "keywords" : [],
1818 "typescript" : " ^4.8.4"
1919 },
2020 "peerDependencies" : {
21+ "javy" : " ^0.1.0"
2122 }
2223}
Original file line number Diff line number Diff line change 1+ import * as fs from "javy/fs" ;
2+
13export type ShopifyFunction < Input extends { } , Output extends { } > = (
24 input : Input
35) => Output ;
46
5-
6- interface Javy {
7- JSON : {
8- fromStdin ( ) : any ;
9- toStdout ( val : any ) ;
10- }
11- }
12-
13- declare global {
14- const Javy : Javy ;
15- }
16-
17-
187export default function < I extends { } , O extends { } > ( userfunction : ShopifyFunction < I , O > ) {
19- const input_obj = Javy . JSON . fromStdin ( ) ;
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 ) ;
2011 const output_obj = userfunction ( input_obj ) ;
21- Javy . JSON . toStdout ( output_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 ) ;
2215}
You can’t perform that action at this time.
0 commit comments