48 lines
847 B
Forth
48 lines
847 B
Forth
namespace web_api_cookbook
|
|
|
|
open WebSharper
|
|
open WebSharper.UI
|
|
open WebSharper.UI.Client
|
|
|
|
[<JavaScript>]
|
|
module Option =
|
|
let getOrElse def opt =
|
|
if Option.isSome opt
|
|
then Option.get opt
|
|
else def
|
|
|
|
[<JavaScript>]
|
|
module Units =
|
|
module Animation =
|
|
[<Measure>]
|
|
type frames
|
|
module Time =
|
|
[<Measure>]
|
|
type ms
|
|
[<Measure>]
|
|
type s
|
|
|
|
[<JavaScript>]
|
|
module Doc =
|
|
let When show content =
|
|
function
|
|
| true -> content ()
|
|
| false -> Doc.Empty
|
|
|> View.MapCached <| show
|
|
|> Doc.EmbedView
|
|
|
|
[<JavaScript>]
|
|
module Math =
|
|
let clamp a b c =
|
|
if c < a then a
|
|
else if c > b then b
|
|
else c
|
|
|
|
[<Inline>]
|
|
let inline lerp a b t = a + t * (b - a)
|
|
|
|
[<AutoOpen>]
|
|
[<JavaScript>]
|
|
module Tuple2 =
|
|
let tuple2 a b = a,b
|