Skip to content
Jonathan Potter edited this page Jun 5, 2014 · 11 revisions

cloneObject(x)

cloneObject : Object -> Object

Types

x : Object
return : Object

Description

Returns a copy of x.

extend(x, y)

extend : Object -> Object -> Object

Types

x : Object
y : Object
return : Object

Description

Returns an object that has all the keys/values of both x and y. If x and y have the same key then it will use y's value.

lookup(propertyName, obj)

lookup : String -> Object -> Maybe a

Types

propertyName : String
obj : Object
return : Maybe

Description

Accesses the specified property of the object. If propertyName is a valid property on obj this returns a Just; otherwise it returns a Nothing.

Example
tlc.lookup("one", {one: 1}); // Just 1
tlc.lookup("two", {one: 1}); // Nothing

prop(propertyName, obj)

prop : String -> Object -> a

Types

propertyName : String
obj : Object
return : Any

Description

Accesses the specified property of the object. This is an unsafe version of tlc.prop so use it only when the property must exist. tlc.prop(propertyName, obj) is equivalent to obj[propertyName].

Example

If you have an array of DOM elements, xs, and you want to get their offset widths you can do the following.

tlc.map(tlc.prop("offsetWidth"), xs); // [132, 493, ...]

propCall(propertyName, args, obj)

propCall : String -> [a] -> Object -> b

Types

propertyName : String
args : Array
obj : Object
return : Any

Description

Calls the specified property of the object. tlc.propCall(propertyName, [arg1, arg2, ...], obj) is equivalent to obj[propertyName](arg1, arg2, ...).

Example

If you have an array of DOM elements, xs, and you want to get only the ones that have children, you can do the following.

tlc.filter(tlc.propCall("hasChildNodes", []), xs);

API

  • [Array](API Array)
  • [Function](API Function)
  • [Maybe](API Maybe)
  • [Object](API Object)
  • [Set](API Set)
  • [Typeclass](API Typeclass)

Guides

  • [Operators](Guide Operators)
  • [Typeclasses](Guide Typeclasses)
  • [Replacing OOP](Guide Replacing Object Oriented Programming)

General

Clone this wiki locally