MCPcopy Create free account
hub / github.com/angular/angular / search

Method search

packages/common/upgrade/src/location_shim.ts:661–700  ·  view source on GitHub ↗
(
    search?: string | number | {[key: string]: unknown},
    paramValue?: null | undefined | string | number | boolean | string[],
  )

Source from the content-addressed store, hash-verified

659 paramValue: null | undefined | string | number | boolean | string[],
660 ): this;
661 search(
662 search?: string | number | {[key: string]: unknown},
663 paramValue?: null | undefined | string | number | boolean | string[],
664 ): {[key: string]: unknown} | this {
665 switch (arguments.length) {
666 case 0:
667 return this.$$search;
668 case 1:
669 if (typeof search === 'string' || typeof search === 'number') {
670 this.$$search = this.urlCodec.decodeSearch(search.toString());
671 } else if (typeof search === 'object' && search !== null) {
672 // Copy the object so it's never mutated
673 search = {...search};
674 // remove object undefined or null properties
675 for (const key in search) {
676 if (search[key] == null) delete search[key];
677 }
678
679 this.$$search = search;
680 } else {
681 throw new Error(
682 'LocationProvider.search(): First argument must be a string or an object.',
683 );
684 }
685 break;
686 default:
687 if (typeof search === 'string') {
688 const currentSearch = this.search();
689 if (typeof paramValue === 'undefined' || paramValue === null) {
690 delete currentSearch[search];
691 return this.search(currentSearch);
692 } else {
693 currentSearch[search] = paramValue;
694 return this.search(currentSearch);
695 }
696 }
697 }
698 this.composeUrls();
699 return this;
700 }
701
702 /**
703 * Retrieves the current hash fragment, or changes the hash fragment and returns a reference to

Callers 7

urlMethod · 0.95
formatTemplateFunction · 0.45
getConditionMethod · 0.45
upgrade.spec.tsFile · 0.45
constructorMethod · 0.45
searchWithQueryMethod · 0.45

Calls 3

composeUrlsMethod · 0.95
decodeSearchMethod · 0.80
toStringMethod · 0.65

Tested by

no test coverage detected