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 @@
.isArrayConstraint(obj) | ||
obj | * | An object to check |
Returns | boolean | true if obj is a cjs.ArrayConstraint , false otherwise |
Determine whether an object is a constraint
.isConstraint(obj) | ||
obj | * | An object to check |
Returns | boolean | obj instanceof cjs.Constraint |
Determine whether an object is an FSM
.isFSM(obj) | ||
obj | * | An object to check |
Returns | boolean | true if obj is an FSM , false otherwise |
Determine whether an object is a map constraint
-.isMapConstraint(obj) | ||
obj | * | An object to check |
Returns | boolean | true if obj is a cjs.MapConstraint , false otherwise |
Memoize a function to avoid unnecessary re-evaluation. Its options are:
+.isMapConstraint(obj) | ||
obj | * | An object to check |
Returns | boolean | true if obj is a cjs.MapConstraint , false otherwise |
Memoize a function to avoid unnecessary re-evaluation. Its options are:
context
: The context in which func
should be evaluatedrun_on_create
: Whether to run func
immediately after creating the live function. (default: true
)Memoize a function to avoid unnecessary re-evaluation. Its options are:
+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)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] | Object | A set of options to control how the map constraint is evaluated |
Any iterator in forEach can return this object to break out of its loop.
-Clear every entry of this object.
+.MapConstraint([options]) | ||
[options] | Object | A set of options to control how the map constraint is evaluated |
Any iterator in forEach can return this object to break out of its loop.
+Clear every entry of this object.
.clear() | ||
Returns | cjs.MapConstraint | this |
var map = cjs({x: 1, y: 2});
map.isEmpty(); // false
map.clear();
map.isEmpty(); // true
-
Clear this object and try to clean up any memory.
-.destroy([silent=false]) | ||
[silent=false] | boolean | If set to true , avoids invalidating any dependent constraints. |
Get every key and value of this object as an array.
+Clear this object and try to clean up any memory.
+.destroy([silent=false]) | ||
[silent=false] | boolean | If set to true , avoids invalidating any dependent constraints. |
Get every key and value of this object as an array.
.entries() | ||
Returns | array.object | A set of objects with properties key and value |
var map = cjs({x: 1, y: 2});
map.entries(); // [{key:'x',value:1},
// {key:'y',value:2}]
-
The forEach() method executes a provided function once per entry. +
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) | ||
callback | function | Function to execute for each entry. |
thisArg | * | Object to use as this when executing callback . |
Returns | cjs.MapConstraint | this |
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
-
Get the item at key (like this[key])
+Get the item at key (like this[key])
.get(key) | ||
key | * | The entry's key |
Returns | *,undefined | the value at that entry or undefined |
var map = cjs({x: 1, y: 2});
map.get("x"); // 1
Search for a key or create it if it wasn't found
+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_fn | function | A function to create the value if key is not found |
[create_fn_context] | * | The context in which to call create_fn |
[index=this.size] | number | Where to place a value that is created |
[literal=false] | boolean | Whether to create the value as a literal constraint (the value of a function is the function) |
Returns | number | The index of the entry with key=key or -1 |
var map = xjs({x: 1, y: 2});
map.getOrPut('x', function() {
@@ -936,16 +936,16 @@ Partials
return 3;
}); // (no output)
// 3
-
Check if there is any entry with key = key
Check if there is any entry with key = key
.has(key) | ||
key | * | The key to search for. |
Returns | boolean | true if there is an entry with key=key , false otherwise. |
var map = cjs({x: 1, y: 2});
map.has('x'); // true
-
Get the index of the entry with key = key
Get the index of the entry with key = key
.indexOf(key) | ||
key | * | The key to search for. |
Returns | number | The index of the entry with key=key or -1 |
var map = cjs({x: 1, y: 2});
map.indexOf('z'); // -1
-
Check if this object has any entries
+Check if this object has any entries
.isEmpty() | ||
Returns | boolean | true if there are no entries, false otherwise |
var map = cjs({x: 1, y: 2});
map.isEmpty(); // false
-
Convert my value to a standard JavaScript object. The keys are converted using toString
Convert my value to a standard JavaScript object. The keys are converted using toString
.item() | ||
Returns | object | A standard JavaScript object |
.item(key) | ||
key | number | The object key |
Returns | * | The value at index key |
.item(key, value) | ||
key | number | The object key |
value | * | The new value |
Returns | cjs.MapConstraint | this |
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
-
Return a constraint whose value is bound to my value for key
+Return a constraint whose value is bound to my value for key
.itemConstraint(key) | ||
key | *,Constraint | The array index |
Returns | Constraint | A constraint whose value is this[key] |
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
-
Given a value, find the corresponding key
+Given a value, find the corresponding key
.keyForValue(value, [eq_check]) | ||
value | * | The value whose key to search for |
[eq_check] | function | How to check if two values are equal (default: === |
Returns | *,undefined | The key where this.get(key)===value |
var map = cjs({x: 1, y: 2, z: 3});
map.keyForValue(1); // 'x'
-
Get the keys on this object.
+Get the keys on this object.
.keys() | ||
Returns | array.* | The set of keys |
var map = cjs({x: 1, y: 2});
map.keys(); // ['x','y']
-
Move the entry with key key
to `index
Move the entry with key key
to `index
.move(key, to_index) | ||
key | * | The key to search for |
to_index | number | The new index for the key |
Returns | cjs.ArrayConstraint | this |
var map = cjs({x: 1, y: 2, z: 3});
map.keys(); // ['x','y', 'z']
map.move('z', 0)
map.keys(); // ['z','x', 'y']
-
Move the entry at old_index
to index new_index
Move the entry at old_index
to index new_index
.moveIndex(old_index, new_index) | ||
old_index | number | The index to move from |
new_index | number | The index to move to |
Returns | cjs.ArrayConstraint | this |
var map = cjs({x: 1, y: 2, z: 3});
map.keys(); // ['x','y', 'z']
map.moveIndex(1, 0)
map.keys(); // ['y','x', 'z']
-
Set the entry for key
to value
(this[key]=value
)
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] | number | The entry's index |
[literal] | boolean | Whether to treat the value as literal |
Returns | cjs.MapConstraint | this |
var map = cjs({x: 1, y: 2});
map.put("z", 3, 1);
map.keys(); // ['x','z','y']
Remove a key's entry (like delete this[key]
)
Remove a key's entry (like delete this[key]
)
.remove(key) | ||
key | * | The entry's key |
Returns | cjs.MapConstraint | this |
var map = cjs({x: 1, y: 2});
map.remove("x");
map.keys(); // ['y']
Change the default equality check when getting a key
-.setEqualityCheck(equality_check) | ||
equality_check | function | The new key equality check |
Returns | cjs.ArrayConstraint | this |
Change the hash function when getting a key
-.setHash(hash) | ||
hash | function,string | The new hashing function (or a string representing a property name for every key to use as the hash) |
Returns | cjs.ArrayConstraint | this |
Change the default value equality check when getting a value
-.setValueEqualityCheck(vequality_check) | ||
vequality_check | function | The new value equality check |
Returns | cjs.ArrayConstraint | this |
Change the hash function when getting a value
-.setValueHash(hash) | ||
hash | function,string | The new hashing function (or a string representing a property name for every key to use as the hash) |
Returns | cjs.ArrayConstraint | this |
Get the number of entries in this object.
+Change the default equality check when getting a key
+.setEqualityCheck(equality_check) | ||
equality_check | function | The new key equality check |
Returns | cjs.ArrayConstraint | this |
Change the hash function when getting a key
+.setHash(hash) | ||
hash | function,string | The new hashing function (or a string representing a property name for every key to use as the hash) |
Returns | cjs.ArrayConstraint | this |
Change the default value equality check when getting a value
+.setValueEqualityCheck(vequality_check) | ||
vequality_check | function | The new value equality check |
Returns | cjs.ArrayConstraint | this |
Change the hash function when getting a value
+.setValueHash(hash) | ||
hash | function,string | The new hashing function (or a string representing a property name for every key to use as the hash) |
Returns | cjs.ArrayConstraint | this |
Get the number of entries in this object.
.size() | ||
Returns | number | The number of entries |
var map = cjs({x: 1, y: 2});
map.size(); // 2
-
Converts this array to a JavaScript object.
+Converts this array to a JavaScript object.
.toObject([key_map_fn]) | ||
[key_map_fn] | function | A function to convert keys |
Returns | object | This object as a JavaScript object |
var map = cjs({x: 1, y: 2, z: 3});
map.toObject(); // {x:1,y:2,z:3}
-
Get the values on this object.
+Get the values on this object.
.values() | ||
Returns | array.* | The set of values |
var map = cjs({x: 1, y: 2});
map.values(); // [1,2]
-