Skip to content

Commit

Permalink
Change to the empty lazy to use the types
Browse files Browse the repository at this point in the history
  • Loading branch information
joooKiwi committed Apr 1, 2024
1 parent 896865e commit 20ab3fc
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions javascript/src/CommonLazy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
All the right is reserved to the author of this project.
******************************************************************************/

import type {EmptyArray, EmptyMap, EmptyObject, EmptySet, EmptyWeakMap, EmptyWeakSet} from "@joookiwi/type"

import {lazy} from "./method/lazy"
import {lazyOf} from "./method/lazyOf"

Expand Down Expand Up @@ -175,17 +177,17 @@ export namespace CommonLazy {
/** A {@link Lazy} for an empty {@link String} */
export const EMPTY_STRING = lazyOf('',)
/** A {@link Lazy} for an empty {@link Object} */
export const EMPTY_OBJECT = lazy(() => Object.freeze({},),)
export const EMPTY_OBJECT = lazy(() => Object.freeze({},) as EmptyObject,)
/** A {@link Lazy} for an empty {@link Array} */
export const EMPTY_ARRAY = lazy(() => Object.freeze([],) as readonly [],)
export const EMPTY_ARRAY = lazy(() => Object.freeze([],) as EmptyArray,)
/** A {@link Lazy} for an empty {@link Set} */
export const EMPTY_SET = lazy(() => Object.freeze(new Set<never>(),) as ReadonlySet<never>,)
export const EMPTY_SET = lazy(() => Object.freeze(new Set<never>(),) as EmptySet,)
/** A {@link Lazy} for an empty {@link WeakSet} */
export const EMPTY_WEAK_SET = lazy(() => Object.freeze(new WeakSet<never>(),),)
export const EMPTY_WEAK_SET = lazy(() => Object.freeze(new WeakSet(),) as EmptyWeakSet,)
/** A {@link Lazy} for an empty {@link Map} */
export const EMPTY_MAP = lazy(() => Object.freeze(new Map<unknown, never>(),) as ReadonlyMap<unknown, never>,)
export const EMPTY_MAP = lazy(() => Object.freeze(new Map<any, never>(),) as EmptyMap,)
/** A {@link Lazy} for an empty {@link WeakMap} */
export const EMPTY_WEAK_MAP = lazy(() => Object.freeze(new WeakMap<object, never>(),),)
export const EMPTY_WEAK_MAP = lazy(() => Object.freeze(new WeakMap(),) as EmptyWeakMap,)

//#endregion -------------------- Lazy empty objects --------------------

Expand Down

0 comments on commit 20ab3fc

Please sign in to comment.