Constants Reference
๐ข Shared constants and aliases to static methods, values and symbols.
Usage
๐ฆ Node
Install @lou.codes/constants
as a dependency:
Import it and use it:
๐ฆ Deno
Import @lou.codes/constants
using the npm:
prefix, and use it directly:
๐ Browser
Import @lou.codes/constants
using esm.sh, and use it directly:
Useful links
- ๐ Documentation: TypeDoc generated documentation.
- โณ Changelog: List of changes between versions.
Array
Functions
from()
from(arrayLike)
Creates an array from an array-like object.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
arrayLike | ArrayLike <T > | An array-like object to convert to an array. |
Returns
T
[]
from(arrayLike, mapfn, thisArg)
Creates an array from an iterable object.
Type parameters
Type parameter |
---|
T |
U |
Parameters
Parameter | Type | Description |
---|---|---|
arrayLike | ArrayLike <T > | An array-like object to convert to an array. |
mapfn | (v : T , k : number ) => U | A mapping function to call on every element of the array. |
thisArg ? | any | Value of โthisโ used to invoke the mapfn. |
Returns
U
[]
from(iterable)
Creates an array from an iterable object.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
iterable | Iterable <T > | ArrayLike <T > | An iterable object to convert to an array. |
Returns
T
[]
from(iterable, mapfn, thisArg)
Creates an array from an iterable object.
Type parameters
Type parameter |
---|
T |
U |
Parameters
Parameter | Type | Description |
---|---|---|
iterable | Iterable <T > | ArrayLike <T > | An iterable object to convert to an array. |
mapfn | (v : T , k : number ) => U | A mapping function to call on every element of the array. |
thisArg ? | any | Value of โthisโ used to invoke the mapfn. |
Returns
U
[]
isArray()
Parameters
Parameter | Type |
---|---|
arg | any |
Returns
arg is any[]
Number
Functions
isFinite()
Returns true if passed value is finite. Unlike the global isFinite, Number.isFinite doesnโt forcibly convert the parameter to a number. Only finite values of the type number, result in true.
Parameters
Parameter | Type | Description |
---|---|---|
number | unknown | A numeric value. |
Returns
boolean
isNaN()
Returns a Boolean value that indicates whether a value is the reserved value NaN (not a number). Unlike the global isNaN(), Number.isNaN() doesnโt forcefully convert the parameter to a number. Only values of the type number, that are also NaN, result in true.
Parameters
Parameter | Type | Description |
---|---|---|
number | unknown | A numeric value. |
Returns
boolean
isSafeInteger()
Returns true if the value passed is a safe integer.
Parameters
Parameter | Type | Description |
---|---|---|
number | unknown | A numeric value. |
Returns
boolean
Object
Functions
assign()
assign(target, source)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.
Type parameters
Type parameter |
---|
T extends object |
U |
Parameters
Parameter | Type | Description |
---|---|---|
target | T | The target object to copy to. |
source | U | The source object from which to copy properties. |
Returns
T
& U
assign(target, source1, source2)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.
Type parameters
Type parameter |
---|
T extends object |
U |
V |
Parameters
Parameter | Type | Description |
---|---|---|
target | T | The target object to copy to. |
source1 | U | The first source object from which to copy properties. |
source2 | V | The second source object from which to copy properties. |
Returns
T
& U
& V
assign(target, source1, source2, source3)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.
Type parameters
Type parameter |
---|
T extends object |
U |
V |
W |
Parameters
Parameter | Type | Description |
---|---|---|
target | T | The target object to copy to. |
source1 | U | The first source object from which to copy properties. |
source2 | V | The second source object from which to copy properties. |
source3 | W | The third source object from which to copy properties. |
Returns
T
& U
& V
& W
assign(target, sources)
Copy the values of all of the enumerable own properties from one or more source objects to a target object. Returns the target object.
Parameters
Parameter | Type | Description |
---|---|---|
target | object | The target object to copy to. |
โฆsources | any [] | One or more source objects from which to copy properties |
Returns
any
create()
Alias for Object.create(null)
combined with Object.assign
to create an
object without prototype.
Type parameters
Type parameter | Value |
---|---|
OutputType | object |
Parameters
Parameter | Type |
---|---|
object ? | OutputType |
Returns
OutputType
Object with no prototype.
See
defineProperty()
Adds a property to an object, or modifies attributes of an existing property.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
o | T | Object on which to add or modify the property. This can be a native JavaScript object (that is, a user-defined object or a built in object) or a DOM object. |
p | PropertyKey | The property name. |
attributes | PropertyDescriptor & ThisType <any > | Descriptor for the property. It can be for a data property or an accessor property. |
Returns
T
entries()
entries(o)
Returns an array of key/values of the enumerable properties of an object
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
o | object | ArrayLike <T > | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
[string
, T
][]
entries(o)
Returns an array of key/values of the enumerable properties of an object
Parameters
Parameter | Type | Description |
---|---|---|
o | object | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
[string
, any
][]
freeze()
freeze(f)
Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
Type parameters
Type parameter |
---|
T extends Function |
Parameters
Parameter | Type | Description |
---|---|---|
f | T | Object on which to lock the attributes. |
Returns
T
freeze(o)
Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
Type parameters
Type parameter |
---|
T extends object |
| U
extends | string
| number
| bigint
| boolean
| symbol
|
Parameters
Parameter | Type | Description |
---|---|---|
o | T | Object on which to lock the attributes. |
Returns
Readonly
<T
>
freeze(o)
Prevents the modification of existing property attributes and values, and prevents the addition of new properties.
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
o | T | Object on which to lock the attributes. |
Returns
Readonly
<T
>
fromEntries()
fromEntries(entries)
Returns an object created by key-value entries for properties and methods
Type parameters
Type parameter | Value |
---|---|
T | any |
Parameters
Parameter | Type | Description |
---|---|---|
entries | Iterable <readonly [PropertyKey , T ]> | An iterable object that contains key-value entries for properties and methods. |
Returns
object
fromEntries(entries)
Returns an object created by key-value entries for properties and methods
Parameters
Parameter | Type | Description |
---|---|---|
entries | Iterable <readonly any []> | An iterable object that contains key-value entries for properties and methods. |
Returns
any
getOwnPropertyDescriptor()
Gets the own property descriptor of the specified object. An own property descriptor is one that is defined directly on the object and is not inherited from the objectโs prototype.
Parameters
Parameter | Type | Description |
---|---|---|
o | any | Object that contains the property. |
p | PropertyKey | Name of the property. |
Returns
undefined
| PropertyDescriptor
getPrototypeOf()
Returns the prototype of an object.
Parameters
Parameter | Type | Description |
---|---|---|
o | any | The object that references the prototype. |
Returns
any
hasOwn()
Determines whether an object has a property with the specified name.
Parameters
Parameter | Type | Description |
---|---|---|
o | object | An object. |
v | PropertyKey | A property name. |
Returns
boolean
is()
Returns true if the values are the same value, false otherwise.
Parameters
Parameter | Type | Description |
---|---|---|
value1 | any | The first value. |
value2 | any | The second value. |
Returns
boolean
keys()
keys(o)
Returns the names of the enumerable string properties and methods of an object.
Parameters
Parameter | Type | Description |
---|---|---|
o | object | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
string
[]
keys(o)
Returns the names of the enumerable string properties and methods of an object.
Parameters
Parameter | Type | Description |
---|---|---|
o | object | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
string
[]
values()
values(o)
Returns an array of values of the enumerable properties of an object
Type parameters
Type parameter |
---|
T |
Parameters
Parameter | Type | Description |
---|---|---|
o | object | ArrayLike <T > | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
T
[]
values(o)
Returns an array of values of the enumerable properties of an object
Parameters
Parameter | Type | Description |
---|---|---|
o | object | Object that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object. |
Returns
any
[]
Reflect
Functions
ownKeys()
Returns the string and symbol keys of the own properties of an object. The own properties of an object are those that are defined directly on that object, and are not inherited from the objectโs prototype.
Parameters
Parameter | Type | Description |
---|---|---|
target | object | Object that contains the own properties. |
Returns
(string
| symbol
)[]
String
Functions
raw()
String.raw is usually used as a tag function of a Tagged Template String. When called as such, the first argument will be a well formed template call site object and the rest parameter will contain the substitution values. It can also be called directly, for example, to interleave strings and values from your own tag function, and in this case the only thing it needs from the first argument is the raw property.
Parameters
Parameter | Type | Description |
---|---|---|
template | object | A well-formed template string call site representation. |
template.raw | readonly string [] | ArrayLike <string > | - |
โฆsubstitutions | any [] | A set of substitution values. |
Returns
string
Symbol
Variables
asyncIterator
Alias for Symbol.asyncIterator
.
See
iterator
Alias for Symbol.iterator
.
See
empty
Variables
EMPTY_ARRAY
Empty read only array.
EMPTY_OBJECT
Empty readonly object.
EMPTY_STRING
Empty string.