diff --git a/api/index.html b/api/index.html index 4af77dd..7e09b9f 100644 --- a/api/index.html +++ b/api/index.html @@ -368,7 +368,7 @@

Partials

.isArrayConstraint(obj)
obj*An object to check
Returnsbooleantrue if obj is a cjs.ArrayConstraint, false otherwise
cjs.isConstraint(obj)

Determine whether an object is a constraint

.isConstraint(obj)
obj*An object to check
Returnsbooleanobj instanceof cjs.Constraint
cjs.isFSM(obj)

Determine whether an object is an FSM

.isFSM(obj)
obj*An object to check
Returnsbooleantrue if obj is an FSM, false otherwise
cjs.isMapConstraint(obj)

Determine whether an object is a map constraint

-
.isMapConstraint(obj)
obj*An object to check
Returnsbooleantrue if obj is a cjs.MapConstraint, false otherwise
cjs.liven(func, [options])

Memoize a function to avoid unnecessary re-evaluation. Its options are:

+
.isMapConstraint(obj)
obj*An object to check
Returnsbooleantrue if obj is a cjs.MapConstraint, false otherwise
cjs.liven(func, [options])

Memoize a function to avoid unnecessary re-evaluation. Its options are:

  • context: The context in which func should be evaluated
  • run_on_create: Whether to run func immediately after creating the live function. (default: true)
  • @@ -395,7 +395,7 @@

    Partials

    cobj.get('foo'); // 1 cobj.put('bar', 2); cobj.get('bar') // 2 -
cjs.memoize(getter_fn, [options])

Memoize a function to avoid unnecessary re-evaluation. Its options are:

+
cjs.memoize(getter_fn, [options])

Memoize a function to avoid unnecessary re-evaluation. Its options are:

  • hash: Create a unique value for each set of arguments (call with an argument array)
  • equals: check if two sets of arguments are equal (call with two argument arrays)
  • @@ -898,18 +898,18 @@

    Partials

  • literal_values: True if values that are functions should return a function rather than that function's return value. (default: false)
  • create_unsubstantiated: Create a constraint when searching for non-existent keys. (default: true)
-
.MapConstraint([options])
[options]ObjectA set of options to control how the map constraint is evaluated
cjs.MapConstraint.BREAK

Any iterator in forEach can return this object to break out of its loop.

-
cjs.MapConstraint.prototype.clear()

Clear every entry of this object.

+
.MapConstraint([options])
[options]ObjectA set of options to control how the map constraint is evaluated
cjs.MapConstraint.BREAK

Any iterator in forEach can return this object to break out of its loop.

+
cjs.MapConstraint.prototype.clear()

Clear every entry of this object.

.clear()
Returnscjs.MapConstraintthis

Example:

var map = cjs({x: 1, y: 2});
 map.isEmpty(); // false
 map.clear();
 map.isEmpty(); // true
-
cjs.MapConstraint.prototype.destroy([silent=false])

Clear this object and try to clean up any memory.

-
.destroy([silent=false])
[silent=false]booleanIf set to true, avoids invalidating any dependent constraints.
cjs.MapConstraint.prototype.entries()

Get every key and value of this object as an array.

+
cjs.MapConstraint.prototype.destroy([silent=false])

Clear this object and try to clean up any memory.

+
.destroy([silent=false])
[silent=false]booleanIf set to true, avoids invalidating any dependent constraints.
cjs.MapConstraint.prototype.entries()

Get every key and value of this object as an array.

.entries()
Returnsarray.objectA set of objects with properties key and value

Example:

var map = cjs({x: 1, y: 2});
 map.entries(); // [{key:'x',value:1},
                //  {key:'y',value:2}]
-
cjs.MapConstraint.prototype.forEach(callback, thisArg)

The forEach() method executes a provided function once per entry. +

cjs.MapConstraint.prototype.forEach(callback, thisArg)

The forEach() method executes a provided function once per entry. If cjs.MapConstraint.BREAK is returned for any element, we stop looping

.forEach(callback, thisArg)
callbackfunctionFunction to execute for each entry.
thisArg*Object to use as this when executing callback.
Returnscjs.MapConstraintthis

Example:

var map = cjs({x:1,y:2,z:3});
 map.forEach(function(val, key) {
@@ -918,12 +918,12 @@ 

Partials

return cjs.MapConstraint.BREAK; } }); // x:1 ... y:2 -
cjs.MapConstraint.prototype.get(key)

Get the item at key (like this[key])

+
cjs.MapConstraint.prototype.get(key)

Get the item at key (like this[key])

.get(key)
key*The entry's key
Returns*,undefinedthe value at that entry or undefined

Example:

var map = cjs({x: 1, y: 2});
 map.get("x"); // 1
 
cjs.MapConstraint.prototype.getOrPut(key, create_fn, [create_fn_context], [index=this.size], [literal=false])

Search for a key or create it if it wasn't found

+
cjs.MapConstraint.prototype.getOrPut(key, create_fn, [create_fn_context], [index=this.size], [literal=false])

Search for a key or create it if it wasn't found

.getOrPut(key, create_fn, [create_fn_context], [index=this.size], [literal=false])
key*The key to search for.
create_fnfunctionA function to create the value if key is not found
[create_fn_context]*The context in which to call create_fn
[index=this.size]numberWhere to place a value that is created
[literal=false]booleanWhether to create the value as a literal constraint (the value of a function is the function)
ReturnsnumberThe index of the entry with key=key or -1

Example:

var map = xjs({x: 1, y: 2});
 map.getOrPut('x', function() {
@@ -936,16 +936,16 @@ 

Partials

return 3; }); // (no output) // 3 -
cjs.MapConstraint.prototype.has(key)

Check if there is any entry with key = key

+
cjs.MapConstraint.prototype.has(key)

Check if there is any entry with key = key

.has(key)
key*The key to search for.
Returnsbooleantrue if there is an entry with key=key, false otherwise.

Example:

var map = cjs({x: 1, y: 2});
 map.has('x'); // true
-
cjs.MapConstraint.prototype.indexOf(key)

Get the index of the entry with key = key

+
cjs.MapConstraint.prototype.indexOf(key)

Get the index of the entry with key = key

.indexOf(key)
key*The key to search for.
ReturnsnumberThe index of the entry with key=key or -1

Example:

var map = cjs({x: 1, y: 2});
 map.indexOf('z'); // -1
-
cjs.MapConstraint.prototype.isEmpty()

Check if this object has any entries

+
cjs.MapConstraint.prototype.isEmpty()

Check if this object has any entries

.isEmpty()
Returnsbooleantrue if there are no entries, false otherwise

Example:

var map = cjs({x: 1, y: 2});
 map.isEmpty(); // false
-
cjs.MapConstraint.prototype.item(...)

Convert my value to a standard JavaScript object. The keys are converted using toString

+
cjs.MapConstraint.prototype.item(...)

Convert my value to a standard JavaScript object. The keys are converted using toString

.item()
ReturnsobjectA standard JavaScript object
.item(key)
keynumberThe object key
Returns*The value at index key
.item(key, value)
keynumberThe object key
value*The new value
Returnscjs.MapConstraintthis

Example:

var map = cjs({x: 1, y: 2});
 map.item(); // {x:1,y:2}
 
var map = cjs({x: 1, y: 2});
@@ -957,54 +957,54 @@ 

Partials

">cjs.MapConstraint.prototype.getOrPut
  • cjs.MapConstraint.prototype.get
  • cjs.MapConstraint.prototype.put
  • cjs.MapConstraint.prototype.getOrPut -
  • cjs.MapConstraint.prototype.itemConstraint(key)

    Return a constraint whose value is bound to my value for key

    +
    cjs.MapConstraint.prototype.itemConstraint(key)

    Return a constraint whose value is bound to my value for key

    .itemConstraint(key)
    key*,ConstraintThe array index
    ReturnsConstraintA constraint whose value is this[key]

    Example:

    var map = cjs({x: 1, y: 2});
     var x_val = map.itemConstraint('x');
     x_val.get(); // 1
     map.item('x', 3);
     x_val.get(); // 3
    -
    cjs.MapConstraint.prototype.keyForValue(value, [eq_check])

    Given a value, find the corresponding key

    +
    cjs.MapConstraint.prototype.keyForValue(value, [eq_check])

    Given a value, find the corresponding key

    .keyForValue(value, [eq_check])
    value*The value whose key to search for
    [eq_check]functionHow to check if two values are equal (default: ===
    Returns*,undefinedThe key where this.get(key)===value

    Example:

    var map = cjs({x: 1, y: 2, z: 3});
     map.keyForValue(1); // 'x'
    -
    cjs.MapConstraint.prototype.keys()

    Get the keys on this object.

    +
    cjs.MapConstraint.prototype.keys()

    Get the keys on this object.

    .keys()
    Returnsarray.*The set of keys

    Example:

    var map = cjs({x: 1, y: 2});
     map.keys(); // ['x','y']
    -
    cjs.MapConstraint.prototype.move(key, to_index)

    Move the entry with key key to `index

    +
    cjs.MapConstraint.prototype.move(key, to_index)

    Move the entry with key key to `index

    .move(key, to_index)
    key*The key to search for
    to_indexnumberThe new index for the key
    Returnscjs.ArrayConstraintthis

    Example:

    var map = cjs({x: 1, y: 2, z: 3});
     map.keys(); // ['x','y', 'z']
     map.move('z', 0)
     map.keys(); // ['z','x', 'y']
    -
    cjs.MapConstraint.prototype.moveIndex(old_index, new_index)

    Move the entry at old_index to index new_index

    +
    cjs.MapConstraint.prototype.moveIndex(old_index, new_index)

    Move the entry at old_index to index new_index

    .moveIndex(old_index, new_index)
    old_indexnumberThe index to move from
    new_indexnumberThe index to move to
    Returnscjs.ArrayConstraintthis

    Example:

    var map = cjs({x: 1, y: 2, z: 3});
     map.keys(); // ['x','y', 'z']
     map.moveIndex(1, 0)
     map.keys(); // ['y','x', 'z']
    -
    cjs.MapConstraint.prototype.put(key, value, [index=this.size], [literal])

    Set the entry for key to value (this[key]=value)

    +
    cjs.MapConstraint.prototype.put(key, value, [index=this.size], [literal])

    Set the entry for key to value (this[key]=value)

    .put(key, value, [index=this.size], [literal])
    key*The entry's key
    value*The entry's value
    [index=this.size]numberThe entry's index
    [literal]booleanWhether to treat the value as literal
    Returnscjs.MapConstraintthis

    Example:

    var map = cjs({x: 1, y: 2});
     map.put("z", 3, 1);
     map.keys(); // ['x','z','y']
     
    cjs.MapConstraint.prototype.remove(key)

    Remove a key's entry (like delete this[key])

    +
    cjs.MapConstraint.prototype.remove(key)

    Remove a key's entry (like delete this[key])

    .remove(key)
    key*The entry's key
    Returnscjs.MapConstraintthis

    Example:

    var map = cjs({x: 1, y: 2});
     map.remove("x");
     map.keys(); // ['y']
     
    cjs.MapConstraint.prototype.setEqualityCheck(equality_check)

    Change the default equality check when getting a key

    -
    .setEqualityCheck(equality_check)
    equality_checkfunctionThe new key equality check
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.setHash(hash)

    Change the hash function when getting a key

    -
    .setHash(hash)
    hashfunction,stringThe new hashing function (or a string representing a property name for every key to use as the hash)
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.setValueEqualityCheck(vequality_check)

    Change the default value equality check when getting a value

    -
    .setValueEqualityCheck(vequality_check)
    vequality_checkfunctionThe new value equality check
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.setValueHash(hash)

    Change the hash function when getting a value

    -
    .setValueHash(hash)
    hashfunction,stringThe new hashing function (or a string representing a property name for every key to use as the hash)
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.size()

    Get the number of entries in this object.

    +
    cjs.MapConstraint.prototype.setEqualityCheck(equality_check)

    Change the default equality check when getting a key

    +
    .setEqualityCheck(equality_check)
    equality_checkfunctionThe new key equality check
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.setHash(hash)

    Change the hash function when getting a key

    +
    .setHash(hash)
    hashfunction,stringThe new hashing function (or a string representing a property name for every key to use as the hash)
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.setValueEqualityCheck(vequality_check)

    Change the default value equality check when getting a value

    +
    .setValueEqualityCheck(vequality_check)
    vequality_checkfunctionThe new value equality check
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.setValueHash(hash)

    Change the hash function when getting a value

    +
    .setValueHash(hash)
    hashfunction,stringThe new hashing function (or a string representing a property name for every key to use as the hash)
    Returnscjs.ArrayConstraintthis
    cjs.MapConstraint.prototype.size()

    Get the number of entries in this object.

    .size()
    ReturnsnumberThe number of entries

    Example:

    var map = cjs({x: 1, y: 2});
     map.size(); // 2
    -
    cjs.MapConstraint.prototype.toObject([key_map_fn])

    Converts this array to a JavaScript object.

    +
    cjs.MapConstraint.prototype.toObject([key_map_fn])

    Converts this array to a JavaScript object.

    .toObject([key_map_fn])
    [key_map_fn]functionA function to convert keys
    ReturnsobjectThis object as a JavaScript object

    Example:

    var map = cjs({x: 1, y: 2, z: 3});
     map.toObject(); // {x:1,y:2,z:3}
    -
    cjs.MapConstraint.prototype.values()

    Get the values on this object.

    +
    cjs.MapConstraint.prototype.values()

    Get the values on this object.

    .values()
    Returnsarray.*The set of values

    Example:

    var map = cjs({x: 1, y: 2});
     map.values(); // [1,2]
    -