Create a new object as a shallow clone of the given object.
The object to clone.
Create an object from an iterable of key-value pairs, each pair defining one property in the created object.
The list of key-value pairs.
Create an object from an iterable of key-value pairs, each pair defining one property in the created object.
Create an object by transforming the property values of a source
object. The returned object has all the same property names as the source
object, but with (possibly) different values, as generated by the given
valueFunc
.
The valueFunc
is invoked with each "key" (a property name
from the source
object), the index of the property (based on iteration
order of the source
object's properties), a list of all the keys,
the corresponding "element" (property value) from the source
, and a
list of all the element values.
Note that only the enumerable properties of the source object are used.
> buildObject(
{a: "foo", b: "bar" },
(k, i, ks, e) => `${k}-${e}`
)
{ a: "a-foo", b: "b-bar" }
The source object.
A function that generates property values for the output object.
Create an object by replacing the property values of a source
object with corresponding values from an array of values. The
returned object has all the same property names as the source
object, but with (possibly) different values, as provided by
the values
array.
The enumerable properties of the source object are iterated over
and paired with corresponding values from values
; the property
values of the source object are ignored.
> buildObject(
{a: "foo", b: "bar" },
["one", "two", "ignored"]
)
{ a: "one", b: "two" }
The source object.
The array of property values.
Create an object by replacing the property values of a source object with corresponding values from another object.
Note that only the enumerable properties of the source object are used; the property values of the source object are ignored.
> buildObject(
{b: 1, d: 2},
{e: 10, d: 20, c: 30, b: 40, a: 50 }
)
{ b: 40, d: 20 }
The source object.
The object from which property values are taken.
Create an object by replacing the property value of every property in a source object with the given fixed value.
Note that only the enumerable properties of the source object are used; the property values of the source object are ignored. This only works for primitive typed values.
> buildObject(
{b: 1, d: 2},
"the one and only"
)
{ b: "the ony and only", d: "the one and only" }
The source object.
The value to use for every property.
Creates an object from a list (or other iterable) of "keys" (property values) and a function which generates the property values.
The valueFunc
is invoked with each "key" (a property name
from the source
object), the index of the property (based on iteration
order of the source
object's properties), a list of all the keys,
the corresponding "element" (property value) from the source
, and a
list of all the element values. In this case, the keys and the elements
are identical.
Note that only the enumerable properties of the source object are used.
> buildObject(
["a", "b"],
(k, i, ks, e) => `${k}-${e}`
)
{ a: "a-a", b: "b-b" }
The iterable of keys (property names).
A function that generates property values for the output object.
Creates an object from a list (or other iterable) of "keys" (property values) and a function which generates the property values.
The valueFunc
is invoked with each "key" (a property name
from the source
object), the index of the property (based on iteration
order of the source
object's properties), a list of all the keys,
the corresponding "element" (property value) from the source
, and a
list of all the element values. In this case, the keys and the elements
are identical.
Note that only the enumerable properties of the source object are used.
> buildObject(
["a", "b"],
(k, i, ks, e) => `${k}-${e}`
)
{ a: "a-a", b: "b-b" }
The iterable of keys (property names).
A function that generates property values for the output object.
Create an object by pairing corresponding elements from a list of keys (property names) and a list of values. Any iterable can be used in place of a list for the keys, but only an array can be used for the values.
> buildObject(
["a", "b"],
["one", "two", "ignored"]
)
{ a: "one", b: "two" }
The keys (property names).
The array of property values.
Create an object by copying the specified properties from the given object.
> buildObject(
["b", "d"],
{e: 10, d: 20, c: 30, b: 40, a: 50 }
)
{ b: 40, d: 20 }
The keys (property names).
The object from which property values are taken.
Create an object with the named properties, all of whom share the same primitive value.
> buildObject(
["b", "d"],
"the one and only"
)
{ b: "the ony and only", d: "the one and only" }
Note this only works for primitive typed values.
The keys (property names).
The value to use for every property.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are determined for each element from the given keyFunc
,
and property values are determined from the given valueFunc
.
The keyFunc
is invoked with each element and it's index within elements
, plus
a full list of all the elements, and the valueFunc
is invoked with each key (property
name) produced by the keyFunc
, the index, the set of all produced keys, plus the
corresponding elements and the set of all elements.
> buildObject(
["b", "d"],
e => e.toUpperCase(),
(k, i, ks, e) => `${k}-${e}`
)
{ B: "B-b", D: "D-d" }
The elements from which the properties are derived.
The function that caluclates property names from elements.
The function that calculates property values from keys and/or elements.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are determined for each element from the given keyFunc
,
and property values are taken from the corresponding index in the provided array.
The keyFunc
is invoked with each element and it's index within elements
, plus
a full list of all the elements.
> buildObject(
["b", "d"],
e => e.toUpperCase(),
(k, i, ks, e) => `${k}-${e}`
)
{ B: "B-b", D: "D-d" }
The elements from which the properties are derived.
The function that caluclates property names from elements.
The property values.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are determined for each element from the given keyFunc
,
and property values are taken from the corresponding properties of the given
valueSource
object (the property named by the produced key).
The keyFunc
is invoked with each element and it's index within elements
, plus
a full list of all the elements.
The elements from which the properties are derived.
The function that caluclates property names from elements.
The object that provides the property values.
Create an object by iterating over a set of elements and defining one property for
each, using the same fixedValue
for each property. Property names ("keys") are
determined for each element from the given keyFunc
.
The keyFunc
is invoked with each element and it's index within elements
, plus
a full list of all the elements.
The elements from which the properties are derived.
The function that caluclates property names from elements.
The value to use for all properties.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are taken from the corresponding index of the provided
keys
array, and property values are determined from the given valueFunc
.
The valueFunc
is invoked with each key (property
name) produced by the keyFunc
, the index, the set of all produced keys, plus the
corresponding elements and the set of all elements.
The elements from which the properties are derived.
The array of keys.
The function that calculates property values from keys and/or elements.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are taken from the corresponding index of the provided
keys
array, and property values are taken from the corresponding index in the
provided values
array.
The elements from which the properties are derived.
The array of keys.
The property values.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are taken from the corresponding index of the provided
keys
array, and property values are taken from the corresponding properties of the given
valueSource
object (the property named by the key).
The elements from which the properties are derived.
The array of keys.
The object that provides the property values.
Create an object by iterating over a set of elements and defining one property for
each, using the same fixedValue
for each property. Property names ("keys") are taken
from the corresponding index of the provided keys
array.
The elements from which the properties are derived.
The array of keys.
The value to use for all properties.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are taken from the corresponding property of the provided
keySource
object, and property values are determined from the given valueFunc
.
The valueFunc
is invoked with each key (property
name) produced by the keyFunc
, the index, the set of all produced keys, plus the
corresponding elements and the set of all elements.
The elements from which the properties are derived.
The function that calculates property values from keys and/or elements.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are taken from the corresponding property of the provided
keySource
object, and property values are taken from the corresponding index in the
provided values
array.
The elements from which the properties are derived.
The property values.
Create an object by iterating over a set of elements and defining one property for
each. Property names ("keys") are taken from the corresponding property of the provided
keySource
object, and property values are taken from the corresponding properties of the given
valueSource
object (the property named by the key).
The elements from which the properties are derived.
The object that provides the property values.
Create an object by iterating over a set of elements and defining one property for
each, using the same fixedValue
for each property. Property names ("keys") are taken
from the corresponding property of the provided keySource
object, and property values
are taken from the corresponding properties of the given
The elements from which the properties are derived.
The value to use for all properties.
Generated using TypeDoc
A pragmatic definition of a primitive type, which is to say, something we can differentiate from the other ValueSuppliers: arrays, functions, and objects.