Skip to content

Commit 921594e

Browse files
committed
make xlsx controller use async calls in javascript
1 parent 8e78499 commit 921594e

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

src/ARCtrl/Xlsx.fs

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,50 @@ module XlsxHelper =
2222
type DatamapXlsx() =
2323
member _.fromFsWorkbook (fswb: FsWorkbook) = DataMap.fromFsWorkbook fswb
2424
member _.toFsWorkbook (datamap: DataMap) = DataMap.toFsWorkbook datamap
25+
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
26+
member _.fromXlsxFileAsync (path: string) = FsWorkbook.fromXlsxFile path |> CrossAsync.map DataMap.fromFsWorkbook
27+
member _.toXlsxFileAsync (path: string, datamap: DataMap) = DataMap.toFsWorkbook datamap |> FsWorkbook.toXlsxFile path
28+
#else
2529
member _.fromXlsxFile (path: string) = FsWorkbook.fromXlsxFile path |> DataMap.fromFsWorkbook
2630
member _.toXlsxFile (path: string, datamap: DataMap) = DataMap.toFsWorkbook datamap |> FsWorkbook.toXlsxFile path
31+
#endif
2732

2833
[<AttachMembers>]
2934
type AssayXlsx() =
3035
member _.fromFsWorkbook (fswb: FsWorkbook) = ArcAssay.fromFsWorkbook fswb
3136
member _.toFsWorkbook (assay: ArcAssay) = ArcAssay.toFsWorkbook assay
37+
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
38+
member _.fromXlsxFileAsync (path: string) = FsWorkbook.fromXlsxFile path |> CrossAsync.map ArcAssay.fromFsWorkbook
39+
member _.toXlsxFileAsync (path: string, assay: ArcAssay) = ArcAssay.toFsWorkbook assay |> FsWorkbook.toXlsxFile path
40+
#else
3241
member _.fromXlsxFile (path: string) = FsWorkbook.fromXlsxFile path |> ArcAssay.fromFsWorkbook
3342
member _.toXlsxFile (path: string, assay: ArcAssay) = ArcAssay.toFsWorkbook assay |> FsWorkbook.toXlsxFile path
43+
#endif
3444

3545
[<AttachMembers>]
3646
type StudyXlsx() =
3747
member _.fromFsWorkbook (fswb: FsWorkbook) = ArcStudy.fromFsWorkbook fswb
3848
member _.toFsWorkbook (study: ArcStudy, ?assays: ResizeArray<ArcAssay>) = ArcStudy.toFsWorkbook(study,?assays=Option.map List.ofSeq assays)
49+
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
50+
member _.fromXlsxFileAsync (path: string) = FsWorkbook.fromXlsxFile path |> CrossAsync.map ArcStudy.fromFsWorkbook
51+
member _.toXlsxFileAsync (path: string, study: ArcStudy, ?assays: ResizeArray<ArcAssay>) = ArcStudy.toFsWorkbook(study,?assays=Option.map List.ofSeq assays) |> (FsWorkbook.toXlsxFile path)
52+
#else
3953
member _.fromXlsxFile (path: string) = FsWorkbook.fromXlsxFile path |> ArcStudy.fromFsWorkbook
4054
member _.toXlsxFile (path: string, study: ArcStudy, ?assays: ResizeArray<ArcAssay>) = ArcStudy.toFsWorkbook(study,?assays=Option.map List.ofSeq assays) |> FsWorkbook.toXlsxFile path
55+
#endif
4156

4257

4358
[<AttachMembers>]
4459
type InvestigationXlsx() =
4560
member _.fromFsWorkbook (fswb: FsWorkbook) = ArcInvestigation.fromFsWorkbook fswb
4661
member _.toFsWorkbook (investigation: ArcInvestigation) = ArcInvestigation.toFsWorkbook(investigation)
62+
#if FABLE_COMPILER_JAVASCRIPT || FABLE_COMPILER_TYPESCRIPT
63+
member _.fromXlsxFileAsync (path: string) = FsWorkbook.fromXlsxFile path |> CrossAsync.map ArcInvestigation.fromFsWorkbook
64+
member _.toXlsxFileAsync (path: string, investigation: ArcInvestigation) = ArcInvestigation.toFsWorkbook(investigation) |> FsWorkbook.toXlsxFile path
65+
#else
4766
member _.fromXlsxFile (path: string) = FsWorkbook.fromXlsxFile path |> ArcInvestigation.fromFsWorkbook
4867
member _.toXlsxFile (path: string, investigation: ArcInvestigation) = ArcInvestigation.toFsWorkbook(investigation) |> FsWorkbook.toXlsxFile path
68+
#endif
4969

5070
open XlsxHelper
5171

0 commit comments

Comments
 (0)