@deboxsoft/module-core
Advanced tools
Comparing version 2.6.74 to 2.6.75
@@ -574,2 +574,52 @@ import * as _zod from 'zod'; | ||
/** | ||
* Creates a function that memoizes the result of `func`. If `resolver` is | ||
* provided, it determines the cache key for storing the result based on the | ||
* arguments provided to the memoized function. By default, the first argument | ||
* provided to the memoized function is used as the map cache key. The `func` | ||
* is invoked with the `this` binding of the memoized function. | ||
* | ||
* **Note:** The cache is exposed as the `cache` property on the memoized | ||
* function. Its creation may be customized by replacing the `memoize.Cache` | ||
* constructor with one whose instances implement the | ||
* [`Map`](http://ecma-international.org/ecma-262/7.0/#sec-properties-of-the-map-prototype-object) | ||
* method interface of `clear`, `delete`, `get`, `has`, and `set`. | ||
* | ||
* @since 0.1.0 | ||
* @category Function | ||
* @param {Function} func The function to have its output memoized. | ||
* @param {Function} [resolver] The function to resolve the cache key. | ||
* @returns {Function} Returns the new memoized function. | ||
* @example | ||
* | ||
* const object = { 'a': 1, 'b': 2 } | ||
* const other = { 'c': 3, 'd': 4 } | ||
* | ||
* const values = memoize(values) | ||
* values(object) | ||
* // => [1, 2] | ||
* | ||
* values(other) | ||
* // => [3, 4] | ||
* | ||
* object.a = 2 | ||
* values(object) | ||
* // => [1, 2] | ||
* | ||
* // Modify the result cache. | ||
* values.cache.set(object, ['a', 'b']) | ||
* values(object) | ||
* // => ['a', 'b'] | ||
* | ||
* // Replace `memoize.Cache`. | ||
* memoize.Cache = WeakMap | ||
*/ | ||
declare const memoize: { | ||
(func: any, resolver: any): { | ||
(...args: any[]): any; | ||
cache: Map<any, any>; | ||
}; | ||
Cache: MapConstructor; | ||
}; | ||
declare const zod: typeof _zod; | ||
@@ -685,2 +735,2 @@ | ||
export { Container, ContainerDIClass, DateSchema, DbxError, DbxErrorOptions, HttpErrorResponse, IdSchema, LOGGER_KEY, Logger, MakeSchemaResponse, ModuleConfig, NotificationType, PageCursorInfo, PageCursorParams, PageCursorParamsOutput, PageDefaultInfo, PageDefaultParams, PageDefaultParamsOutput, PageInfo, PageParams, Pagination, PaginationOptions, PaginationType, RangeDate, RangeDateSchema, TimeStampSchema, ZodOpenAPIInternalMetadata, ZodOpenAPIMetadata, ZodOpenApiFullMetadata, clamp, cloneDeep, compact, createLoggerConsole, dayTimeZone, debounce, enumInfo, extendZodWithOpenApi, getLogger, getRangeDate, isAnyZodType, isEmpty, isNil, isObject, isPlainObject, isString, isStringAndNotBlank, isStringBlank, isUndefined, isZodType, kindOf, makeSchemaResponse, mapValues, objectEquals, omit, omitBy, pickBy, pull, throttle, transformDefaultPageInfo, urlJoin, zod }; | ||
export { Container, ContainerDIClass, DateSchema, DbxError, DbxErrorOptions, HttpErrorResponse, IdSchema, LOGGER_KEY, Logger, MakeSchemaResponse, ModuleConfig, NotificationType, PageCursorInfo, PageCursorParams, PageCursorParamsOutput, PageDefaultInfo, PageDefaultParams, PageDefaultParamsOutput, PageInfo, PageParams, Pagination, PaginationOptions, PaginationType, RangeDate, RangeDateSchema, TimeStampSchema, ZodOpenAPIInternalMetadata, ZodOpenAPIMetadata, ZodOpenApiFullMetadata, clamp, cloneDeep, compact, createLoggerConsole, dayTimeZone, debounce, enumInfo, extendZodWithOpenApi, getLogger, getRangeDate, isAnyZodType, isEmpty, isNil, isObject, isPlainObject, isString, isStringAndNotBlank, isStringBlank, isUndefined, isZodType, kindOf, makeSchemaResponse, mapValues, memoize, objectEquals, omit, omitBy, pickBy, pull, throttle, transformDefaultPageInfo, urlJoin, zod }; |
@@ -79,2 +79,3 @@ import { __export, CONFIG_KEY, Container, ContainerDIClass, DbxError, getConfig, getConfigService, __reExport } from './chunk-3BIZMSTQ.js'; | ||
mapValues: () => mapValues, | ||
memoize: () => memoize, | ||
mustache: () => default3, | ||
@@ -673,2 +674,22 @@ noCase: () => noCase, | ||
// src/utils/memoize.ts | ||
var memoize = (func, resolver) => { | ||
if (typeof func !== "function" || resolver != null && typeof resolver !== "function") { | ||
throw new TypeError("Expected a function"); | ||
} | ||
const memoized = function(...args) { | ||
const key = resolver ? resolver.apply(this, args) : args[0]; | ||
const cache = memoized.cache; | ||
if (cache.has(key)) { | ||
return cache.get(key); | ||
} | ||
const result = func.apply(this, args); | ||
memoized.cache = cache.set(key, result) || cache; | ||
return result; | ||
}; | ||
memoized.cache = new (memoize.Cache || Map)(); | ||
return memoized; | ||
}; | ||
memoize.Cache = Map; | ||
// src/zod/index.ts | ||
@@ -829,2 +850,2 @@ var zod_exports = {}; | ||
export { DateSchema, IdSchema, LOGGER_KEY, Logger, PageCursorInfo, PageCursorParams, PageDefaultInfo, PageDefaultParams, PageInfo, PageParams, Pagination, PaginationOptions, PaginationType, RangeDateSchema, TimeStampSchema, clamp, cloneDeep, compact, createLoggerConsole, dayTimeZone, debounce, enumInfo, extendZodWithOpenApi, getLogger, getRangeDate, isAnyZodType, isEmpty, isNil, isObject, isPlainObject, isString, isStringAndNotBlank, isStringBlank, isUndefined, isZodType, kindOf, makeSchemaResponse, mapValues, objectEquals, omit, omitBy, pickBy, pull, throttle, transformDefaultPageInfo, urlJoin, zod }; | ||
export { DateSchema, IdSchema, LOGGER_KEY, Logger, PageCursorInfo, PageCursorParams, PageDefaultInfo, PageDefaultParams, PageInfo, PageParams, Pagination, PaginationOptions, PaginationType, RangeDateSchema, TimeStampSchema, clamp, cloneDeep, compact, createLoggerConsole, dayTimeZone, debounce, enumInfo, extendZodWithOpenApi, getLogger, getRangeDate, isAnyZodType, isEmpty, isNil, isObject, isPlainObject, isString, isStringAndNotBlank, isStringBlank, isUndefined, isZodType, kindOf, makeSchemaResponse, mapValues, memoize, objectEquals, omit, omitBy, pickBy, pull, throttle, transformDefaultPageInfo, urlJoin, zod }; |
{ | ||
"name": "@deboxsoft/module-core", | ||
"version": "2.6.74", | ||
"version": "2.6.75", | ||
"license": "SEE LICENSE IN LICENSE", | ||
@@ -5,0 +5,0 @@ "maintainers": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
150240
4506