We're sure you have your reasons.
What if we could do FFI without writing javascript much, if it all?
This library sits at the unsafeCoerce
end of the safety scale - it
is expected that your usage of these functions will provide the
necessary safety while we provide the primitives with low overhead and
little imposition upon how you structure your code.
import FFI.Simple
import Data.Array as A
foreign import data React :: Type
foreign import data Element :: Type
react :: React
react = require 'react'
createElement :: forall r. String -> Record r -> Array Element -> Element
createElement c p cs = applyTo react (args3 c p cs)
Send it a message -- Joe Armstrong (1950-2019)
Improvements:
F.S.Globals
:- Made
global
check not justwindow
, but alsoglobalThis
,global
, so supporting any environment. But nodejs is shit, so it's basically useless in that environment.
- Made
- Improved tests for existing functionality
New:
F.S.Functions
:new
F.S.Objects
:- Property checks:
hasOwnProperty
- non-inherited propsisIn
- possibly inherited props
- Safer Property access:
(.?)
maybeGetProperty
maybeGetProperty'
- Property checks:
F.S.Undef
:maybeUndef
- theMaybe
analogue ofnullUndef
Improvements:
F.S.Globals
:- Warns on module load if
window
is not defined - If
window
is not defined:global
will always returnNothing
unsafeGlobal
will always quietly returnundef
- Warns on module load if
Breakages:
F.S.Undef
:Undefined
->Undef
undefined
->undef
New:
F.S.Globals
:unsafeGlobal
- Assume a global will be present, quietly returnundef
if it is not. (Bring your own safety!)
Breakages:
F.S.Functions
:bind'
->bindTo
apply
->applyTo
delay
now takes a value to provide
F.S.Objects
:typeof
->typeOf
New:
F.S.Globals
(new module):global
- look up a global by name
F.S.Objects
:instanceOf
- wrapper for jsinstanceof
(.=)
/setProperty'
to set a property(!=)
/defineProperty'
to define a readonly property
- Remove
F.S.Require
as i can't figure out how to make a build work with it. - Remove
call
,callMethod
andcallMethod'
fromF.S.Functions
- Add
F.S.Functions.delay
- Made dotty operators infixl
- Depend on effect and refs
- Add
F.S.PseudoArray.unshift
Copyright (c) 2019 James Laver
This software is free and open source software licensed under the terms of the Mozilla Public License (MPL) 2.0