Module

FFI.Simple.Objects

Package
purescript-ffi-simple
Repository
garganscript/purescript-ffi-simple

#typeOf Source

typeOf :: forall a. a -> String

Gets the type of an object with javascript typeof

#instanceOf Source

instanceOf :: forall a b. a -> b -> Boolean

Checks whether an object is an instance of an invokable

#named Source

named :: forall o. String -> o -> o

Return the object with a custom name Notes:

  • name is a readonly property, so we define over it
  • quietly mutates the input - use immediately after creation

#downcast Source

downcast :: forall ctor from to. ctor -> from -> Maybe to

Attempt to cast to a type given a constructor for it

#isIn Source

isIn :: forall a. String -> a -> Boolean

Is the given property found on the given object or via inheritance?

#keys Source

keys :: forall a. a -> Array String

Return a list of keys in the object

#hasOwnProperty Source

hasOwnProperty :: forall o. String -> o -> Boolean

Does this object have the given property itself (i.e. not inherited)?

#(..) Source

Operator alias for FFI.Simple.Objects.getProperty' (left-associative / precedence 9)

#getProperty Source

getProperty :: forall o v. String -> o -> v

Get the property with the given name form the given object If property does not exist, will be undefined (see F.S.Undef)

#getProperty' Source

getProperty' :: forall o v. o -> String -> v

flip getProperty

#(.?) Source

Operator alias for FFI.Simple.Objects.maybeGetProperty' (left-associative / precedence 9)

#maybeGetProperty Source

maybeGetProperty :: forall o v. String -> o -> Maybe v

Attempts to get a property from an object, returning Nothing if it was undefined

#maybeGetProperty' Source

maybeGetProperty' :: forall o v. o -> String -> Maybe v

flip maybeGetProperty

#(.=) Source

Operator alias for FFI.Simple.Objects.setProperty' (left-associative / precedence 9)

#setProperty Source

setProperty :: forall o v. String -> o -> v -> o

Sets a property on an object Notes:

  • Will probably throw an error if you try to set a readonly property
  • Is meant to be used in Effect

#setProperty' Source

setProperty' :: forall o v. o -> String -> v -> o

flip setProperty

#(!=) Source

Operator alias for FFI.Simple.Objects.defineProperty' (left-associative / precedence 9)

#defineProperty Source

defineProperty :: forall o v. String -> o -> v -> o

Defines a new readonly property. Useful for e.g. name which is a readonly prop

#defineProperty' Source

defineProperty' :: forall o v. o -> String -> v -> o

#(!-) Source

Operator alias for FFI.Simple.Objects.removeProperty' (left-associative / precedence 9)

#removeProperty Source

removeProperty :: forall o. String -> o -> o

#removeProperty' Source

removeProperty' :: forall o. o -> String -> o