Add experimental once function

This commit is contained in:
yuanchuan 2023-02-19 12:30:17 +08:00
parent 787bb390c0
commit dffd83078b
1 changed files with 10 additions and 0 deletions

View File

@ -688,6 +688,16 @@ const Expose = add_alias({
}
},
once({ context, extra, position }) {
let counter = 'once-counter' + position;
return (...args) => {
if (is_nil(context[counter])) {
context[counter] = args;
}
return context[counter];
}
},
}, {
'index': 'i',