@aurelia/kernel
Advanced tools
Comparing version
@@ -6,2 +6,22 @@ # Change Log | ||
<a name="2.0.0-beta.18"></a> | ||
# 2.0.0-beta.18 (2024-05-23) | ||
### Features: | ||
* **kernel:** add last resolver (#1976) ([c47817c](https://github.com/aurelia/aurelia/commit/c47817c)) | ||
### Bug Fixes: | ||
* **di:** use official metadata instead of weakmap (#1977) ([9aeeffa](https://github.com/aurelia/aurelia/commit/9aeeffa)) | ||
* **dev:** turbo package input + ts dev script ([253e92a](https://github.com/aurelia/aurelia/commit/253e92a)) | ||
### Refactorings: | ||
* **collection:** define map & set overrides on the instance instead of prototype (#1975) ([253e92a](https://github.com/aurelia/aurelia/commit/253e92a)) | ||
* **runtime:** reoganise utils import ([253e92a](https://github.com/aurelia/aurelia/commit/253e92a)) | ||
* ***:** extract error codes and cleanup (#1974) ([63ffdc9](https://github.com/aurelia/aurelia/commit/63ffdc9)) | ||
<a name="2.0.0-beta.17"></a> | ||
@@ -8,0 +28,0 @@ # 2.0.0-beta.17 (2024-05-11) |
import { IContainer, InterfaceSymbol, type IContainerConfiguration, type IResolver, type Key, type Resolved } from './di'; | ||
import type { IAllResolver, IFactoryResolver, ILazyResolver, INewInstanceResolver, IOptionalResolver, IResolvedFactory, IResolvedLazy } from './di.resolvers'; | ||
export declare const Registrable: Readonly<{ | ||
/** | ||
* Associate an object as a registrable, making the container recognize & use | ||
* the specific given register function during the registration | ||
*/ | ||
define: <T extends WeakKey>(object: T, register: (this: T, container: IContainer) => IContainer | void) => T; | ||
get: <T_1 extends WeakKey>(object: T_1) => ((container: IContainer) => IContainer | void) | undefined; | ||
has: <T_2 extends WeakKey>(object: T_2) => boolean; | ||
}>; | ||
export declare const registrableMetadataKey: unique symbol; | ||
export declare const DefaultResolver: { | ||
@@ -13,0 +5,0 @@ none(key: Key): IResolver; |
@@ -15,2 +15,8 @@ import { IContainer, IResolver, Key, Resolved } from './di'; | ||
/** | ||
* Create a resolver that will resolve the last instance of a key from the resolving container | ||
* | ||
* - @param key [[`Key`]] | ||
*/ | ||
export declare const last: <T extends Key>(key: T) => IResolver<T | undefined>; | ||
/** | ||
* Lazily inject a dependency depending on whether the [[`Key`]] is present at the time of function call. | ||
@@ -17,0 +23,0 @@ * |
@@ -50,3 +50,3 @@ import { Constructable, Overwrite } from './interfaces'; | ||
/** | ||
* Decorator. (lazily) bind the method to the class instance on first call. | ||
* Decorator. Bind the method to the class instance. | ||
*/ | ||
@@ -99,4 +99,4 @@ export declare const bound: <TThis extends object, TArgs extends unknown[], TReturn>(originalMethod: (this: TThis, ...args: TArgs) => TReturn, context: ClassMethodDecoratorContext<TThis, (this: TThis, ...args: TArgs) => TReturn>) => void; | ||
*/ | ||
export declare const onResolveAll: (...maybePromises: (void | Promise<void>)[]) => void | Promise<void>; | ||
export declare const onResolveAll: (...maybePromises: unknown[]) => void | Promise<void>; | ||
export {}; | ||
//# sourceMappingURL=functions.d.ts.map |
export { IPlatform, } from './platform'; | ||
export { DI, IContainer, type IFactory, inject, type IRegistration, type IRegistry, type IResolver, IServiceLocator, type Key, type RegisterSelf, type ResolveCallback, singleton, transient, type AbstractInjectable, type Injectable, type InterfaceSymbol, InstanceProvider, type Resolved, type Transformer, type IContainerConfiguration, } from './di'; | ||
export { resolve, type IResolvedInjection, Registrable, ContainerConfiguration, DefaultResolver, } from './di.container'; | ||
export { DI, IContainer, type IFactory, inject, type IRegistration, type IRegistry, type IResolver, type IDisposableResolver, IServiceLocator, type Key, type RegisterSelf, type ResolveCallback, singleton, transient, type AbstractInjectable, type Injectable, type InterfaceSymbol, InstanceProvider, type Resolved, type Transformer, type IContainerConfiguration, } from './di'; | ||
export { resolve, type IResolvedInjection, ContainerConfiguration, DefaultResolver, registrableMetadataKey, } from './di.container'; | ||
export { Registration, createImplementationRegister, } from './di.registration'; | ||
export { createResolver, all, factory, type IAllResolver, type IFactoryResolver, type IOptionalResolver, type IResolvedFactory, type INewInstanceResolver, lazy, type ILazyResolver, type IResolvedLazy, optional, ignore, newInstanceForScope, newInstanceOf, type ICallableResolver, allResources, optionalResource, own, resource, } from './di.resolvers'; | ||
export { createResolver, all, factory, type IAllResolver, type IFactoryResolver, type IOptionalResolver, type IResolvedFactory, type INewInstanceResolver, last, lazy, type ILazyResolver, type IResolvedLazy, optional, ignore, newInstanceForScope, newInstanceOf, type ICallableResolver, allResources, optionalResource, own, resource, } from './di.resolvers'; | ||
export { type Class, type Constructable, type ConstructableClass, type IDisposable, type IIndexable, type Overwrite, type Primitive, type Writable, } from './interfaces'; | ||
@@ -13,3 +13,3 @@ export { LogLevel, type IConsoleLike, type ColorOptions, ILogConfig, type ILogEvent, ILogEventFactory, ISink, ILogger, LogConfig, DefaultLogEvent, DefaultLogEventFactory, DefaultLogger, ConsoleSink, LoggerConfiguration, format, sink, } from './logger'; | ||
export { isArrayIndex, camelCase, kebabCase, pascalCase, toArray, bound, mergeArrays, firstDefined, getPrototypeChain, isNativeFunction, onResolve, onResolveAll, } from './functions'; | ||
export { type AnyFunction, type FunctionPropNames, type MaybePromise, } from './utilities'; | ||
export { isObject, isArray, isMap, isSet, isPromise, isFunction, isNumber, isString, isSymbol, areEqual, createLookup, type AnyFunction, type FunctionPropNames, type MaybePromise, } from './utilities'; | ||
//# sourceMappingURL=index.d.ts.map |
@@ -0,1 +1,61 @@ | ||
/** | ||
* Returns true if the value is a Promise via checking if it's an instance of Promise. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isPromise: <T>(v: unknown) => v is Promise<T>; | ||
/** | ||
* Returns true if the value is an Array via checking if it's an instance of Array. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isArray: <T>(v: unknown) => v is T[]; | ||
/** | ||
* Returns true if the value is a Set via checking if it's an instance of Set. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isSet: <T>(v: unknown) => v is Set<T>; | ||
/** | ||
* Returns true if the value is a Map via checking if it's an instance of Map. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isMap: <T, K>(v: unknown) => v is Map<T, K>; | ||
/** | ||
* Returns true if the value is an object via checking if it's an instance of Object. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isObject: (v: unknown) => v is object; | ||
/** | ||
* Returns true if the value is a function | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isFunction: <T extends Function>(v: unknown) => v is T; | ||
/** | ||
* Returns true if the value is a string | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isString: (v: unknown) => v is string; | ||
/** | ||
* Returns true if the value is a symbol | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isSymbol: (v: unknown) => v is string; | ||
/** | ||
* Returns true if the value is a number | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const isNumber: (v: unknown) => v is number; | ||
/** | ||
* Create an object with no prototype to be used as a record | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const createLookup: <T>() => Record<string, T>; | ||
/** | ||
* Compare the 2 values without pitfall of JS ===, including NaN and +0/-0 | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export declare const areEqual: (value1: any, value2: any) => boolean; | ||
export type AnyFunction = (...args: any) => any; | ||
@@ -2,0 +62,0 @@ export type FunctionPropNames<T> = { |
{ | ||
"name": "@aurelia/kernel", | ||
"version": "2.1.0-dev.202405130849", | ||
"version": "2.1.0-dev.202405280947", | ||
"main": "dist/cjs/index.cjs", | ||
@@ -57,4 +57,4 @@ "module": "dist/esm/index.mjs", | ||
"dependencies": { | ||
"@aurelia/metadata": "2.1.0-dev.202405130849", | ||
"@aurelia/platform": "2.1.0-dev.202405130849" | ||
"@aurelia/metadata": "2.1.0-dev.202405280947", | ||
"@aurelia/platform": "2.1.0-dev.202405280947" | ||
}, | ||
@@ -61,0 +61,0 @@ "devDependencies": { |
@@ -29,3 +29,3 @@ /* eslint-disable @typescript-eslint/no-this-alias */ | ||
} from './di.resolvers'; | ||
import { ErrorNames, createMappedError, logError, logWarn } from './errors'; | ||
import { ErrorNames, createMappedError, logError } from './errors'; | ||
import { isNativeFunction } from './functions'; | ||
@@ -35,25 +35,5 @@ import { type Class, type Constructable } from './interfaces'; | ||
import { ResourceDefinition, StaticResourceType, resourceBaseName, type ResourceType } from './resource'; | ||
import { getMetadata, isFunction, isString, objectFreeze } from './utilities'; | ||
import { getMetadata, isFunction, isString } from './utilities'; | ||
export const Registrable = /*@__PURE__*/(() => { | ||
const map = new WeakMap<WeakKey, (container: IContainer) => IContainer | void>(); | ||
return objectFreeze({ | ||
/** | ||
* Associate an object as a registrable, making the container recognize & use | ||
* the specific given register function during the registration | ||
*/ | ||
define: <T extends WeakKey>(object: T, register: (this: T, container: IContainer) => IContainer | void): T => { | ||
if (__DEV__) { | ||
if (map.has(object) && map.get(object) !== register) { | ||
logWarn(`Overriding registrable found for key:`, object); | ||
} | ||
} | ||
map.set(object, register); | ||
return object; | ||
}, | ||
get: <T extends WeakKey>(object: T) => map.get(object), | ||
has: <T extends WeakKey>(object: T) => map.has(object), | ||
}); | ||
})(); | ||
export const registrableMetadataKey = Symbol.for('au:registrable'); | ||
export const DefaultResolver = { | ||
@@ -193,8 +173,9 @@ none(key: Key): IResolver { | ||
current.register(this); | ||
} else if (Registrable.has(current)) { | ||
Registrable.get(current)!.call(current, this); | ||
} else if ((def = getMetadata(resourceBaseName, current)!) != null) { | ||
def.register(this); | ||
} else if (isClass<StaticResourceType>(current)) { | ||
if (isString((current).$au?.type)) { | ||
const registrable = current[Symbol.metadata]?.[registrableMetadataKey] as IRegistry; | ||
if (isRegistry(registrable)) { | ||
registrable.register(this); | ||
} else if (isString((current).$au?.type)) { | ||
const $au = current.$au; | ||
@@ -243,4 +224,2 @@ const aliases = (current.aliases ?? emptyArray).concat($au.aliases ?? emptyArray); | ||
value.register(this); | ||
} else if (Registrable.has(value)) { | ||
Registrable.get(value)!.call(value, this); | ||
} else { | ||
@@ -764,3 +743,3 @@ this.register(value); | ||
const isRegistry = (obj: IRegistry | Record<string, IRegistry>): obj is IRegistry => | ||
isFunction(obj.register); | ||
isFunction(obj?.register); | ||
@@ -767,0 +746,0 @@ const isSelfRegistry = <T extends Constructable>(obj: RegisterSelf<T>): obj is RegisterSelf<T> => |
@@ -48,2 +48,15 @@ /* eslint-disable @typescript-eslint/no-explicit-any */ | ||
/** | ||
* Create a resolver that will resolve the last instance of a key from the resolving container | ||
* | ||
* - @param key [[`Key`]] | ||
*/ | ||
export const last = <T extends Key>(key: T): IResolver<T | undefined> => ({ | ||
$isResolver: true, | ||
resolve: handler => { | ||
const allInstances = handler.getAll(key); | ||
return allInstances.length > 0 ? allInstances[allInstances.length - 1] : undefined; | ||
} | ||
}); | ||
/** | ||
* Lazily inject a dependency depending on whether the [[`Key`]] is present at the time of function call. | ||
@@ -50,0 +63,0 @@ * |
@@ -63,3 +63,2 @@ /* eslint-disable prefer-template */ | ||
[ErrorNames.invalid_module_transform_input]: `Invalid module transform input: {{0}}. Expected Promise or Object.`, | ||
// [ErrorNames.module_loader_received_null]: `Module loader received null/undefined input. Expected Object.`, | ||
[ErrorNames.invalid_inject_decorator_usage]: `The @inject decorator on the target ('{{0}}') type '{{1}}' is not supported.`, | ||
@@ -66,0 +65,0 @@ [ErrorNames.resource_key_already_registered]: `Resource key '{{0}}' has already been registered.`, |
import { ErrorNames, createMappedError } from './errors'; | ||
import { Constructable, Overwrite } from './interfaces'; | ||
import { createObject, objectAssign } from './utilities'; | ||
import { createLookup, isPromise, objectAssign } from './utilities'; | ||
@@ -37,3 +37,3 @@ /** | ||
for (; i < length; ++i) { | ||
ch = charCodeAt(value, i); | ||
ch = value.charCodeAt(i); | ||
if (i === 0 && ch === 0x30 && length > 1 /* must not start with 0 */ || ch < 0x30 /* 0 */ || ch > 0x39/* 9 */) { | ||
@@ -64,3 +64,3 @@ return isNumericLookup[value] = false; | ||
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions | ||
const isDigit = objectAssign(createObject(), { | ||
const isDigit = objectAssign(createLookup(), { | ||
'0': true, | ||
@@ -157,3 +157,3 @@ '1': true, | ||
export const camelCase = /*@__PURE__*/(function () { | ||
const cache: Record<string, string | undefined> = createObject(); | ||
const cache = createLookup<string | undefined>(); | ||
@@ -184,3 +184,3 @@ const callback = (char: string, sep: boolean): string => { | ||
export const pascalCase = /*@__PURE__*/(function () { | ||
const cache: Record<string, string | undefined> = createObject(); | ||
const cache = createLookup<string | undefined>(); | ||
@@ -211,3 +211,3 @@ return (input: string): string => { | ||
export const kebabCase = /*@__PURE__*/(function () { | ||
const cache: Record<string, string | undefined> = createObject(); | ||
const cache = createLookup<string | undefined>(); | ||
@@ -245,3 +245,3 @@ const callback = (char: string, sep: boolean): string => { | ||
/** | ||
* Decorator. (lazily) bind the method to the class instance on first call. | ||
* Decorator. Bind the method to the class instance. | ||
*/ | ||
@@ -381,3 +381,3 @@ export const bound = < | ||
export function toLookup(...objs: {}[]): Readonly<{}> { | ||
return objectAssign(createObject(), ...objs); | ||
return objectAssign(createLookup(), ...objs); | ||
} | ||
@@ -391,3 +391,3 @@ | ||
*/ | ||
export const isNativeFunction = /*@__PURE__*/(function () { | ||
export const isNativeFunction = /*@__PURE__*/(() => { | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
@@ -402,30 +402,5 @@ const lookup: WeakMap<Function, boolean> = new WeakMap(); | ||
isNative = lookup.get(fn); | ||
if (isNative === void 0) { | ||
sourceText = fn.toString(); | ||
i = sourceText.length; | ||
// http://www.ecma-international.org/ecma-262/#prod-NativeFunction | ||
isNative = ( | ||
// 29 is the length of 'function () { [native code] }' which is the smallest length of a native function string | ||
i >= 29 && | ||
// 100 seems to be a safe upper bound of the max length of a native function. In Chrome and FF it's 56, in Edge it's 61. | ||
i <= 100 && | ||
// This whole heuristic *could* be tricked by a comment. Do we need to care about that? | ||
charCodeAt(sourceText, i - 1) === 0x7D && // } | ||
// TODO: the spec is a little vague about the precise constraints, so we do need to test this across various browsers to make sure just one whitespace is a safe assumption. | ||
charCodeAt(sourceText, i - 2) <= 0x20 && // whitespace | ||
charCodeAt(sourceText, i - 3) === 0x5D && // ] | ||
charCodeAt(sourceText, i - 4) === 0x65 && // e | ||
charCodeAt(sourceText, i - 5) === 0x64 && // d | ||
charCodeAt(sourceText, i - 6) === 0x6F && // o | ||
charCodeAt(sourceText, i - 7) === 0x63 && // c | ||
charCodeAt(sourceText, i - 8) === 0x20 && // | ||
charCodeAt(sourceText, i - 9) === 0x65 && // e | ||
charCodeAt(sourceText, i - 10) === 0x76 && // v | ||
charCodeAt(sourceText, i - 11) === 0x69 && // i | ||
charCodeAt(sourceText, i - 12) === 0x74 && // t | ||
charCodeAt(sourceText, i - 13) === 0x61 && // a | ||
charCodeAt(sourceText, i - 14) === 0x6E && // n | ||
charCodeAt(sourceText, i - 15) === 0x5B // [ | ||
); | ||
if (isNative == null) { | ||
i = (sourceText = fn.toString()).length; | ||
isNative = i > 28 && sourceText.indexOf('[native code] }') === i - 15; | ||
lookup.set(fn, isNative); | ||
@@ -464,8 +439,6 @@ } | ||
*/ | ||
export const onResolveAll = ( | ||
...maybePromises: (void | Promise<void>)[] | ||
): void | Promise<void> => { | ||
let maybePromise: Promise<void> | void = void 0; | ||
let firstPromise: Promise<void> | void = void 0; | ||
let promises: Promise<void>[] | undefined = void 0; | ||
export const onResolveAll = (...maybePromises: unknown[]): void | Promise<void> => { | ||
let maybePromise: unknown = void 0; | ||
let firstPromise: unknown = void 0; | ||
let promises: unknown[] | undefined = void 0; | ||
let i = 0; | ||
@@ -476,3 +449,3 @@ // eslint-disable-next-line | ||
maybePromise = maybePromises[i]; | ||
if ((maybePromise = maybePromises[i]) instanceof Promise) { | ||
if (isPromise(maybePromise = maybePromises[i])) { | ||
if (firstPromise === void 0) { | ||
@@ -489,7 +462,5 @@ firstPromise = maybePromise; | ||
if (promises === void 0) { | ||
return firstPromise; | ||
return firstPromise as void | Promise<void>; | ||
} | ||
return Promise.all(promises) as unknown as Promise<void>; | ||
}; | ||
const charCodeAt = (str: string, index: number) => str.charCodeAt(index); |
@@ -13,2 +13,3 @@ export { | ||
type IResolver, | ||
type IDisposableResolver, | ||
IServiceLocator, | ||
@@ -32,5 +33,5 @@ type Key, | ||
type IResolvedInjection, | ||
Registrable, | ||
ContainerConfiguration, | ||
DefaultResolver, | ||
registrableMetadataKey, | ||
} from './di.container'; | ||
@@ -52,2 +53,3 @@ | ||
type INewInstanceResolver, | ||
last, | ||
lazy, | ||
@@ -146,2 +148,13 @@ type ILazyResolver, | ||
export { | ||
isObject, | ||
isArray, | ||
isMap, | ||
isSet, | ||
isPromise, | ||
isFunction, | ||
isNumber, | ||
isString, | ||
isSymbol, | ||
areEqual, | ||
createLookup, | ||
type AnyFunction, | ||
@@ -148,0 +161,0 @@ type FunctionPropNames, |
@@ -7,3 +7,3 @@ import { createInterface, IContainer, IRegistry } from './di'; | ||
import { getAnnotationKeyFor } from './resource'; | ||
import { createObject, defineMetadata, getMetadata, isFunction, objectFreeze } from './utilities'; | ||
import { createLookup, defineMetadata, getMetadata, isFunction, objectFreeze } from './utilities'; | ||
import { resolve } from './di.container'; | ||
@@ -422,3 +422,3 @@ import { all, optional } from './di.resolvers'; | ||
/** @internal */ | ||
private readonly _scopedLoggers: { [key: string]: ILogger | undefined } = createObject(); | ||
private readonly _scopedLoggers = createLookup<ILogger | undefined>(); | ||
@@ -425,0 +425,0 @@ /** @internal */ |
@@ -10,11 +10,74 @@ import { Metadata } from '@aurelia/metadata'; | ||
/** @internal */ export const isPromise = <T>(v: unknown): v is Promise<T> => v instanceof Promise; | ||
/** | ||
* Returns true if the value is a Promise via checking if it's an instance of Promise. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isPromise = <T>(v: unknown): v is Promise<T> => v instanceof Promise; | ||
/** | ||
* Returns true if the value is an Array via checking if it's an instance of Array. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isArray = <T>(v: unknown): v is T[] => v instanceof Array; | ||
/** | ||
* Returns true if the value is a Set via checking if it's an instance of Set. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isSet = <T>(v: unknown): v is Set<T> => v instanceof Set; | ||
/** | ||
* Returns true if the value is a Map via checking if it's an instance of Map. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isMap = <T, K>(v: unknown): v is Map<T, K> => v instanceof Map; | ||
/** | ||
* Returns true if the value is an object via checking if it's an instance of Object. | ||
* This does not work for objects across different realms (e.g., iframes). | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isObject = (v: unknown): v is object => v instanceof Object; | ||
/** | ||
* Returns true if the value is a function | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
// eslint-disable-next-line @typescript-eslint/ban-types | ||
/** @internal */ export const isFunction = <T extends Function>(v: unknown): v is T => typeof v === 'function'; | ||
export const isFunction = <T extends Function>(v: unknown): v is T => typeof v === 'function'; | ||
/** @internal */ export const isString = (v: unknown): v is string => typeof v === 'string'; | ||
/** @internal */ export const createObject = <T extends object>() => Object.create(null) as T; | ||
/** @internal */ export const createError = (message: string) => new Error(message); | ||
/** | ||
* Returns true if the value is a string | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isString = (v: unknown): v is string => typeof v === 'string'; | ||
/** | ||
* Returns true if the value is a symbol | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isSymbol = (v: unknown): v is string => typeof v === 'symbol'; | ||
/** | ||
* Returns true if the value is a number | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const isNumber = (v: unknown): v is number => typeof v === 'number'; | ||
/** | ||
* Create an object with no prototype to be used as a record | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const createLookup = <T>() => Object.create(null) as Record<string, T>; | ||
/** | ||
* Compare the 2 values without pitfall of JS ===, including NaN and +0/-0 | ||
* An utility to be shared among core packages for better size optimization | ||
*/ | ||
export const areEqual = Object.is; | ||
// eslint-disable-next-line @typescript-eslint/no-explicit-any | ||
@@ -21,0 +84,0 @@ export type AnyFunction = (...args: any) => any; |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1085598
0.26%18841
0.94%+ Added
+ Added
- Removed
- Removed