Skip to content

Constants Reference

License NPM Version Open Issues Size

🔢 Shared constants.

Usage

📦 Node

Install @lou.codes/constants as a dependency:

Terminal window
pnpm add @lou.codes/constants
# or
npm install @lou.codes/constants
# or
yarn add @lou.codes/constants

Import it and use it:

import { EMPTY_OBJECT } from "@lou.codes/constants";
console.log(EMPTY_OBJECT); // {}

🦕 Deno

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

import { EMPTY_OBJECT } from "npm:@lou.codes/constants";
console.log(EMPTY_OBJECT); // {}

🌎 Browser

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

<script type="module">
import { EMPTY_OBJECT } from "https://esm.sh/@lou.codes/constants";
console.log(EMPTY_OBJECT); // {}
</script>

Variables

EMPTY_ARRAY

Const EMPTY_ARRAY: readonly []

Empty read only array.

View source


EMPTY_OBJECT

Const EMPTY_OBJECT: Readonly<{}>

Empty read only object.

View source


EMPTY_STRING

Const EMPTY_STRING: ""

Empty string.

View source

Functions

createObject

createObject<OutputType>(prototype?): OutputType

Alias for Object.create that takes undefined instead of null for the prototype.

Type parameters

NameType
OutputType{}

Parameters

NameType
prototype (optional)object

Returns

OutputType

Object with no prototype.

View source


freeze

freeze<T>(f): T

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

Type parameters

NameType
Textends Function

Parameters

NameTypeDescription
fTObject on which to lock the attributes.

Returns

T

View source

freeze<T, U>(o): Readonly<T>

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

Type parameters

NameType
Textends Object
Uextends string | number | bigint | boolean | symbol

Parameters

NameTypeDescription
oTObject on which to lock the attributes.

Returns

Readonly<T>

View source

freeze<T>(o): Readonly<T>

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

Type parameters

Name
T

Parameters

NameTypeDescription
oTObject on which to lock the attributes.

Returns

Readonly<T>

View source