This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public static Option<TException> WithoutValue<TValue, TException>(this Option<TValue, TException> option) | |
| { | |
| return option.Match(_ => Option.None<TException>(), exception => exception.Some()); | |
| } | |
| public static IEnumerable<TValue> Values<TValue, TException>(this IEnumerable<Option<TValue, TException>> source) | |
| { | |
| if (source == null) throw new ArgumentNullException(nameof(source)); | |
| return source.SelectMany(option => option.ToEnumerable()); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Fable.Core.JsInterop.Debugger |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /// <summary>Wraps this object instance into an IEnumerable<T> consisting of a single item.</summary> | |
| /// <typeparam name="T"> Type of the object. </typeparam> | |
| /// <param name="item"> The instance that will be wrapped. </param> | |
| /// <returns> An IEnumerable<T> consisting of a single item. </returns> | |
| public static IEnumerable<T> Yield<T>(this T item) | |
| { | |
| yield return item; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| open Fable.Core | |
| open Fable.Core.JsInterop | |
| open Fable.Import | |
| type App() = | |
| member this.ChangeColor selector color = | |
| let element = Browser.document.querySelector selector :?> Browser.HTMLElement | |
| element.style.color <- color |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module Helper | |
| open Fable.Import.Browser | |
| let private toList (nodeList:NodeListOf<Element>) = | |
| let length = nodeList.length - 1.0 | |
| [0.0 .. length] | |
| |> List.map (fun i -> nodeList.item i :?> HTMLElement) | |
| let dollar selector (element:HTMLElement) = |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // <PackageReference Include="Microsoft.AspNetCore.Cors" Version="2.0.0" /> | |
| let configureApp (app : IApplicationBuilder) = | |
| app.UseGiraffeErrorHandler errorHandler | |
| app.UseCors(fun builder -> | |
| builder.WithOrigins("http://localhost:8080").AllowAnyMethod().AllowAnyHeader() |> ignore | |
| ) |> ignore | |
| let configureServices (services : IServiceCollection) = | |
| services.AddCors() |> ignore |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let mapPartition (partitioner : 'T -> Result<'U1, 'U2>) list : 'U1 list * 'U2 list = | |
| // OPTIMIZATION : If the input list is empty, immediately return empty results. | |
| if List.isEmpty list then | |
| [], [] | |
| else | |
| // Mutable variables are used here instead of List.fold for maximum performance. | |
| let mutable list = list | |
| let mutable resultList1 = [] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| const http = require('http') | |
| const port = 3000 | |
| const requestHandler = (request, response) => { | |
| console.log(request.url) | |
| response.end('Hello Node.js Server!') | |
| } | |
| const server = http.createServer(requestHandler) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| open System | |
| open Suave | |
| open Suave.Filters | |
| let subPath path (ctx:HttpContext) = | |
| async { | |
| let localPath = ctx.request.url.LocalPath | |
| let result = | |
| match (localPath.StartsWith(path)) with | |
| | false -> None |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta http-equiv="x-ua-compatible" content="ie=edge"> <!-- † --> | |
| <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
| <title>Page Title</title> | |
| </head> | |
| <body> | |
| </body> | |
| </html> |