|
Last change
on this file since ba17441 was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
1.1 KB
|
| Line | |
|---|
| 1 | import { ConformsPredicateObject } from '../_internal/ConformsPredicateObject.mjs';
|
|---|
| 2 |
|
|---|
| 3 | /**
|
|---|
| 4 | * Creates a function that invokes the predicate properties of `source` with the corresponding property values of a given object, returning `true` if all predicates return truthy, else `false`.
|
|---|
| 5 | *
|
|---|
| 6 | * Note: The created function is equivalent to `conformsTo` with source partially applied.
|
|---|
| 7 | *
|
|---|
| 8 | * @param {Record<PropertyKey, (value: any) => boolean>} source The object of property predicates to conform to.
|
|---|
| 9 | * @returns {(object: Record<PropertyKey, any>) => boolean} Returns the new spec function.
|
|---|
| 10 | *
|
|---|
| 11 | * @example
|
|---|
| 12 | * const isPositive = (n) => n > 0;
|
|---|
| 13 | * const isEven = (n) => n % 2 === 0;
|
|---|
| 14 | * const predicates = { a: isPositive, b: isEven };
|
|---|
| 15 | * const conform = conforms(predicates);
|
|---|
| 16 | *
|
|---|
| 17 | * console.log(conform({ a: 2, b: 4 })); // true
|
|---|
| 18 | * console.log(conform({ a: -1, b: 4 })); // false
|
|---|
| 19 | * console.log(conform({ a: 2, b: 3 })); // false
|
|---|
| 20 | * console.log(conform({ a: 0, b: 2 })); // false
|
|---|
| 21 | */
|
|---|
| 22 | declare function conforms<T>(source: ConformsPredicateObject<T>): (value: T) => boolean;
|
|---|
| 23 |
|
|---|
| 24 | export { conforms };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.