Skip to content
Functions for working with homogeneous JavaScript objects
PureScript JavaScript
Branch: master
Clone or download
garyb Merge pull request #9 from bouzuya/remove-unused-fn
Remove unused _unsafeDeleteObject
Latest commit 8a7dc21 Jun 9, 2019


Latest release Build status

Functions for working with homogeneous JavaScript objects from PureScript. Similar to using Map String a but simply reusing JavaScript objects.


bower install purescript-foreign-object


example = do
    -- make an empty Object
    empty = FO.empty

    -- insert to an empty Object
    inserted = FO.insert "a" 1 empty

    -- or: use the singleton function
    -- singleton FO.singleton "a" 1

  -- lookup values for existing in the Object as a result of Maybe
  let lookup = FO.lookup "a" inserted
  Assert.assertEqual { actual: lookup, expected: Just 1 }

  -- delete a value from an Object
  let deleted = FO.delete "a" inserted
  Assert.assertEqual { actual: deleted, expected: FO.empty }

    -- convert homogeneous records to Object
    converted = FO.fromHomogeneous { a: 1, b: 2, c: 3}
    -- check that the converted is equal to a regularly built Object
      = FO.empty
      # FO.insert "a" 1
      # FO.insert "b" 2
      # FO.insert "c" 3

  Assert.assertEqual { actual: converted, expected: built }

See the tests for more examples.


Module documentation is published on Pursuit.

You can’t perform that action at this time.