|
|
|
|
@ -210,7 +210,7 @@ export function function_declaration(id, params, body) {
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} name
|
|
|
|
|
* @param {import('estree').Statement[]} body
|
|
|
|
|
* @returns {import('estree').Property}
|
|
|
|
|
* @returns {import('estree').Property & { value: import('estree').FunctionExpression}}}
|
|
|
|
|
*/
|
|
|
|
|
export function get(name, body) {
|
|
|
|
|
return prop('get', key(name), function_builder(null, [], block(body)));
|
|
|
|
|
@ -305,11 +305,12 @@ export function object_pattern(properties) {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* @template {import('estree').Expression} Value
|
|
|
|
|
* @param {'init' | 'get' | 'set'} kind
|
|
|
|
|
* @param {import('estree').Expression} key
|
|
|
|
|
* @param {import('estree').Expression} value
|
|
|
|
|
* @param {Value} value
|
|
|
|
|
* @param {boolean} computed
|
|
|
|
|
* @returns {import('estree').Property}
|
|
|
|
|
* @returns {import('estree').Property & { value: Value }}
|
|
|
|
|
*/
|
|
|
|
|
export function prop(kind, key, value, computed = false) {
|
|
|
|
|
return { type: 'Property', kind, key, value, method: false, shorthand: false, computed };
|
|
|
|
|
@ -355,23 +356,10 @@ export function sequence(expressions) {
|
|
|
|
|
/**
|
|
|
|
|
* @param {string} name
|
|
|
|
|
* @param {import('estree').Statement[]} body
|
|
|
|
|
* @param {import('estree').Expression | null} [fallback]
|
|
|
|
|
* @returns {import('estree').Property}
|
|
|
|
|
* @returns {import('estree').Property & { value: import('estree').FunctionExpression}}
|
|
|
|
|
*/
|
|
|
|
|
export function set(name, body, fallback) {
|
|
|
|
|
return prop(
|
|
|
|
|
'set',
|
|
|
|
|
key(name),
|
|
|
|
|
function_builder(
|
|
|
|
|
null,
|
|
|
|
|
[
|
|
|
|
|
fallback
|
|
|
|
|
? { type: 'AssignmentPattern', left: id('$$value'), right: fallback }
|
|
|
|
|
: id('$$value')
|
|
|
|
|
],
|
|
|
|
|
block(body)
|
|
|
|
|
)
|
|
|
|
|
);
|
|
|
|
|
export function set(name, body) {
|
|
|
|
|
return prop('set', key(name), function_builder(null, [id('$$value')], block(body)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|