|
Last change
on this file was a762898, checked in by istevanoska <ilinastevanoska@…>, 5 months ago |
|
Added visualizations
|
-
Property mode
set to
100644
|
|
File size:
601 bytes
|
| Line | |
|---|
| 1 | function conformsTo(target, source) {
|
|---|
| 2 | if (source == null) {
|
|---|
| 3 | return true;
|
|---|
| 4 | }
|
|---|
| 5 | if (target == null) {
|
|---|
| 6 | return Object.keys(source).length === 0;
|
|---|
| 7 | }
|
|---|
| 8 | const keys = Object.keys(source);
|
|---|
| 9 | for (let i = 0; i < keys.length; i++) {
|
|---|
| 10 | const key = keys[i];
|
|---|
| 11 | const predicate = source[key];
|
|---|
| 12 | const value = target[key];
|
|---|
| 13 | if (value === undefined && !(key in target)) {
|
|---|
| 14 | return false;
|
|---|
| 15 | }
|
|---|
| 16 | if (typeof predicate === 'function' && !predicate(value)) {
|
|---|
| 17 | return false;
|
|---|
| 18 | }
|
|---|
| 19 | }
|
|---|
| 20 | return true;
|
|---|
| 21 | }
|
|---|
| 22 |
|
|---|
| 23 | export { conformsTo };
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.