/
githubmirror
/
amphtml
Обзор
Документация
Войти
/
githubmirror
/
amphtml
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
main
extensions/amp-bind/0.1/bind-macro.js
42 строки
1020 B
Shihua Zheng
commit (#39097)
06 июн 2023, 02:37
Не верифицирован
06 июн 2023, 02:37
649e4ac
Код
Авторство
О чём код?
import {BindExpression} from './bind-expression'; /** * A single parsed Bind macro. */ export class BindMacro { /** * @param {!BindMacroDef} data * @param {!{[key: string]: !BindMacro}} referableMacros */ constructor(data, referableMacros) { /** @const @private {!Array<string>} */ this.argumentNames_ = data.argumentNames || []; /** @const @private {!BindExpression} */ this.expression_ = new BindExpression( data.expressionString, referableMacros ); } /** * @param {!JsonObject} scope * @param {!Array} args * @throws {Error} On illegal function invocation. * @return {BindExpressionResultDef} */ evaluate(scope, args) { const copy = /** @type {!JsonObject} */ ({...scope}); for (let i = 0; i < this.argumentNames_.length; i++) { copy[this.argumentNames_[i]] = args[i]; } return this.expression_.evaluate(copy); } /** * @return {number} */ getExpressionSize() { return this.expression_.expressionSize; } }