new Facets()
- Description:
Represents a
baja:Facetsin BajaScript.BFacetsis a map of name/value pairs used to annotate a
BComplex's Slot or to just provide additional metadata
about something. The values of facets may only be
BIDataValues which are a predefined subset of simples.When creating a
Simple, always use themake()method instead of
creating a new Object.
- Source:
Extends
Members
decodeFromString
- Description:
Decode a
Stringto aFacets.
- Source:
- Overrides:
Decode a String to a Facets.
(static) DEFAULT :baja.Facets
- Description:
Default
Facetsinstance.
- Source:
Default Facets instance.
Type:
(static) NULL :baja.Facets
- Description:
NULL
Facetsinstance.
- Source:
NULL Facets instance.
Type:
Methods
decodeAsync(str, batchopt) → {Promise.<baja.Facets>}
- Description:
Decode a
Stringto aFacets, doing an async decode on each individual
encoded Simple.
- Source:
- Overrides:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
str |
String | ||
batch |
baja.comm.Batch |
<optional> |
Returns:
- Type
- Promise.<baja.Facets>
encodeToString() → {String}
- Description:
Encode
Facetsto aString.
- Source:
- Overrides:
Returns:
- Type
- String
equals(obj) → {Boolean}
- Description:
Equality test.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Returns:
- Type
- Boolean
equivalent(obj) → {Boolean}
- Description:
Equivalence test.
equivalent()is used to compare if two Objects have equivalent
state, but might not want to return true for equals since it
it has implied semantics for many operations. The default
implementation returns the result of baja.Object#equals.
- Source:
- Inherited From:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Returns:
- Type
- Boolean
get(key, defopt)
- Description:
Return a value from the map for the given key.
- Source:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
key |
String | the key used to look up the data value |
|
def |
<optional> |
if defined, this value is returned if the key can't be found. |
Returns:
the data value for the key (null if not found)
getAgents(isopt, batchopt) → {Promise}
- Description:
Returns a promise that resolves to the agent list for this Object.
- Source:
- Inherited From:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
is |
Array.<String> |
<optional> |
An optional array of filters to add to the |
batch |
baja.comm.Batch |
<optional> |
An optional object used to batch network |
Returns:
A promise that will resolve with the Agent Info.
- Type
- Promise
getIcon() → {baja.Icon}
- Description:
Return the Object's Icon.
- Source:
- Inherited From:
Returns:
- Type
- baja.Icon
getKeys() → {Array.<String>}
- Description:
Return a copy of the
Facetskeys.
- Source:
Returns:
all of the keys used in the Facets
- Type
- Array.<String>
getType() → {Type}
- Description:
Get the type of this instance.
- Source:
- Inherited From:
Returns:
- Type
- Type
getTypeDisplayName(cxopt) → {Promise.<string>|string}
- Description:
Gets the friendly type display name for this object.
- Source:
- Since:
- Niagara 4.10
- Inherited From:
- See:
-
- baja.Type#getDisplayName
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cx |
Object |
<optional> |
a context to be passed down to Type |
Returns:
If no context is provided, the type
display name is returned synchronously as a string. If context provided,
the type display name is resolved via a promise as a string.
- Type
- Promise.<string> | string
make()
- Description:
Make a
Facetsobject. Same as baja.Facets.make.
- Source:
- Overrides:
- See:
makeRemove(key) → {baja.Facets}
- Description:
Removes the key from the provided facets and returns a new facets. If the orig facets doesn't
contain the specified key then return the original instance.
- Source:
- Since:
- Niagara 4.14
Parameters:
| Name | Type | Description |
|---|---|---|
key |
String | the key in the facets to remove |
Returns:
- Type
- baja.Facets
newCopy(exactopt)
- Description:
Every value may be cloned using the
newCopymethod.Please note that
Simples are immutable so they don't
allocate a new instance.
- Source:
- Inherited From:
- See:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
exact |
Boolean |
<optional> |
true if an exact copy of the value should be |
Returns:
a copy of the value (or the same instance if the value is a
Simple).
toObject() → {Object}
- Description:
Converts the
Facets(itself) to an object literal.
- Source:
Returns:
- Type
- Object
toString(cxopt) → {String|Promise.<String>}
- Description:
Return a
Stringrepresentation of theFacets.
- Source:
- Overrides:
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
cx |
Object |
<optional> |
Passed directly into the toString() functions of the |
Returns:
returns a Promise if a cx is passed in.
valueOf() → {String}
- Description:
Return the value of the
Facets.
- Source:
- Overrides:
Returns:
- Type
- String
(static) getFacetsFromObject(obj) → {baja.Facets}
- Description:
Return the facets for the given object.
If the object is a
Facets, that object is returned.If the object has a
facetsslot, the value of that slot is returned.If the object has a parent, the
Facetsfrom the object's parent slot is
returned.If the facets can't be found then baja.Facets.DEFAULT is returned.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
obj |
Returns:
- Type
- baja.Facets
(static) make(keys, valuesopt) → {baja.Facets}
- Description:
Make a
Facetsobject. This function can either take twoArrayobjects
for keys and values, twoFacetsor two object literals. In the latter two
cases, a newFacetsobject will be returned containing a combination of
keys and values from both inputFacetsobjects. If a key exists on both
Facetsobjects, the value from the second Facets will take precedence.
- Source:
Example
var facets1 = baja.Facets.make(['a', 'b'], ['1', '2']);
var facets2 = baja.Facets.make(['b', 'c'], ['3', '4']);
var facets3 = baja.Facets.make(facets1, facets2);
baja.outln(facets3.get('a')); //1
baja.outln(facets3.get('b')); //3 - facets2 overwrote value in facets1
baja.outln(facets3.get('c')); //4
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
keys |
Array.<String> | baja.Facets | Object | an array of keys for the |
|
values |
Array.<baja.Simple> | baja.Facets | Object |
<optional> |
an array of values |
Returns:
the Facets
- Type
- baja.Facets
(static) mergeSlotFacets(containeropt, propertyPathopt) → {baja.Facets}
- Description:
Get the slot facets from a container, merged all the way down through a
property path or slot.
- Source:
- Since:
- Niagara 4.10
Parameters:
| Name | Type | Attributes | Description |
|---|---|---|---|
container |
baja.Complex |
<optional> |
|
propertyPath |
Array.<(baja.Property|string)> | baja.Property | string |
<optional> |
Returns:
- Type
- baja.Facets