@proc7ts/primitives
Advanced tools
@@ -5,2 +5,4 @@ /** | ||
| * Creates the promise only on demand. | ||
| * | ||
| * The methods of this object do not require `this` context and can be called as functions. | ||
| */ | ||
@@ -15,5 +17,5 @@ export interface PromiseResolver<T> { | ||
| * | ||
| * @param value Either a promise value, or a promise-like instance resolving to one. | ||
| * @param resolution Either a promise value, or a promise-like instance resolving to one. | ||
| */ | ||
| resolve(value: T | PromiseLike<T>): void; | ||
| resolve(this: void, ...resolution: undefined extends T ? [(T | PromiseLike<T>)?] : [T | PromiseLike<T>]): void; | ||
| /** | ||
@@ -28,3 +30,3 @@ * Rejects the promise. | ||
| */ | ||
| reject(reason?: any): void; | ||
| reject(this: void, reason?: any): void; | ||
| /** | ||
@@ -37,3 +39,3 @@ * Creates a promise resolved by {@link resolve}, or rejected by {@link reject}. | ||
| */ | ||
| promise(): Promise<T>; | ||
| promise(this: void): Promise<T>; | ||
| } | ||
@@ -40,0 +42,0 @@ /** |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"promise-resolver.d.ts","sourceRoot":"","sources":["../../src/promises/promise-resolver.ts"],"names":[],"mappings":"AAOA;;;;GAIG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAEhC;;;;;;;;OAQG;IACH,OAAO,CAAC,KAAK,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAEzC;;;;;;;;OAQG;IACH,MAAM,CAAC,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAE3B;;;;;;OAMG;IACH,OAAO,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC;CAEvB;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAC,CAgC1D"} | ||
| {"version":3,"file":"promise-resolver.d.ts","sourceRoot":"","sources":["../../src/promises/promise-resolver.ts"],"names":[],"mappings":"AAOA;;;;;;GAMG;AACH,MAAM,WAAW,eAAe,CAAC,CAAC;IAEhC;;;;;;;;OAQG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,EAAE,GAAG,UAAU,EAAE,SAAS,SAAS,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAE,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,GAAG,IAAI,CAAC;IAE9G;;;;;;;;OAQG;IACH,MAAM,CAAC,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,EAAE,GAAG,GAAG,IAAI,CAAC;IAEvC;;;;;;OAMG;IACH,OAAO,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;CAEjC;AAED;;;;GAIG;AACH,wBAAgB,kBAAkB,CAAC,CAAC,KAAK,eAAe,CAAC,CAAC,CAAC,CAgC1D"} |
| /** | ||
| * @packageDocumentation | ||
| * @module @proc7ts/primitives | ||
| */ | ||
| /** | ||
| * Checks if the given object is a promise-like instance. | ||
@@ -3,0 +7,0 @@ * |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"is-promise-like.d.ts","sourceRoot":"","sources":["../../src/type/is-promise-like.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAC3C,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,MAAM,GACvC,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,CAIjC"} | ||
| {"version":3,"file":"is-promise-like.d.ts","sourceRoot":"","sources":["../../src/type/is-promise-like.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE,MAAM,EAC3C,KAAK,EAAE,WAAW,CAAC,SAAS,CAAC,GAAG,MAAM,GACvC,KAAK,IAAI,WAAW,CAAC,SAAS,CAAC,CAIjC"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"primitives.js","sources":["../src/array/array-of-elements.ts","../src/array/element-or-array.ts","../src/array/set-of-elements.ts","../src/class/super-class-of.ts","../src/fn/asis.ts","../src/fn/merge-functions.ts","../src/fn/noop.ts","../src/value/async-value.ts","../src/value/async-recipe.ts","../src/value/value-providers.ts","../src/value/lazy-value.ts","../src/value/value-recipe.ts","../src/promises/promise-resolver.ts","../src/reflection/property-accessor.ts","../src/type/is-array-like.ts","../src/type/is-iterable.ts","../src/type/presence.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Checks whether the given value is an array.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | T[] | null | undefined): value is T[];\n\n/**\n * Checks whether the given value is a readonly array.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is readonly T[];\n\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Converts element or array of elements to array of elements.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[];\n\n/**\n * Converts element or readonly array of elements to readonly array of elements.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if the `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | readonly T[] | null | undefined): readonly T[];\n\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[] {\n return (/*#__INLINE__*/ isArrayOfElements(value)) ? value : value != null ? [value] : [];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Builds element or array of the given elements.\n *\n * @param source A source of elements as their iterable or array-like container.\n *\n * @returns The only element of the `source`, an array of all elements of non-empty source, or `undefined` if the\n * `source` is empty.\n */\nexport function elementOrArray<T>(source: Iterable<T> | ArrayLike<T>): T | T[] | undefined {\n\n const array = Array.from(source);\n const { length } = array;\n\n if (length) {\n return length === 1 ? array[0] : array;\n }\n\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { isArrayOfElements } from './array-of-elements';\n\n/**\n * Builds a set of the given element or array of elements.\n *\n * @param elements Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns A new set containing all of the given elements, or empty set if `elements` is `null` or `undefined`.\n */\nexport function setOfElements<T>(elements: T | readonly T[] | null | undefined): Set<T> {\n return (/*#__INLINE__*/ isArrayOfElements(elements))\n ? new Set(elements)\n : (elements != null ? new Set([elements]) : new Set());\n}\n\n/**\n * Adds element of array of elements to the given set.\n *\n * Adds to the set a single element, all `elements` of the given array, or nothing when `elements` is `null`\n * or `undefined`.\n *\n * @param set Target set to add elements to.\n * @param elements Element(s) to add to the `set`. Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The target `set`.\n */\nexport function extendSetOfElements<T>(set: Set<T>, elements: T | readonly T[] | null | undefined): Set<T> {\n if (/*#__INLINE__*/ isArrayOfElements(elements)) {\n elements.forEach(element => set.add(element));\n } else if (elements != null) {\n set.add(elements);\n }\n return set;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport type { Class } from './class';\n\n/**\n * Detects a super class of the given class optionally satisfying the given criteria.\n *\n * Traverses all class ancestors until reaches the one satisfying the given criteria, or stops when there is no more\n * ancestors.\n *\n * @param type The class constructor to find super class of.\n * @param satisfying The criteria of super class matching. It is a function accepting a super class constructor\n * as the only parameter and returning `true` if the given super class matches, or `false` otherwise. Always returns\n * `true` by default.\n *\n * @return A super class `satisfying` the given criteria, or `undefined` if there is no such super class, or there is no\n * super class at all (e.g. when `Object` is passed in).\n */\nexport function superClassOf(type: Class, satisfying: (type: Class) => boolean = () => true): Class | undefined {\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prototype: object = Object.getPrototypeOf(type.prototype);\n\n if (prototype == null) {\n return;\n }\n\n const superType = prototype.constructor as Class;\n\n if (satisfying(superType)) {\n return superType;\n }\n\n return superClassOf(superType, satisfying);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that returns its argument as is.\n *\n * @param value A value to return.\n *\n * @returns `value`.\n */\nexport function asis<T>(value: T): T {\n return value;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Merges two functions by calling one after another.\n *\n * Optionally merges function call results.\n *\n * @typeParam TArgs Function parameter types as tuple.\n * @typeParam TReturn A type of function result.\n * @typeParam TThis A type if `this` object expected by function.\n * @param first The first function to call.\n * @param second The second function to call.\n * @param merge Optional function call results merger. Accepts two function results as arguments and returns the final\n * result. When omitted the first function call result is ignored and the second function's call result is returned.\n *\n * @return A function that calls both of the given ones and merges their results. If one of the functions is absent,\n * then just returns another one. If both are absent, then returns `undefined`.\n */\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: (this: TThis, ...args: TArgs) => TReturn,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: (this: TThis, ...args: TArgs) => TReturn,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn = (_f, s) => s,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined {\n if (!first) {\n return second;\n }\n if (!second) {\n return first;\n }\n return function (this: TThis, ...args: TArgs): TReturn {\n return merge(\n first.apply(this, args),\n second.apply(this, args),\n );\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that does nothing.\n *\n * @returns `undefined`.\n */\nexport function noop(): undefined {\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Converts a value to its promise.\n *\n * @param value Either a value, or a promise-like instance resolving to it.\n *\n * @returns A promise resolving to the given value.\n */\nexport function asyncValue<T>(value: T | PromiseLike<T>): Promise<T> {\n return (async () => value)();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { asyncValue } from './async-value';\n\n/**\n * Asynchronous recipe of value evaluation.\n *\n * This is either a value as-is, a promise-like instance resolving to it, or its {@link AsyncRecipe.Evaluator evaluator}\n * function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type AsyncRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | PromiseLike<TValue>\n | AsyncRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace AsyncRecipe {\n\n /**\n * Asynchronous value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Either an valuated value, or a promise-like instance resolving to one.\n */\n (this: void, ...args: TArgs) => TValue | PromiseLike<TValue>;\n\n}\n\n/**\n * @internal\n */\nfunction isAsyncEvaluator<TValue, TArgs extends any[]>(\n value: AsyncRecipe<TValue, TArgs>,\n): value is AsyncRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Asynchronously evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns A promise resolved to the value.\n */\nexport async function asyncByRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n ...args: TArgs\n): Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts asynchronous value recipe to its {@link AsyncRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value recipe to convert.\n *\n * @returns A function asynchronously evaluating the value.\n */\nexport function asyncRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n): (this: void, ...args: TArgs) => Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe))\n ? (async (...args) => recipe(...args))\n : () => asyncValue(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Creates a provider of the only argument.\n *\n * @param value A value to return.\n *\n * @returns A function that returns `value`.\n */\nexport function valueProvider<T>(value: T): (this: void) => T {\n return (): T => value;\n}\n\n/**\n * Creates a provider of arguments tuple.\n *\n * The returned tuple should never be modified as it is not cloned.\n *\n * @param values Values to return.\n *\n * @returns A function that returns `values` tuple.\n */\nexport function valuesProvider<T extends readonly any[]>(...values: T): (this: void) => T {\n return (): T => values;\n}\n\n/**\n * Creates a provider of cloned arguments tuple.\n *\n * The returned tuple can be modified as it is cloned before the return.\n *\n * @param values Values to return.\n *\n * @returns A function that returns a clone of `values` tuple.\n */\nexport function valuesCloner<T extends any[]>(...values: T): (this: void) => T {\n return (): T => Array.from(values) as T;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * Creates a provider of lazily evaluated value.\n *\n * The returned function evaluates the value first time it is called. Then it just returns previously evaluated value.\n *\n * @param provider A no-arg function evaluating the value.\n *\n * @returns A function that returns the value evaluated by `provider`.\n */\nexport function lazyValue<T>(provider: (this: void) => T): (this: void) => T {\n\n let get = (): T => (get = valueProvider(provider()))();\n\n return (): T => get();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * A recipe of value evaluation.\n *\n * This is either a value as-is, or its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type ValueRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | ValueRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace ValueRecipe {\n\n /**\n * Value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Evaluated value.\n */\n (this: void, ...args: TArgs) => TValue;\n\n}\n\n/**\n * @internal\n */\nfunction isValueEvaluator<TValue, TArgs extends any[]>(\n value: ValueRecipe<TValue, TArgs>,\n): value is ValueRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns Either the value itself, or the one evaluated by the given evaluator recipe.\n */\nexport function valueByRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n ...args: TArgs\n): TValue {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts a value recipe to its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value recipe to convert.\n *\n * @returns Either evaluator itself, or the one evaluating to the given value.\n */\nexport function valueRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n): ValueRecipe.Evaluator<TValue, TArgs> {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe : valueProvider(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { noop } from '../fn';\nimport { lazyValue } from '../value';\n\n/**\n * A resolver of promise that can be created later or not created at all.\n *\n * Creates the promise only on demand.\n */\nexport interface PromiseResolver<T> {\n\n /**\n * Resolves the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param value Either a promise value, or a promise-like instance resolving to one.\n */\n resolve(value: T | PromiseLike<T>): void;\n\n /**\n * Rejects the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param reason Promise rejection reason.\n */\n reject(reason?: any): void;\n\n /**\n * Creates a promise resolved by {@link resolve}, or rejected by {@link reject}.\n *\n * The subsequent calls to this method return the same promise instance.\n *\n * @returns Created promise.\n */\n promise(): Promise<T>;\n\n}\n\n/**\n * Creates a promise resolver.\n *\n * @returns New promise resolver.\n */\nexport function newPromiseResolver<T>(): PromiseResolver<T> {\n\n let resolvePromise: (value: T | PromiseLike<T>) => void;\n let rejectPromise: (reason?: any) => void;\n let buildPromise = lazyValue(() => new Promise<T>((resolve, reject) => {\n resolvePromise = resolve;\n rejectPromise = reject;\n }));\n const settle = (resolution: () => Promise<T>): void => {\n buildPromise = lazyValue(resolution);\n resolvePromise = noop;\n rejectPromise = noop;\n };\n\n resolvePromise = value => {\n settle(() => Promise.resolve(value));\n };\n rejectPromise = error => {\n settle(() => Promise.reject(error));\n };\n\n return {\n resolve(value) {\n resolvePromise(value);\n },\n reject(reason) {\n rejectPromise(reason);\n },\n promise() {\n return buildPromise();\n },\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Property accessor descriptor. I.e. the one with `get` and `set` functions.\n *\n * @typeParam TValue Property value type.\n */\nexport interface PropertyAccessorDescriptor<TValue> extends TypedPropertyDescriptor<TValue> {\n enumerable?: boolean;\n configurable?: boolean;\n writable?: undefined;\n value?: undefined;\n get?: () => TValue;\n set?: (value: TValue) => void;\n}\n\n/**\n * Detects whether the given property descriptor is the one of property accessor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return `true` if the descriptor has no `value` or `writable` attributes set.\n */\nexport function isPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): desc is PropertyAccessorDescriptor<TValue> {\n return desc.value === undefined && desc.writable === undefined;\n}\n\n/**\n * Converts a property descriptor to property accessor descriptor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return Either an accessor descriptor constructed from data descriptor, or `desc` if it is an accessor descriptor\n * already.\n */\nexport function toPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): PropertyAccessorDescriptor<TValue> {\n if (isPropertyAccessorDescriptor(desc)) {\n return desc;\n }\n\n const value__symbol = Symbol('value');\n\n interface ValueHost {\n [value__symbol]: TValue;\n }\n\n const initial = desc.value as TValue;\n\n const accessorDesc: PropertyAccessorDescriptor<TValue> = {\n ...desc,\n writable: undefined,\n value: undefined,\n get(this: ValueHost) {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n };\n\n if (desc.writable) {\n accessorDesc.set = function (this: ValueHost, newValue: TValue) {\n this[value__symbol] = newValue;\n };\n }\n\n delete accessorDesc.writable;\n delete accessorDesc.value;\n\n return accessorDesc;\n}\n\n/**\n * Creates an property accessor descriptor for the given field.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n */\nexport function fieldAccessorDescriptor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const value__symbol = Symbol(`${String(fieldKey)}:value`);\n\n interface ValueHost {\n [value__symbol]: TObject[TKey];\n }\n\n const initial: TObject[TKey] = target[fieldKey];\n\n return {\n configurable: true,\n enumerable: true,\n get(this: ValueHost): TObject[TKey] {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n set(this: ValueHost, newValue) {\n this[value__symbol] = newValue;\n },\n };\n}\n\n/**\n * Converts an object field to property accessor.\n *\n * Defines a new property with the given name in the target object and returns its descriptor.\n *\n * The converted descriptor is always configurable, enumerable, and writable.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n *\n * @return New property accessor descriptor.\n */\nexport function field2accessor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const desc = fieldAccessorDescriptor(target, fieldKey);\n\n Object.defineProperty(target, fieldKey, desc);\n\n return desc;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given value is array-like.\n *\n * @typeParam TElement Array elements type.\n * @typeParam TOther Non-array value type.\n * @param value A value to check.\n *\n * @returns `true` if the `value` has a `length` property, or `false` otherwise.\n */\nexport function isArrayLike<TElement, TOther>(value: ArrayLike<TElement> | TOther): value is ArrayLike<TElement> {\n return !!value && typeof value === 'object' && typeof (value as Partial<ArrayLike<TElement>>).length === 'number';\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given object is iterable.\n *\n * @typeParam TElement Iterable elements type.\n * @typeParam TOther Non-iterable value type.\n * @param value An object value to check.\n *\n * @returns `true` if the `value` has a `[Symbol.iterator]` property set, or `false` otherwise.\n */\nexport function isIterable<TElement, TOther>(value: Iterable<TElement> | TOther): value is Iterable<TElement> {\n return !!(value as Iterable<TElement>)[Symbol.iterator];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that checks whether the given value is present.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `null` or `undefined`, or `false` otherwise.\n */\nexport function isPresent<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\n/**\n * A function that checks whether the given value is not present.\n *\n * This is a direct opposite to `isPresent()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `null` or `undefined`, or `false` otherwise.\n */\nexport function isNotPresent<T>(value: T | undefined | null): value is T {\n return value == null;\n}\n\n/**\n * A function that checks whether the given value is defined.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `undefined`, or `false` otherwise.\n */\nexport function isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\n/**\n * A function that checks whether the given value is undefined.\n *\n * This is a direct opposite to `isDefined()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `undefined`, or `false` otherwise.\n */\nexport function isUndefined<T>(value: T | undefined): value is T {\n return value === undefined;\n}\n"],"names":[],"mappings":";;;;AAAA;;;;SAuBgB,iBAAiB,CAAI,KAA0C;IAC7E,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;SAsBe,eAAe,CAAI,KAAiC;IAClE,OAAO,iBAAiB,iBAAiB,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC;AAC3F;;ACjDA;;;;AAKA;;;;;;;;SAQgB,cAAc,CAAI,MAAkC;IAElE,MAAM,KAAK,GAAG,KAAK,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IACjC,MAAM,EAAE,MAAM,EAAE,GAA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C7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} | ||
| {"version":3,"file":"primitives.js","sources":["../src/array/array-of-elements.ts","../src/array/element-or-array.ts","../src/array/set-of-elements.ts","../src/class/super-class-of.ts","../src/fn/asis.ts","../src/fn/merge-functions.ts","../src/fn/noop.ts","../src/value/async-value.ts","../src/value/async-recipe.ts","../src/value/value-providers.ts","../src/value/lazy-value.ts","../src/value/value-recipe.ts","../src/promises/promise-resolver.ts","../src/reflection/property-accessor.ts","../src/type/is-array-like.ts","../src/type/is-iterable.ts","../src/type/presence.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Checks whether the given value is an array.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | T[] | null | undefined): value is T[];\n\n/**\n * Checks whether the given value is a readonly array.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is readonly T[];\n\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Converts element or array of elements to array of elements.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[];\n\n/**\n * Converts element or readonly array of elements to readonly array of elements.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if the `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | readonly T[] | null | undefined): readonly T[];\n\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[] {\n return (/*#__INLINE__*/ isArrayOfElements(value)) ? value : value != null ? [value] : [];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Builds element or array of the given elements.\n *\n * @param source A source of elements as their iterable or array-like container.\n *\n * @returns The only element of the `source`, an array of all elements of non-empty source, or `undefined` if the\n * `source` is empty.\n */\nexport function elementOrArray<T>(source: Iterable<T> | ArrayLike<T>): T | T[] | undefined {\n\n const array = Array.from(source);\n const { length } = array;\n\n if (length) {\n return length === 1 ? array[0] : array;\n }\n\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { isArrayOfElements } from './array-of-elements';\n\n/**\n * Builds a set of the given element or array of elements.\n *\n * @param elements Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns A new set containing all of the given elements, or empty set if `elements` is `null` or `undefined`.\n */\nexport function setOfElements<T>(elements: T | readonly T[] | null | undefined): Set<T> {\n return (/*#__INLINE__*/ isArrayOfElements(elements))\n ? new Set(elements)\n : (elements != null ? new Set([elements]) : new Set());\n}\n\n/**\n * Adds element of array of elements to the given set.\n *\n * Adds to the set a single element, all `elements` of the given array, or nothing when `elements` is `null`\n * or `undefined`.\n *\n * @param set Target set to add elements to.\n * @param elements Element(s) to add to the `set`. Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The target `set`.\n */\nexport function extendSetOfElements<T>(set: Set<T>, elements: T | readonly T[] | null | undefined): Set<T> {\n if (/*#__INLINE__*/ isArrayOfElements(elements)) {\n elements.forEach(element => set.add(element));\n } else if (elements != null) {\n set.add(elements);\n }\n return set;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport type { Class } from './class';\n\n/**\n * Detects a super class of the given class optionally satisfying the given criteria.\n *\n * Traverses all class ancestors until reaches the one satisfying the given criteria, or stops when there is no more\n * ancestors.\n *\n * @param type The class constructor to find super class of.\n * @param satisfying The criteria of super class matching. It is a function accepting a super class constructor\n * as the only parameter and returning `true` if the given super class matches, or `false` otherwise. Always returns\n * `true` by default.\n *\n * @return A super class `satisfying` the given criteria, or `undefined` if there is no such super class, or there is no\n * super class at all (e.g. when `Object` is passed in).\n */\nexport function superClassOf(type: Class, satisfying: (type: Class) => boolean = () => true): Class | undefined {\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prototype: object = Object.getPrototypeOf(type.prototype);\n\n if (prototype == null) {\n return;\n }\n\n const superType = prototype.constructor as Class;\n\n if (satisfying(superType)) {\n return superType;\n }\n\n return superClassOf(superType, satisfying);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that returns its argument as is.\n *\n * @param value A value to return.\n *\n * @returns `value`.\n */\nexport function asis<T>(value: T): T {\n return value;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Merges two functions by calling one after another.\n *\n * Optionally merges function call results.\n *\n * @typeParam TArgs Function parameter types as tuple.\n * @typeParam TReturn A type of function result.\n * @typeParam TThis A type if `this` object expected by function.\n * @param first The first function to call.\n * @param second The second function to call.\n * @param merge Optional function call results merger. Accepts two function results as arguments and returns the final\n * result. When omitted the first function call result is ignored and the second function's call result is returned.\n *\n * @return A function that calls both of the given ones and merges their results. If one of the functions is absent,\n * then just returns another one. If both are absent, then returns `undefined`.\n */\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: (this: TThis, ...args: TArgs) => TReturn,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: (this: TThis, ...args: TArgs) => TReturn,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn = (_f, s) => s,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined {\n if (!first) {\n return second;\n }\n if (!second) {\n return first;\n }\n return function (this: TThis, ...args: TArgs): TReturn {\n return merge(\n first.apply(this, args),\n second.apply(this, args),\n );\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that does nothing.\n *\n * @returns `undefined`.\n */\nexport function noop(): undefined {\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Converts a value to its promise.\n *\n * @param value Either a value, or a promise-like instance resolving to it.\n *\n * @returns A promise resolving to the given value.\n */\nexport function asyncValue<T>(value: T | PromiseLike<T>): Promise<T> {\n return (async () => value)();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { asyncValue } from './async-value';\n\n/**\n * Asynchronous recipe of value evaluation.\n *\n * This is either a value as-is, a promise-like instance resolving to it, or its {@link AsyncRecipe.Evaluator evaluator}\n * function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type AsyncRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | PromiseLike<TValue>\n | AsyncRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace AsyncRecipe {\n\n /**\n * Asynchronous value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Either an valuated value, or a promise-like instance resolving to one.\n */\n (this: void, ...args: TArgs) => TValue | PromiseLike<TValue>;\n\n}\n\n/**\n * @internal\n */\nfunction isAsyncEvaluator<TValue, TArgs extends any[]>(\n value: AsyncRecipe<TValue, TArgs>,\n): value is AsyncRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Asynchronously evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns A promise resolved to the value.\n */\nexport async function asyncByRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n ...args: TArgs\n): Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts asynchronous value recipe to its {@link AsyncRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value recipe to convert.\n *\n * @returns A function asynchronously evaluating the value.\n */\nexport function asyncRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n): (this: void, ...args: TArgs) => Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe))\n ? (async (...args) => recipe(...args))\n : () => asyncValue(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Creates a provider of the only argument.\n *\n * @param value A value to return.\n *\n * @returns A function that returns `value`.\n */\nexport function valueProvider<T>(value: T): (this: void) => T {\n return (): T => value;\n}\n\n/**\n * Creates a provider of arguments tuple.\n *\n * The returned tuple should never be modified as it is not cloned.\n *\n * @param values Values to return.\n *\n * @returns A function that returns `values` tuple.\n */\nexport function valuesProvider<T extends readonly any[]>(...values: T): (this: void) => T {\n return (): T => values;\n}\n\n/**\n * Creates a provider of cloned arguments tuple.\n *\n * The returned tuple can be modified as it is cloned before the return.\n *\n * @param values Values to return.\n *\n * @returns A function that returns a clone of `values` tuple.\n */\nexport function valuesCloner<T extends any[]>(...values: T): (this: void) => T {\n return (): T => Array.from(values) as T;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * Creates a provider of lazily evaluated value.\n *\n * The returned function evaluates the value first time it is called. Then it just returns previously evaluated value.\n *\n * @param provider A no-arg function evaluating the value.\n *\n * @returns A function that returns the value evaluated by `provider`.\n */\nexport function lazyValue<T>(provider: (this: void) => T): (this: void) => T {\n\n let get = (): T => (get = valueProvider(provider()))();\n\n return (): T => get();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * A recipe of value evaluation.\n *\n * This is either a value as-is, or its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type ValueRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | ValueRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace ValueRecipe {\n\n /**\n * Value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Evaluated value.\n */\n (this: void, ...args: TArgs) => TValue;\n\n}\n\n/**\n * @internal\n */\nfunction isValueEvaluator<TValue, TArgs extends any[]>(\n value: ValueRecipe<TValue, TArgs>,\n): value is ValueRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns Either the value itself, or the one evaluated by the given evaluator recipe.\n */\nexport function valueByRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n ...args: TArgs\n): TValue {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts a value recipe to its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value recipe to convert.\n *\n * @returns Either evaluator itself, or the one evaluating to the given value.\n */\nexport function valueRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n): ValueRecipe.Evaluator<TValue, TArgs> {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe : valueProvider(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { noop } from '../fn';\nimport { lazyValue } from '../value';\n\n/**\n * A resolver of promise that can be created later or not created at all.\n *\n * Creates the promise only on demand.\n *\n * The methods of this object do not require `this` context and can be called as functions.\n */\nexport interface PromiseResolver<T> {\n\n /**\n * Resolves the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param resolution Either a promise value, or a promise-like instance resolving to one.\n */\n resolve(this: void, ...resolution: undefined extends T ? [(T | PromiseLike<T>)?]: [T | PromiseLike<T>]): void;\n\n /**\n * Rejects the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param reason Promise rejection reason.\n */\n reject(this: void, reason?: any): void;\n\n /**\n * Creates a promise resolved by {@link resolve}, or rejected by {@link reject}.\n *\n * The subsequent calls to this method return the same promise instance.\n *\n * @returns Created promise.\n */\n promise(this: void): Promise<T>;\n\n}\n\n/**\n * Creates a promise resolver.\n *\n * @returns New promise resolver.\n */\nexport function newPromiseResolver<T>(): PromiseResolver<T> {\n\n let resolvePromise: (value?: T | PromiseLike<T>) => void;\n let rejectPromise: (reason?: any) => void;\n let buildPromise = lazyValue(() => new Promise<T>((resolve, reject) => {\n resolvePromise = resolve;\n rejectPromise = reject;\n }));\n const settle = (resolution: () => Promise<T>): void => {\n buildPromise = lazyValue(resolution);\n resolvePromise = noop;\n rejectPromise = noop;\n };\n\n resolvePromise = value => {\n settle(() => Promise.resolve(value as T));\n };\n rejectPromise = error => {\n settle(() => Promise.reject(error));\n };\n\n return {\n resolve(value?) {\n resolvePromise(value);\n },\n reject(reason) {\n rejectPromise(reason);\n },\n promise() {\n return buildPromise();\n },\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Property accessor descriptor. I.e. the one with `get` and `set` functions.\n *\n * @typeParam TValue Property value type.\n */\nexport interface PropertyAccessorDescriptor<TValue> extends TypedPropertyDescriptor<TValue> {\n enumerable?: boolean;\n configurable?: boolean;\n writable?: undefined;\n value?: undefined;\n get?: () => TValue;\n set?: (value: TValue) => void;\n}\n\n/**\n * Detects whether the given property descriptor is the one of property accessor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return `true` if the descriptor has no `value` or `writable` attributes set.\n */\nexport function isPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): desc is PropertyAccessorDescriptor<TValue> {\n return desc.value === undefined && desc.writable === undefined;\n}\n\n/**\n * Converts a property descriptor to property accessor descriptor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return Either an accessor descriptor constructed from data descriptor, or `desc` if it is an accessor descriptor\n * already.\n */\nexport function toPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): PropertyAccessorDescriptor<TValue> {\n if (isPropertyAccessorDescriptor(desc)) {\n return desc;\n }\n\n const value__symbol = Symbol('value');\n\n interface ValueHost {\n [value__symbol]: TValue;\n }\n\n const initial = desc.value as TValue;\n\n const accessorDesc: PropertyAccessorDescriptor<TValue> = {\n ...desc,\n writable: undefined,\n value: undefined,\n get(this: ValueHost) {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n };\n\n if (desc.writable) {\n accessorDesc.set = function (this: ValueHost, newValue: TValue) {\n this[value__symbol] = newValue;\n };\n }\n\n delete accessorDesc.writable;\n delete accessorDesc.value;\n\n return accessorDesc;\n}\n\n/**\n * Creates an property accessor descriptor for the given field.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n */\nexport function fieldAccessorDescriptor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const value__symbol = Symbol(`${String(fieldKey)}:value`);\n\n interface ValueHost {\n [value__symbol]: TObject[TKey];\n }\n\n const initial: TObject[TKey] = target[fieldKey];\n\n return {\n configurable: true,\n enumerable: true,\n get(this: ValueHost): TObject[TKey] {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n set(this: ValueHost, newValue) {\n this[value__symbol] = newValue;\n },\n };\n}\n\n/**\n * Converts an object field to property accessor.\n *\n * Defines a new property with the given name in the target object and returns its descriptor.\n *\n * The converted descriptor is always configurable, enumerable, and writable.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n *\n * @return New property accessor descriptor.\n */\nexport function field2accessor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const desc = fieldAccessorDescriptor(target, fieldKey);\n\n Object.defineProperty(target, fieldKey, desc);\n\n return desc;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given value is array-like.\n *\n * @typeParam TElement Array elements type.\n * @typeParam TOther Non-array value type.\n * @param value A value to check.\n *\n * @returns `true` if the `value` has a `length` property, or `false` otherwise.\n */\nexport function isArrayLike<TElement, TOther>(value: ArrayLike<TElement> | TOther): value is ArrayLike<TElement> {\n return !!value && typeof value === 'object' && typeof (value as Partial<ArrayLike<TElement>>).length === 'number';\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given object is iterable.\n *\n * @typeParam TElement Iterable elements type.\n * @typeParam TOther Non-iterable value type.\n * @param value An object value to check.\n *\n * @returns `true` if the `value` has a `[Symbol.iterator]` property set, or `false` otherwise.\n */\nexport function isIterable<TElement, TOther>(value: Iterable<TElement> | TOther): value is Iterable<TElement> {\n return !!(value as Iterable<TElement>)[Symbol.iterator];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that checks whether the given value is present.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `null` or `undefined`, or `false` otherwise.\n */\nexport function isPresent<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\n/**\n * A function that checks whether the given value is not present.\n *\n * This is a direct opposite to `isPresent()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `null` or `undefined`, or `false` otherwise.\n */\nexport function isNotPresent<T>(value: T | undefined | null): value is T {\n return value == null;\n}\n\n/**\n * A function that checks whether the given value is defined.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `undefined`, or `false` otherwise.\n */\nexport function isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\n/**\n * A function that checks whether the given value is undefined.\n *\n * This is a direct opposite to `isDefined()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `undefined`, or `false` otherwise.\n */\nexport function isUndefined<T>(value: T | undefined): value is T {\n return value === undefined;\n}\n"],"names":[],"mappings":";;;;AAAA;;;;SAuBgB,iBAAiB,CAAI,KAA0C;IAC7E,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;SAsBe,eAAe,CAAI,KAAiC;IAClE,OAAO,iBAAiB,iBAAiB,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,KAAK,IAAI,IAAI,GAAG,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC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ED;;;;;;;SAOgB,SAAS,CAAI,KAAoB;IAC/C,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC;AAED;;;;;;;;;SASgB,WAAW,CAAI,KAAoB;IACjD,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"} |
@@ -1,1 +0,1 @@ | ||
| {"version":3,"file":"primitives.mjs","sources":["../src/array/array-of-elements.ts","../src/array/element-or-array.ts","../src/array/set-of-elements.ts","../src/class/super-class-of.ts","../src/fn/asis.ts","../src/fn/merge-functions.ts","../src/fn/noop.ts","../src/value/async-value.ts","../src/value/async-recipe.ts","../src/value/value-providers.ts","../src/value/lazy-value.ts","../src/value/value-recipe.ts","../src/promises/promise-resolver.ts","../src/reflection/property-accessor.ts","../src/type/is-array-like.ts","../src/type/is-iterable.ts","../src/type/presence.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Checks whether the given value is an array.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | T[] | null | undefined): value is T[];\n\n/**\n * Checks whether the given value is a readonly array.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is readonly T[];\n\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Converts element or array of elements to array of elements.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[];\n\n/**\n * Converts element or readonly array of elements to readonly array of elements.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if the `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | readonly T[] | null | undefined): readonly T[];\n\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[] {\n return (/*#__INLINE__*/ isArrayOfElements(value)) ? value : value != null ? [value] : [];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Builds element or array of the given elements.\n *\n * @param source A source of elements as their iterable or array-like container.\n *\n * @returns The only element of the `source`, an array of all elements of non-empty source, or `undefined` if the\n * `source` is empty.\n */\nexport function elementOrArray<T>(source: Iterable<T> | ArrayLike<T>): T | T[] | undefined {\n\n const array = Array.from(source);\n const { length } = array;\n\n if (length) {\n return length === 1 ? array[0] : array;\n }\n\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { isArrayOfElements } from './array-of-elements';\n\n/**\n * Builds a set of the given element or array of elements.\n *\n * @param elements Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns A new set containing all of the given elements, or empty set if `elements` is `null` or `undefined`.\n */\nexport function setOfElements<T>(elements: T | readonly T[] | null | undefined): Set<T> {\n return (/*#__INLINE__*/ isArrayOfElements(elements))\n ? new Set(elements)\n : (elements != null ? new Set([elements]) : new Set());\n}\n\n/**\n * Adds element of array of elements to the given set.\n *\n * Adds to the set a single element, all `elements` of the given array, or nothing when `elements` is `null`\n * or `undefined`.\n *\n * @param set Target set to add elements to.\n * @param elements Element(s) to add to the `set`. Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The target `set`.\n */\nexport function extendSetOfElements<T>(set: Set<T>, elements: T | readonly T[] | null | undefined): Set<T> {\n if (/*#__INLINE__*/ isArrayOfElements(elements)) {\n elements.forEach(element => set.add(element));\n } else if (elements != null) {\n set.add(elements);\n }\n return set;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport type { Class } from './class';\n\n/**\n * Detects a super class of the given class optionally satisfying the given criteria.\n *\n * Traverses all class ancestors until reaches the one satisfying the given criteria, or stops when there is no more\n * ancestors.\n *\n * @param type The class constructor to find super class of.\n * @param satisfying The criteria of super class matching. It is a function accepting a super class constructor\n * as the only parameter and returning `true` if the given super class matches, or `false` otherwise. Always returns\n * `true` by default.\n *\n * @return A super class `satisfying` the given criteria, or `undefined` if there is no such super class, or there is no\n * super class at all (e.g. when `Object` is passed in).\n */\nexport function superClassOf(type: Class, satisfying: (type: Class) => boolean = () => true): Class | undefined {\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prototype: object = Object.getPrototypeOf(type.prototype);\n\n if (prototype == null) {\n return;\n }\n\n const superType = prototype.constructor as Class;\n\n if (satisfying(superType)) {\n return superType;\n }\n\n return superClassOf(superType, satisfying);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that returns its argument as is.\n *\n * @param value A value to return.\n *\n * @returns `value`.\n */\nexport function asis<T>(value: T): T {\n return value;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Merges two functions by calling one after another.\n *\n * Optionally merges function call results.\n *\n * @typeParam TArgs Function parameter types as tuple.\n * @typeParam TReturn A type of function result.\n * @typeParam TThis A type if `this` object expected by function.\n * @param first The first function to call.\n * @param second The second function to call.\n * @param merge Optional function call results merger. Accepts two function results as arguments and returns the final\n * result. When omitted the first function call result is ignored and the second function's call result is returned.\n *\n * @return A function that calls both of the given ones and merges their results. If one of the functions is absent,\n * then just returns another one. If both are absent, then returns `undefined`.\n */\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: (this: TThis, ...args: TArgs) => TReturn,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: (this: TThis, ...args: TArgs) => TReturn,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn = (_f, s) => s,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined {\n if (!first) {\n return second;\n }\n if (!second) {\n return first;\n }\n return function (this: TThis, ...args: TArgs): TReturn {\n return merge(\n first.apply(this, args),\n second.apply(this, args),\n );\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that does nothing.\n *\n * @returns `undefined`.\n */\nexport function noop(): undefined {\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Converts a value to its promise.\n *\n * @param value Either a value, or a promise-like instance resolving to it.\n *\n * @returns A promise resolving to the given value.\n */\nexport function asyncValue<T>(value: T | PromiseLike<T>): Promise<T> {\n return (async () => value)();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { asyncValue } from './async-value';\n\n/**\n * Asynchronous recipe of value evaluation.\n *\n * This is either a value as-is, a promise-like instance resolving to it, or its {@link AsyncRecipe.Evaluator evaluator}\n * function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type AsyncRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | PromiseLike<TValue>\n | AsyncRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace AsyncRecipe {\n\n /**\n * Asynchronous value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Either an valuated value, or a promise-like instance resolving to one.\n */\n (this: void, ...args: TArgs) => TValue | PromiseLike<TValue>;\n\n}\n\n/**\n * @internal\n */\nfunction isAsyncEvaluator<TValue, TArgs extends any[]>(\n value: AsyncRecipe<TValue, TArgs>,\n): value is AsyncRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Asynchronously evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns A promise resolved to the value.\n */\nexport async function asyncByRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n ...args: TArgs\n): Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts asynchronous value recipe to its {@link AsyncRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value recipe to convert.\n *\n * @returns A function asynchronously evaluating the value.\n */\nexport function asyncRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n): (this: void, ...args: TArgs) => Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe))\n ? (async (...args) => recipe(...args))\n : () => asyncValue(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Creates a provider of the only argument.\n *\n * @param value A value to return.\n *\n * @returns A function that returns `value`.\n */\nexport function valueProvider<T>(value: T): (this: void) => T {\n return (): T => value;\n}\n\n/**\n * Creates a provider of arguments tuple.\n *\n * The returned tuple should never be modified as it is not cloned.\n *\n * @param values Values to return.\n *\n * @returns A function that returns `values` tuple.\n */\nexport function valuesProvider<T extends readonly any[]>(...values: T): (this: void) => T {\n return (): T => values;\n}\n\n/**\n * Creates a provider of cloned arguments tuple.\n *\n * The returned tuple can be modified as it is cloned before the return.\n *\n * @param values Values to return.\n *\n * @returns A function that returns a clone of `values` tuple.\n */\nexport function valuesCloner<T extends any[]>(...values: T): (this: void) => T {\n return (): T => Array.from(values) as T;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * Creates a provider of lazily evaluated value.\n *\n * The returned function evaluates the value first time it is called. Then it just returns previously evaluated value.\n *\n * @param provider A no-arg function evaluating the value.\n *\n * @returns A function that returns the value evaluated by `provider`.\n */\nexport function lazyValue<T>(provider: (this: void) => T): (this: void) => T {\n\n let get = (): T => (get = valueProvider(provider()))();\n\n return (): T => get();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * A recipe of value evaluation.\n *\n * This is either a value as-is, or its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type ValueRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | ValueRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace ValueRecipe {\n\n /**\n * Value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Evaluated value.\n */\n (this: void, ...args: TArgs) => TValue;\n\n}\n\n/**\n * @internal\n */\nfunction isValueEvaluator<TValue, TArgs extends any[]>(\n value: ValueRecipe<TValue, TArgs>,\n): value is ValueRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns Either the value itself, or the one evaluated by the given evaluator recipe.\n */\nexport function valueByRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n ...args: TArgs\n): TValue {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts a value recipe to its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value recipe to convert.\n *\n * @returns Either evaluator itself, or the one evaluating to the given value.\n */\nexport function valueRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n): ValueRecipe.Evaluator<TValue, TArgs> {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe : valueProvider(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { noop } from '../fn';\nimport { lazyValue } from '../value';\n\n/**\n * A resolver of promise that can be created later or not created at all.\n *\n * Creates the promise only on demand.\n */\nexport interface PromiseResolver<T> {\n\n /**\n * Resolves the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param value Either a promise value, or a promise-like instance resolving to one.\n */\n resolve(value: T | PromiseLike<T>): void;\n\n /**\n * Rejects the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param reason Promise rejection reason.\n */\n reject(reason?: any): void;\n\n /**\n * Creates a promise resolved by {@link resolve}, or rejected by {@link reject}.\n *\n * The subsequent calls to this method return the same promise instance.\n *\n * @returns Created promise.\n */\n promise(): Promise<T>;\n\n}\n\n/**\n * Creates a promise resolver.\n *\n * @returns New promise resolver.\n */\nexport function newPromiseResolver<T>(): PromiseResolver<T> {\n\n let resolvePromise: (value: T | PromiseLike<T>) => void;\n let rejectPromise: (reason?: any) => void;\n let buildPromise = lazyValue(() => new Promise<T>((resolve, reject) => {\n resolvePromise = resolve;\n rejectPromise = reject;\n }));\n const settle = (resolution: () => Promise<T>): void => {\n buildPromise = lazyValue(resolution);\n resolvePromise = noop;\n rejectPromise = noop;\n };\n\n resolvePromise = value => {\n settle(() => Promise.resolve(value));\n };\n rejectPromise = error => {\n settle(() => Promise.reject(error));\n };\n\n return {\n resolve(value) {\n resolvePromise(value);\n },\n reject(reason) {\n rejectPromise(reason);\n },\n promise() {\n return buildPromise();\n },\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Property accessor descriptor. I.e. the one with `get` and `set` functions.\n *\n * @typeParam TValue Property value type.\n */\nexport interface PropertyAccessorDescriptor<TValue> extends TypedPropertyDescriptor<TValue> {\n enumerable?: boolean;\n configurable?: boolean;\n writable?: undefined;\n value?: undefined;\n get?: () => TValue;\n set?: (value: TValue) => void;\n}\n\n/**\n * Detects whether the given property descriptor is the one of property accessor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return `true` if the descriptor has no `value` or `writable` attributes set.\n */\nexport function isPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): desc is PropertyAccessorDescriptor<TValue> {\n return desc.value === undefined && desc.writable === undefined;\n}\n\n/**\n * Converts a property descriptor to property accessor descriptor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return Either an accessor descriptor constructed from data descriptor, or `desc` if it is an accessor descriptor\n * already.\n */\nexport function toPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): PropertyAccessorDescriptor<TValue> {\n if (isPropertyAccessorDescriptor(desc)) {\n return desc;\n }\n\n const value__symbol = Symbol('value');\n\n interface ValueHost {\n [value__symbol]: TValue;\n }\n\n const initial = desc.value as TValue;\n\n const accessorDesc: PropertyAccessorDescriptor<TValue> = {\n ...desc,\n writable: undefined,\n value: undefined,\n get(this: ValueHost) {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n };\n\n if (desc.writable) {\n accessorDesc.set = function (this: ValueHost, newValue: TValue) {\n this[value__symbol] = newValue;\n };\n }\n\n delete accessorDesc.writable;\n delete accessorDesc.value;\n\n return accessorDesc;\n}\n\n/**\n * Creates an property accessor descriptor for the given field.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n */\nexport function fieldAccessorDescriptor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const value__symbol = Symbol(`${String(fieldKey)}:value`);\n\n interface ValueHost {\n [value__symbol]: TObject[TKey];\n }\n\n const initial: TObject[TKey] = target[fieldKey];\n\n return {\n configurable: true,\n enumerable: true,\n get(this: ValueHost): TObject[TKey] {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n set(this: ValueHost, newValue) {\n this[value__symbol] = newValue;\n },\n };\n}\n\n/**\n * Converts an object field to property accessor.\n *\n * Defines a new property with the given name in the target object and returns its descriptor.\n *\n * The converted descriptor is always configurable, enumerable, and writable.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n *\n * @return New property accessor descriptor.\n */\nexport function field2accessor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const desc = fieldAccessorDescriptor(target, fieldKey);\n\n Object.defineProperty(target, fieldKey, desc);\n\n return desc;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given value is array-like.\n *\n * @typeParam TElement Array elements type.\n * @typeParam TOther Non-array value type.\n * @param value A value to check.\n *\n * @returns `true` if the `value` has a `length` property, or `false` otherwise.\n */\nexport function isArrayLike<TElement, TOther>(value: ArrayLike<TElement> | TOther): value is ArrayLike<TElement> {\n return !!value && typeof value === 'object' && typeof (value as Partial<ArrayLike<TElement>>).length === 'number';\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given object is iterable.\n *\n * @typeParam TElement Iterable elements type.\n * @typeParam TOther Non-iterable value type.\n * @param value An object value to check.\n *\n * @returns `true` if the `value` has a `[Symbol.iterator]` property set, or `false` otherwise.\n */\nexport function isIterable<TElement, TOther>(value: Iterable<TElement> | TOther): value is Iterable<TElement> {\n return !!(value as Iterable<TElement>)[Symbol.iterator];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that checks whether the given value is present.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `null` or `undefined`, or `false` otherwise.\n */\nexport function isPresent<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\n/**\n * A function that checks whether the given value is not present.\n *\n * This is a direct opposite to `isPresent()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `null` or `undefined`, or `false` otherwise.\n */\nexport function isNotPresent<T>(value: T | undefined | null): value is T {\n return value == null;\n}\n\n/**\n * A function that checks whether the given value is defined.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `undefined`, or `false` otherwise.\n */\nexport function isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\n/**\n * A function that checks whether the given value is undefined.\n *\n * This is a direct opposite to `isDefined()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `undefined`, or `false` otherwise.\n */\nexport function isUndefined<T>(value: T | undefined): value is T {\n return value === undefined;\n}\n"],"names":[],"mappings":"AAAA;;;;SAuBgB,iBAAiB,CAAI,KAA0C;IAC7E,OAAO,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;AAC9B,CAAC;SAsBe,eAAe,CAAI,KAAiC;IAClE,OAAO,iBAAiB,iBAAiB,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;AAED;;;;;;;;;SASgB,YAAY,CAAI,KAA2B;IACzD,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;SAOgB,SAAS,CAAI,KAAoB;IAC/C,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC;AAED;;;;;;;;;SASgB,WAAW,CAAI,KAAoB;IACjD,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B;;;;"} | ||
| {"version":3,"file":"primitives.mjs","sources":["../src/array/array-of-elements.ts","../src/array/element-or-array.ts","../src/array/set-of-elements.ts","../src/class/super-class-of.ts","../src/fn/asis.ts","../src/fn/merge-functions.ts","../src/fn/noop.ts","../src/value/async-value.ts","../src/value/async-recipe.ts","../src/value/value-providers.ts","../src/value/lazy-value.ts","../src/value/value-recipe.ts","../src/promises/promise-resolver.ts","../src/reflection/property-accessor.ts","../src/type/is-array-like.ts","../src/type/is-iterable.ts","../src/type/presence.ts"],"sourcesContent":["/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Checks whether the given value is an array.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | T[] | null | undefined): value is T[];\n\n/**\n * Checks whether the given value is a readonly array.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns `true` if the given `value` is an array, or `false` otherwise.\n */\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is readonly T[];\n\nexport function isArrayOfElements<T>(value: T | readonly T[] | null | undefined): value is T[] {\n return Array.isArray(value);\n}\n\n/**\n * Converts element or array of elements to array of elements.\n *\n * @param value Either element, array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[];\n\n/**\n * Converts element or readonly array of elements to readonly array of elements.\n *\n * @param value Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The `value` itself if it is an array, empty array if the `value` is `null` or `undefined`, or an array\n * containing only `value` otherwise.\n */\nexport function arrayOfElements<T>(value: T | readonly T[] | null | undefined): readonly T[];\n\nexport function arrayOfElements<T>(value: T | T[] | null | undefined): T[] {\n return (/*#__INLINE__*/ isArrayOfElements(value)) ? value : value != null ? [value] : [];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Builds element or array of the given elements.\n *\n * @param source A source of elements as their iterable or array-like container.\n *\n * @returns The only element of the `source`, an array of all elements of non-empty source, or `undefined` if the\n * `source` is empty.\n */\nexport function elementOrArray<T>(source: Iterable<T> | ArrayLike<T>): T | T[] | undefined {\n\n const array = Array.from(source);\n const { length } = array;\n\n if (length) {\n return length === 1 ? array[0] : array;\n }\n\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { isArrayOfElements } from './array-of-elements';\n\n/**\n * Builds a set of the given element or array of elements.\n *\n * @param elements Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns A new set containing all of the given elements, or empty set if `elements` is `null` or `undefined`.\n */\nexport function setOfElements<T>(elements: T | readonly T[] | null | undefined): Set<T> {\n return (/*#__INLINE__*/ isArrayOfElements(elements))\n ? new Set(elements)\n : (elements != null ? new Set([elements]) : new Set());\n}\n\n/**\n * Adds element of array of elements to the given set.\n *\n * Adds to the set a single element, all `elements` of the given array, or nothing when `elements` is `null`\n * or `undefined`.\n *\n * @param set Target set to add elements to.\n * @param elements Element(s) to add to the `set`. Either element, readonly array of elements, `null`, or `undefined`.\n *\n * @returns The target `set`.\n */\nexport function extendSetOfElements<T>(set: Set<T>, elements: T | readonly T[] | null | undefined): Set<T> {\n if (/*#__INLINE__*/ isArrayOfElements(elements)) {\n elements.forEach(element => set.add(element));\n } else if (elements != null) {\n set.add(elements);\n }\n return set;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport type { Class } from './class';\n\n/**\n * Detects a super class of the given class optionally satisfying the given criteria.\n *\n * Traverses all class ancestors until reaches the one satisfying the given criteria, or stops when there is no more\n * ancestors.\n *\n * @param type The class constructor to find super class of.\n * @param satisfying The criteria of super class matching. It is a function accepting a super class constructor\n * as the only parameter and returning `true` if the given super class matches, or `false` otherwise. Always returns\n * `true` by default.\n *\n * @return A super class `satisfying` the given criteria, or `undefined` if there is no such super class, or there is no\n * super class at all (e.g. when `Object` is passed in).\n */\nexport function superClassOf(type: Class, satisfying: (type: Class) => boolean = () => true): Class | undefined {\n\n // eslint-disable-next-line @typescript-eslint/no-unsafe-assignment\n const prototype: object = Object.getPrototypeOf(type.prototype);\n\n if (prototype == null) {\n return;\n }\n\n const superType = prototype.constructor as Class;\n\n if (satisfying(superType)) {\n return superType;\n }\n\n return superClassOf(superType, satisfying);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that returns its argument as is.\n *\n * @param value A value to return.\n *\n * @returns `value`.\n */\nexport function asis<T>(value: T): T {\n return value;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Merges two functions by calling one after another.\n *\n * Optionally merges function call results.\n *\n * @typeParam TArgs Function parameter types as tuple.\n * @typeParam TReturn A type of function result.\n * @typeParam TThis A type if `this` object expected by function.\n * @param first The first function to call.\n * @param second The second function to call.\n * @param merge Optional function call results merger. Accepts two function results as arguments and returns the final\n * result. When omitted the first function call result is ignored and the second function's call result is returned.\n *\n * @return A function that calls both of the given ones and merges their results. If one of the functions is absent,\n * then just returns another one. If both are absent, then returns `undefined`.\n */\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: (this: TThis, ...args: TArgs) => TReturn,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: (this: TThis, ...args: TArgs) => TReturn,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): (this: TThis, ...args: TArgs) => TReturn;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge?: (first: TReturn, second: TReturn) => TReturn,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined;\n\nexport function mergeFunctions<TArgs extends any[], TReturn, TThis>(\n first: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n second: ((this: TThis, ...args: TArgs) => TReturn) | undefined,\n merge: (first: TReturn, second: TReturn) => TReturn = (_f, s) => s,\n): ((this: TThis, ...args: TArgs) => TReturn) | undefined {\n if (!first) {\n return second;\n }\n if (!second) {\n return first;\n }\n return function (this: TThis, ...args: TArgs): TReturn {\n return merge(\n first.apply(this, args),\n second.apply(this, args),\n );\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that does nothing.\n *\n * @returns `undefined`.\n */\nexport function noop(): undefined {\n return;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n\n/**\n * Converts a value to its promise.\n *\n * @param value Either a value, or a promise-like instance resolving to it.\n *\n * @returns A promise resolving to the given value.\n */\nexport function asyncValue<T>(value: T | PromiseLike<T>): Promise<T> {\n return (async () => value)();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { asyncValue } from './async-value';\n\n/**\n * Asynchronous recipe of value evaluation.\n *\n * This is either a value as-is, a promise-like instance resolving to it, or its {@link AsyncRecipe.Evaluator evaluator}\n * function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type AsyncRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | PromiseLike<TValue>\n | AsyncRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace AsyncRecipe {\n\n /**\n * Asynchronous value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Either an valuated value, or a promise-like instance resolving to one.\n */\n (this: void, ...args: TArgs) => TValue | PromiseLike<TValue>;\n\n}\n\n/**\n * @internal\n */\nfunction isAsyncEvaluator<TValue, TArgs extends any[]>(\n value: AsyncRecipe<TValue, TArgs>,\n): value is AsyncRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Asynchronously evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns A promise resolved to the value.\n */\nexport async function asyncByRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n ...args: TArgs\n): Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts asynchronous value recipe to its {@link AsyncRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Asynchronous value recipe to convert.\n *\n * @returns A function asynchronously evaluating the value.\n */\nexport function asyncRecipe<TValue, TArgs extends any[]>(\n recipe: AsyncRecipe<TValue, TArgs>,\n): (this: void, ...args: TArgs) => Promise<TValue> {\n return (/*#__INLINE__*/ isAsyncEvaluator(recipe))\n ? (async (...args) => recipe(...args))\n : () => asyncValue(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Creates a provider of the only argument.\n *\n * @param value A value to return.\n *\n * @returns A function that returns `value`.\n */\nexport function valueProvider<T>(value: T): (this: void) => T {\n return (): T => value;\n}\n\n/**\n * Creates a provider of arguments tuple.\n *\n * The returned tuple should never be modified as it is not cloned.\n *\n * @param values Values to return.\n *\n * @returns A function that returns `values` tuple.\n */\nexport function valuesProvider<T extends readonly any[]>(...values: T): (this: void) => T {\n return (): T => values;\n}\n\n/**\n * Creates a provider of cloned arguments tuple.\n *\n * The returned tuple can be modified as it is cloned before the return.\n *\n * @param values Values to return.\n *\n * @returns A function that returns a clone of `values` tuple.\n */\nexport function valuesCloner<T extends any[]>(...values: T): (this: void) => T {\n return (): T => Array.from(values) as T;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * Creates a provider of lazily evaluated value.\n *\n * The returned function evaluates the value first time it is called. Then it just returns previously evaluated value.\n *\n * @param provider A no-arg function evaluating the value.\n *\n * @returns A function that returns the value evaluated by `provider`.\n */\nexport function lazyValue<T>(provider: (this: void) => T): (this: void) => T {\n\n let get = (): T => (get = valueProvider(provider()))();\n\n return (): T => get();\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { valueProvider } from './value-providers';\n\n/**\n * A recipe of value evaluation.\n *\n * This is either a value as-is, or its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\nexport type ValueRecipe<TValue, TArgs extends any[] = []> =\n | TValue\n | ValueRecipe.Evaluator<TValue, TArgs>;\n\nexport namespace ValueRecipe {\n\n /**\n * Value evaluator signature.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n */\n export type Evaluator<TValue, TArgs extends any[] = []> =\n /**\n * @param args Parameters required for value evaluation.\n *\n * @returns Evaluated value.\n */\n (this: void, ...args: TArgs) => TValue;\n\n}\n\n/**\n * @internal\n */\nfunction isValueEvaluator<TValue, TArgs extends any[]>(\n value: ValueRecipe<TValue, TArgs>,\n): value is ValueRecipe.Evaluator<TValue, TArgs> {\n return typeof value === 'function';\n}\n\n/**\n * Evaluates a value by its recipe.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value evaluation recipe.\n * @param args Parameters required for value evaluation.\n *\n * @returns Either the value itself, or the one evaluated by the given evaluator recipe.\n */\nexport function valueByRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n ...args: TArgs\n): TValue {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe(...args) : recipe;\n}\n\n/**\n * Converts a value recipe to its {@link ValueRecipe.Evaluator evaluator} function.\n *\n * @typeParam TValue Evaluated value type. This can not be a function.\n * @typeParam TArgs A type of parameters tuple required for value evaluation.\n * @param recipe Value recipe to convert.\n *\n * @returns Either evaluator itself, or the one evaluating to the given value.\n */\nexport function valueRecipe<TValue, TArgs extends any[]>(\n recipe: ValueRecipe<TValue, TArgs>,\n): ValueRecipe.Evaluator<TValue, TArgs> {\n return (/*#__INLINE__*/ isValueEvaluator(recipe)) ? recipe : valueProvider(recipe);\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\nimport { noop } from '../fn';\nimport { lazyValue } from '../value';\n\n/**\n * A resolver of promise that can be created later or not created at all.\n *\n * Creates the promise only on demand.\n *\n * The methods of this object do not require `this` context and can be called as functions.\n */\nexport interface PromiseResolver<T> {\n\n /**\n * Resolves the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param resolution Either a promise value, or a promise-like instance resolving to one.\n */\n resolve(this: void, ...resolution: undefined extends T ? [(T | PromiseLike<T>)?]: [T | PromiseLike<T>]): void;\n\n /**\n * Rejects the promise.\n *\n * Has no effect when the promised is already settled.\n *\n * Can be called before the promise constructed.\n *\n * @param reason Promise rejection reason.\n */\n reject(this: void, reason?: any): void;\n\n /**\n * Creates a promise resolved by {@link resolve}, or rejected by {@link reject}.\n *\n * The subsequent calls to this method return the same promise instance.\n *\n * @returns Created promise.\n */\n promise(this: void): Promise<T>;\n\n}\n\n/**\n * Creates a promise resolver.\n *\n * @returns New promise resolver.\n */\nexport function newPromiseResolver<T>(): PromiseResolver<T> {\n\n let resolvePromise: (value?: T | PromiseLike<T>) => void;\n let rejectPromise: (reason?: any) => void;\n let buildPromise = lazyValue(() => new Promise<T>((resolve, reject) => {\n resolvePromise = resolve;\n rejectPromise = reject;\n }));\n const settle = (resolution: () => Promise<T>): void => {\n buildPromise = lazyValue(resolution);\n resolvePromise = noop;\n rejectPromise = noop;\n };\n\n resolvePromise = value => {\n settle(() => Promise.resolve(value as T));\n };\n rejectPromise = error => {\n settle(() => Promise.reject(error));\n };\n\n return {\n resolve(value?) {\n resolvePromise(value);\n },\n reject(reason) {\n rejectPromise(reason);\n },\n promise() {\n return buildPromise();\n },\n };\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Property accessor descriptor. I.e. the one with `get` and `set` functions.\n *\n * @typeParam TValue Property value type.\n */\nexport interface PropertyAccessorDescriptor<TValue> extends TypedPropertyDescriptor<TValue> {\n enumerable?: boolean;\n configurable?: boolean;\n writable?: undefined;\n value?: undefined;\n get?: () => TValue;\n set?: (value: TValue) => void;\n}\n\n/**\n * Detects whether the given property descriptor is the one of property accessor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return `true` if the descriptor has no `value` or `writable` attributes set.\n */\nexport function isPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): desc is PropertyAccessorDescriptor<TValue> {\n return desc.value === undefined && desc.writable === undefined;\n}\n\n/**\n * Converts a property descriptor to property accessor descriptor.\n *\n * @typeParam TValue Property value type.\n * @param desc Target property descriptor.\n *\n * @return Either an accessor descriptor constructed from data descriptor, or `desc` if it is an accessor descriptor\n * already.\n */\nexport function toPropertyAccessorDescriptor<TValue>(\n desc: TypedPropertyDescriptor<TValue>,\n): PropertyAccessorDescriptor<TValue> {\n if (isPropertyAccessorDescriptor(desc)) {\n return desc;\n }\n\n const value__symbol = Symbol('value');\n\n interface ValueHost {\n [value__symbol]: TValue;\n }\n\n const initial = desc.value as TValue;\n\n const accessorDesc: PropertyAccessorDescriptor<TValue> = {\n ...desc,\n writable: undefined,\n value: undefined,\n get(this: ValueHost) {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n };\n\n if (desc.writable) {\n accessorDesc.set = function (this: ValueHost, newValue: TValue) {\n this[value__symbol] = newValue;\n };\n }\n\n delete accessorDesc.writable;\n delete accessorDesc.value;\n\n return accessorDesc;\n}\n\n/**\n * Creates an property accessor descriptor for the given field.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n */\nexport function fieldAccessorDescriptor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const value__symbol = Symbol(`${String(fieldKey)}:value`);\n\n interface ValueHost {\n [value__symbol]: TObject[TKey];\n }\n\n const initial: TObject[TKey] = target[fieldKey];\n\n return {\n configurable: true,\n enumerable: true,\n get(this: ValueHost): TObject[TKey] {\n return value__symbol in this ? this[value__symbol] : initial;\n },\n set(this: ValueHost, newValue) {\n this[value__symbol] = newValue;\n },\n };\n}\n\n/**\n * Converts an object field to property accessor.\n *\n * Defines a new property with the given name in the target object and returns its descriptor.\n *\n * The converted descriptor is always configurable, enumerable, and writable.\n *\n * @typeParam TObject The type of target object.\n * @typeParam TKey Target object property keys type.\n * @param target The object containing target field.\n * @param fieldKey Target field key.\n *\n * @return New property accessor descriptor.\n */\nexport function field2accessor<TObject, TKey extends keyof TObject>(\n target: TObject,\n fieldKey: TKey,\n): PropertyAccessorDescriptor<TObject[TKey]> {\n\n const desc = fieldAccessorDescriptor(target, fieldKey);\n\n Object.defineProperty(target, fieldKey, desc);\n\n return desc;\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given value is array-like.\n *\n * @typeParam TElement Array elements type.\n * @typeParam TOther Non-array value type.\n * @param value A value to check.\n *\n * @returns `true` if the `value` has a `length` property, or `false` otherwise.\n */\nexport function isArrayLike<TElement, TOther>(value: ArrayLike<TElement> | TOther): value is ArrayLike<TElement> {\n return !!value && typeof value === 'object' && typeof (value as Partial<ArrayLike<TElement>>).length === 'number';\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * Checks whether the given object is iterable.\n *\n * @typeParam TElement Iterable elements type.\n * @typeParam TOther Non-iterable value type.\n * @param value An object value to check.\n *\n * @returns `true` if the `value` has a `[Symbol.iterator]` property set, or `false` otherwise.\n */\nexport function isIterable<TElement, TOther>(value: Iterable<TElement> | TOther): value is Iterable<TElement> {\n return !!(value as Iterable<TElement>)[Symbol.iterator];\n}\n","/**\n * @packageDocumentation\n * @module @proc7ts/primitives\n */\n/**\n * A function that checks whether the given value is present.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `null` or `undefined`, or `false` otherwise.\n */\nexport function isPresent<T>(value: T | undefined | null): value is T {\n return value != null;\n}\n\n/**\n * A function that checks whether the given value is not present.\n *\n * This is a direct opposite to `isPresent()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `null` or `undefined`, or `false` otherwise.\n */\nexport function isNotPresent<T>(value: T | undefined | null): value is T {\n return value == null;\n}\n\n/**\n * A function that checks whether the given value is defined.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is not `undefined`, or `false` otherwise.\n */\nexport function isDefined<T>(value: T | undefined): value is T {\n return value !== undefined;\n}\n\n/**\n * A function that checks whether the given value is undefined.\n *\n * This is a direct opposite to `isDefined()`.\n *\n * @param value A value to check.\n *\n * @returns `true` when the given `value` is `undefined`, or `false` otherwise.\n */\nexport function isUndefined<T>(value: T | undefined): value is T {\n return value === undefined;\n}\n"],"names":[],"mappings":"AAAA;;;;SAuBgB,iBAAiB,CAAI,KAA0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CAAC,QAAQ,CAAC,CAAC;AAC1D;;ACfA;;;;AAIA;;;;;;;SAOgB,SAAS,CAAI,KAA2B;IACtD,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;;;SASgB,YAAY,CAAI,KAA2B;IACzD,OAAO,KAAK,IAAI,IAAI,CAAC;AACvB,CAAC;AAED;;;;;;;SAOgB,SAAS,CAAI,KAAoB;IAC/C,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B,CAAC;AAED;;;;;;;;;SASgB,WAAW,CAAI,KAAoB;IACjD,OAAO,KAAK,KAAK,SAAS,CAAC;AAC7B;;;;"} |
+1
-1
| { | ||
| "name": "@proc7ts/primitives", | ||
| "version": "1.3.0", | ||
| "version": "1.3.1", | ||
| "description": "Type and function primitives", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
123893
0.67%1488
0.4%