Global

Members

(constant) typedArrays

Source:

List of all types that are typed ar­rays

(constant) supports

Source:

Test if the given trait has been im­ple­men­ted for the given type

(constant) valueSupports

Source:

Test if the given trait has been im­ple­men­ted for the given value

(constant) eq

Source:

De­term­ine whether two val­ues are equal us­ing the Equals trait.

This func­tion is a bit more power­ful than than the Equals trait it­self: First of all it searches for a Equals im­ple­ment­a­tion for both ar­gu­ments and it falls back to === if none is found. For this reason us­ing eq() is usu­ally pre­ferred over us­ing the Equals trait dir­ectly.

(constant) uneq

Source:

Equi­val­ent to !eq(a, b)

(constant) get

Source:

Given a key, get a value from a con­tainer.

(constant) has

Source:

Test if a con­tainer in­cludes an entry with the given key

(constant) assign

Source:

Set a value in a con­tainer. Al­ways re­turns the given value.

(constant) del

Source:

De­lete an entry with the given key from a con­tainer

(constant) setdefault

Source:

Set a de­fault value in a con­tainer.

(constant) replace

Source:

Swap out one value in a con­tainer for an­other

Methods

isdef()

Source:

Checks whether a value is defined.

is­def(null) # => false
is­def(un­defined) # => false
is­def(0) # => true
is­def(false) # => true

This func­tion con­siders all val­ues that are not null and not un­defined to be defined.

type()

Source:

De­term­ine type of an ob­ject.#

class Bar {};

type(null) # => null
type(un­defined) # => un­defined
type(42) # => Num­ber
type(new Num­ber(42)) # => Num­ber
type(new Bar()) # => Bar

Like obj.con­structor, but won't fail for null/​un­defined and just re­turns the value it­self for those. This is a use­ful fea­ture for code that is sup­posed to be null/​un­defined-safe since those need not be spe­cial cased.

typename()

Source:

Given a type, de­term­ine it's name.

class Bar {};

type­name(null) # => "null"
type­name(un­defined) # => "un­defined"
type­name(42) # => "Num­ber"
type­name(new Bar()) # => "Bar"

This is use­ful as a re­place­ment for val.con­structor.name, since this can deal with null and un­defined.

isPrimitive()

Source:

Test if a value is prim­it­ive

isPrim­it­ive(null) # => true
isPrim­it­ive(un­defined) # => true
isPrim­it­ive(42) # => true
isPrim­it­ive({}) # => false
isPrim­it­ive(new Num­ber(42)) # => false

typeIsImmutable()

Source:

Test whether in­stance of a given type is im­mut­able

isImmutable()

Source:

Test whether a given value is im­mut­able

assertEquals()

Source:

As­sert that eq(ac­tual, ex­pec­ted)

assertUneq()

Source:

As­sert that !eq(ac­tual, ex­pec­ted)

size()

Source:

De­term­ine the size of a con­tainer. Uses the Size trait

empty()

Source:

De­term­ine if a con­tainer is empty. Uses size(x) === 0

shallowclone()

Source:

Shal­lowly clone an ob­ject

deepclone()

Source:

Re­curs­ively clone an ob­ject

pairs()

Source:

Get an iter­ator over any con­tainer; al­ways re­turns pairs [key, value]

(generator) keys()

Source:

Get an iter­ator over the keys of a con­tainer. Uses pairs(c).

(generator) values()

Source:

Get an iter­ator over the val­ues of a con­tainer. Uses pairs(c).