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>
  • ๐Ÿ“ Documentation: TypeDoc generated documentation.
  • โณ Changelog: List of changes between versions.

Array

Functions

from()

from(arrayLike)
1
function from<T>(arrayLike: ArrayLike<T>): T[];

Creates an array from an array-like object.

Type parameters
Type parameter
T
Parameters
ParameterTypeDescription
arrayLikeArrayLike<T>An array-like object to convert to an array.
Returns

T[]

View source

from(arrayLike, mapfn, thisArg)
1
function from<T, U>(
2
arrayLike: ArrayLike<T>,
3
mapfn: (v: T, k: number) => U,
4
thisArg?: any,
5
): U[];

Creates an array from an iterable object.

Type parameters
Type parameter
T
U
Parameters
ParameterTypeDescription
arrayLikeArrayLike<T>An array-like object to convert to an array.
mapfn(v: T, k: number) => UA mapping function to call on every element of the array.
thisArg?anyValue of โ€˜thisโ€™ used to invoke the mapfn.
Returns

U[]

View source

from(iterable)
1
function from<T>(iterable: Iterable<T> | ArrayLike<T>): T[];

Creates an array from an iterable object.

Type parameters
Type parameter
T
Parameters
ParameterTypeDescription
iterableIterable<T> | ArrayLike<T>An iterable object to convert to an array.
Returns

T[]

View source

from(iterable, mapfn, thisArg)
1
function from<T, U>(
2
iterable: Iterable<T> | ArrayLike<T>,
3
mapfn: (v: T, k: number) => U,
4
thisArg?: any,
5
): U[];

Creates an array from an iterable object.

Type parameters
Type parameter
T
U
Parameters
ParameterTypeDescription
iterableIterable<T> | ArrayLike<T>An iterable object to convert to an array.
mapfn(v: T, k: number) => UA mapping function to call on every element of the array.
thisArg?anyValue of โ€˜thisโ€™ used to invoke the mapfn.
Returns

U[]

View source


isArray()

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

arg is any[]

View source

Number

Functions

isFinite()

1
function isFinite(number: unknown): boolean;

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
ParameterTypeDescription
numberunknownA numeric value.
Returns

boolean

View source


isNaN()

1
function isNaN(number: unknown): boolean;

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
ParameterTypeDescription
numberunknownA numeric value.
Returns

boolean

View source


isSafeInteger()

1
function isSafeInteger(number: unknown): boolean;

Returns true if the value passed is a safe integer.

Parameters
ParameterTypeDescription
numberunknownA numeric value.
Returns

boolean

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?: OutputType): OutputType;

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

Type parameters
Type parameterValue
OutputTypeobject
Parameters
ParameterType
object?OutputType
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


keys()

keys(o)
1
function keys(o: object): string[];

Returns the names of the enumerable string properties and methods 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[]

View source

keys(o)
1
function keys(o: object): string[];

Returns the names of the enumerable string properties and methods 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[]

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

String

Functions

raw()

1
function raw(template: object, ...substitutions: any[]): string;

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
ParameterTypeDescription
templateobjectA well-formed template string call site representation.
template.rawreadonly string[] | ArrayLike<string>-
โ€ฆsubstitutionsany[]A set of substitution values.
Returns

string

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