MCPcopy
hub / github.com/mongodb/node-mongodb-native / ejson

Function ejson

test/tools/utils.ts:173–195  ·  view source on GitHub ↗
(strings: TemplateStringsArray, ...values: any[])

Source from the content-addressed store, hash-verified

171 * falls back to util.inspect if there's an error (circular reference)
172 */
173export function ejson(strings: TemplateStringsArray, ...values: any[]) {
174 const stringParts = [strings[0]];
175 for (const [idx, value] of values.entries()) {
176 if (typeof value === 'object') {
177 let stringifiedObject: string;
178 try {
179 stringifiedObject = EJSON.stringify(value, { relaxed: false });
180 } catch {
181 stringifiedObject = inspect(value, {
182 depth: Infinity,
183 showHidden: true,
184 compact: true
185 });
186 }
187 stringParts.push(stringifiedObject);
188 } else {
189 stringParts.push(String(value));
190 }
191 stringParts.push(strings[idx + 1]);
192 }
193
194 return stringParts.join('');
195}
196
197/**
198 * Run an async function after some set timeout

Callers 3

specialCheckFunction · 0.90
runUnifiedTestFunction · 0.90
executeSDAMTestFunction · 0.90

Calls 2

inspectFunction · 0.50
pushMethod · 0.45

Tested by 1

executeSDAMTestFunction · 0.72