Skip to content

Constants Reference

License NPM Version Open Issues Size

🔢 Shared constants and aliases to static methods, values and symbols.

Usage

📦 Node

Install @lou.codes/constants as a dependency:

Terminal window
1
pnpm add @lou.codes/constants
2
# or
3
npm install @lou.codes/constants
4
# or
5
yarn add @lou.codes/constants

Import it and use it:

1
import { iterator } from "@lou.codes/constants/Symbol.js";
2
3
console.log(iterator); // {}

🦕 Deno

Import @lou.codes/constants using the npm: prefix, and use it directly:

1
import { iterator } from "npm:@lou.codes/constants/Symbol.js";
2
3
console.log(iterator); // {}

🌎 Browser

Import @lou.codes/constants using esm.sh, and use it directly:

1
<script type="module">
2
import { iterator } from "https://esm.sh/@lou.codes/constants/Symbol.js";
3
4
console.log(iterator); // {}
5
</script>

Array

Functions

isArray()

1
function isArray(arg: any): arg is any[];
Parameters
ParameterType
argany
Returns

arg is any[]

View source

Object

Functions

assign()

assign(target, source)
1
function assign<T, U>(target: T, source: U): T & U;

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
ParameterTypeDescription
targetTThe target object to copy to.
sourceUThe source object from which to copy properties.
Returns

T & U

View source

assign(target, source1, source2)
1
function assign<T, U, V>(target: T, source1: U, source2: V): T & U & V;

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
ParameterTypeDescription
targetTThe target object to copy to.
source1UThe first source object from which to copy properties.
source2VThe second source object from which to copy properties.
Returns

T & U & V

View source

assign(target, source1, source2, source3)
1
function assign<T, U, V, W>(
2
target: T,
3
source1: U,
4
source2: V,
5
source3: W,
6
): T & U & V & W;

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
ParameterTypeDescription
targetTThe target object to copy to.
source1UThe first source object from which to copy properties.
source2VThe second source object from which to copy properties.
source3WThe third source object from which to copy properties.
Returns

T & U & V & W

View source

assign(target, sources)
1
function assign(target: object, ...sources: any[]): any;

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
ParameterTypeDescription
targetobjectThe target object to copy to.
sourcesany[]One or more source objects from which to copy properties
Returns

any

View source


create()

1
function create<OutputType>(object?: object): OutputType;

Alias for Object.create(null) combined with Object.assign to create an object without prototype.

Type parameters
Type parameterValue
OutputTypeobject
Parameters
ParameterType
object?object
Returns

OutputType

Object with no prototype.

See

View source


defineProperty()

1
function defineProperty<T>(
2
o: T,
3
p: PropertyKey,
4
attributes: PropertyDescriptor & ThisType<any>,
5
): T;

Adds a property to an object, or modifies attributes of an existing property.

Type parameters
Type parameter
T
Parameters
ParameterTypeDescription
oTObject 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.
pPropertyKeyThe property name.
attributesPropertyDescriptor & ThisType<any>Descriptor for the property. It can be for a data property or an accessor property.
Returns

T

View source


entries()

entries(o)
1
function entries<T>(o: object | ArrayLike<T>): [string, T][];

Returns an array of key/values of the enumerable properties of an object

Type parameters
Type parameter
T
Parameters
ParameterTypeDescription
oobject | 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][]

View source

entries(o)
1
function entries(o: object): [string, any][];

Returns an array of key/values of the enumerable properties of an object

Parameters
ParameterTypeDescription
oobjectObject 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][]

View source


freeze()

freeze(f)
1
function freeze<T>(f: T): T;

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Type parameters
Type parameter
T extends Function
Parameters
ParameterTypeDescription
fTObject on which to lock the attributes.
Returns

T

View source

freeze(o)
1
function freeze<T, U>(o: T): Readonly<T>;

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
ParameterTypeDescription
oTObject on which to lock the attributes.
Returns

Readonly<T>

View source

freeze(o)
1
function freeze<T>(o: T): Readonly<T>;

Prevents the modification of existing property attributes and values, and prevents the addition of new properties.

Type parameters
Type parameter
T
Parameters
ParameterTypeDescription
oTObject on which to lock the attributes.
Returns

Readonly<T>

View source


fromEntries()

fromEntries(entries)
1
function fromEntries<T>(entries: Iterable<readonly [PropertyKey, T]>): object;

Returns an object created by key-value entries for properties and methods

Type parameters
Type parameterValue
Tany
Parameters
ParameterTypeDescription
entriesIterable<readonly [PropertyKey, T]>An iterable object that contains key-value entries for properties and methods.
Returns

object

View source

fromEntries(entries)
1
function fromEntries(entries: Iterable<readonly any[]>): any;

Returns an object created by key-value entries for properties and methods

Parameters
ParameterTypeDescription
entriesIterable<readonly any[]>An iterable object that contains key-value entries for properties and methods.
Returns

any

View source


getOwnPropertyDescriptor()

1
function getOwnPropertyDescriptor(
2
o: any,
3
p: PropertyKey,
4
): undefined | PropertyDescriptor;

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
ParameterTypeDescription
oanyObject that contains the property.
pPropertyKeyName of the property.
Returns

undefined | PropertyDescriptor

View source


getPrototypeOf()

1
function getPrototypeOf(o: any): any;

Returns the prototype of an object.

Parameters
ParameterTypeDescription
oanyThe object that references the prototype.
Returns

any

View source


hasOwn()

1
function hasOwn(o: object, v: PropertyKey): boolean;

Determines whether an object has a property with the specified name.

Parameters
ParameterTypeDescription
oobjectAn object.
vPropertyKeyA property name.
Returns

boolean

View source


is()

1
function is(value1: any, value2: any): boolean;

Returns true if the values are the same value, false otherwise.

Parameters
ParameterTypeDescription
value1anyThe first value.
value2anyThe second value.
Returns

boolean

View source


values()

values(o)
1
function values<T>(o: object | ArrayLike<T>): T[];

Returns an array of values of the enumerable properties of an object

Type parameters
Type parameter
T
Parameters
ParameterTypeDescription
oobject | 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[]

View source

values(o)
1
function values(o: object): any[];

Returns an array of values of the enumerable properties of an object

Parameters
ParameterTypeDescription
oobjectObject that contains the properties and methods. This can be an object that you created or an existing Document Object Model (DOM) object.
Returns

any[]

View source

Reflect

Functions

ownKeys()

1
function ownKeys(target: object): (string | symbol)[];

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
ParameterTypeDescription
targetobjectObject that contains the own properties.
Returns

(string | symbol)[]

View source

Symbol

Variables

asyncIterator

1
const asyncIterator: typeof Symbol.asyncIterator = SymbolAlias.asyncIterator;

Alias for Symbol.asyncIterator.

See

Symbol.asyncIterator

View source


iterator

1
const iterator: typeof Symbol.iterator = SymbolAlias.iterator;

Alias for Symbol.iterator.

See

Symbol.iterator

View source

empty

Variables

EMPTY_ARRAY

1
const EMPTY_ARRAY: readonly [];

Empty read only array.

View source


EMPTY_OBJECT

1
const EMPTY_OBJECT: Readonly<object>;

Empty readonly object.

View source


EMPTY_STRING

1
const EMPTY_STRING: "" = "";

Empty string.

View source