MCPcopy Create free account
hub / github.com/JPeer264/node-rcs-core / get

Method get

lib/selectorsLibrary.ts:136–162  ·  view source on GitHub ↗
(value: string, opts: BaseLibraryOptions = {})

Source from the content-addressed store, hash-verified

134 }
135
136 get(value: string, opts: BaseLibraryOptions = {}): string {
137 const stringifyLineBreaks = value.replace(/\n/g, '\\n');
138 const [beginningWhitespace] = stringifyLineBreaks.match(/^(\\.| )+/) || [''];
139 const [endWhitespace] = stringifyLineBreaks.match(/(\\.| )+$/) || [''];
140 const modifiedValue = stringifyLineBreaks.replace(beginningWhitespace, '').replace(endWhitespace, '');
141 const hasType = AttributeLibrary.isSelector(modifiedValue);
142
143 const reconstructValue = (v: string): string => (
144 (beginningWhitespace + v + endWhitespace).replace(/\\n/g, '\n')
145 );
146
147 if (!hasType) {
148 const ret = this.selectors[0].get(modifiedValue, opts);
149
150 return reconstructValue((
151 ret === modifiedValue
152 ? this.selectors[1].get(modifiedValue, opts)
153 : ret
154 ));
155 }
156
157 if (this.selectors[0].isValidSelector(modifiedValue)) {
158 return reconstructValue(this.selectors[0].get(modifiedValue, opts));
159 }
160
161 return reconstructValue(this.selectors[1].get(modifiedValue, opts));
162 }
163
164 // If it's reserved in any case, consider it reserved everywhere
165 isReserved(...args: Parameters<BaseLibrary['isReserved']>): ReturnType<BaseLibrary['isReserved']> {

Callers

nothing calls this directly

Calls 2

isSelectorMethod · 0.80
isValidSelectorMethod · 0.80

Tested by

no test coverage detected