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