13 lines
357 B
JavaScript
13 lines
357 B
JavaScript
|
|
import { computeValue } from "../../core";
|
||
|
|
import { assert, isObject } from "../../util";
|
||
|
|
const $replaceWith = (collection, expr, options) => {
|
||
|
|
return collection.map((obj) => {
|
||
|
|
obj = computeValue(obj, expr, null, options);
|
||
|
|
assert(isObject(obj), "$replaceWith expression must return an object");
|
||
|
|
return obj;
|
||
|
|
});
|
||
|
|
};
|
||
|
|
export {
|
||
|
|
$replaceWith
|
||
|
|
};
|