|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
918 bytes
|
| Rev | Line | |
|---|
| [a762898] | 1 | import { isMatch } from './isMatch.mjs';
|
|---|
| 2 | import { toKey } from '../_internal/toKey.mjs';
|
|---|
| 3 | import { cloneDeep } from '../object/cloneDeep.mjs';
|
|---|
| 4 | import { get } from '../object/get.mjs';
|
|---|
| 5 | import { has } from '../object/has.mjs';
|
|---|
| 6 |
|
|---|
| 7 | function matchesProperty(property, source) {
|
|---|
| 8 | switch (typeof property) {
|
|---|
| 9 | case 'object': {
|
|---|
| 10 | if (Object.is(property?.valueOf(), -0)) {
|
|---|
| 11 | property = '-0';
|
|---|
| 12 | }
|
|---|
| 13 | break;
|
|---|
| 14 | }
|
|---|
| 15 | case 'number': {
|
|---|
| 16 | property = toKey(property);
|
|---|
| 17 | break;
|
|---|
| 18 | }
|
|---|
| 19 | }
|
|---|
| 20 | source = cloneDeep(source);
|
|---|
| 21 | return function (target) {
|
|---|
| 22 | const result = get(target, property);
|
|---|
| 23 | if (result === undefined) {
|
|---|
| 24 | return has(target, property);
|
|---|
| 25 | }
|
|---|
| 26 | if (source === undefined) {
|
|---|
| 27 | return result === undefined;
|
|---|
| 28 | }
|
|---|
| 29 | return isMatch(result, source);
|
|---|
| 30 | };
|
|---|
| 31 | }
|
|---|
| 32 |
|
|---|
| 33 | export { matchesProperty };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.