MCPcopy
hub / github.com/adobe/react-spectrum / omit

Function omit

packages/dev/parcel-packager-docs/DocsPackager.js:519–552  ·  view source on GitHub ↗
(obj, toOmit, nodes)

Source from the content-addressed store, hash-verified

517}
518
519function omit(obj, toOmit, nodes) {
520 obj = resolveValue(obj, nodes);
521
522 if (obj.type === 'interface' || obj.type === 'object') {
523 let keys = new Set();
524 if (toOmit.type === 'string' && toOmit.value) {
525 keys.add(toOmit.value);
526 } else if (toOmit.type === 'union') {
527 for (let e of toOmit.elements) {
528 if (e.type === 'string' && e.value) {
529 keys.add(e.value);
530 }
531 }
532 }
533
534 if (keys.size === 0) {
535 return obj;
536 }
537
538 let properties = {};
539 for (let key in obj.properties) {
540 if (!keys.has(key)) {
541 properties[key] = obj.properties[key];
542 }
543 }
544
545 return {
546 ...obj,
547 properties
548 };
549 }
550
551 return obj;
552}
553
554// Exactly the same as `omit()` above except for `keys.has(key)` instead of `!keys.has(key)`.
555function pick(obj, toPick, nodes) {

Callers 1

fnFunction · 0.85

Calls 3

resolveValueFunction · 0.70
addMethod · 0.65
hasMethod · 0.65

Tested by

no test coverage detected