Skip to content
This repository has been archived by the owner on Dec 11, 2019. It is now read-only.

support new Set(...) in ledger publisher ruleset #3545

Merged
merged 4 commits into from
Aug 30, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions app/extensions/brave/content/scripts/pageInformation.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,15 @@
expr['arguments'].forEach((argument) => { args.push(traverse(argument)) })
return value[traverse(op1.property, true)].apply(value, args)

case 'NewExpression':
op1 = expr.callee
if (op1.type !== 'Identifier') throw new Error('unexpected callee: ' + op1.type)
if (op1.name !== 'Set') throw new Error('only new Set(...) is allowed, not new ' + op1.name)
args = []
expr['arguments'].forEach((argument) => { args.push(traverse(argument)) })
if (args.length > 1) throw new Error('Set(...) takes at most one argument')
return new Set(args[0])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't you want return new Set(...args) for full generality? No point collecting the traversed arguments in args past the first one if you use only the first one.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Set takes at most one argument, which is an array. if i were to pass args instead of args[0], then i would need to do use .apply() as well. i will make it clearer.


case 'ConditionalExpression':
return (traverse(expr.test) ? traverse(expr.consequent) : traverse(expr.alternate))

Expand Down
2 changes: 1 addition & 1 deletion js/about/preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ class PaymentsTab extends ImmutableComponent {
<span id='fundsAmount'>
{this.btcToCurrencyString(this.props.ledgerData.get('balance'))}
<a href='https://brave.com/Payments_FAQ.html' target='_blank'>
<span className='fa fa-question-circle fundsFAQ'></span>
<span className='fa fa-question-circle fundsFAQ' />
</a>
</span>
{this.walletButton}
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,8 @@
"keytar": "^3.0.0",
"l20n": "^3.5.1",
"ledger-balance": "^0.8.46",
"ledger-client": "^0.8.50",
"ledger-publisher": "^0.8.47",
"ledger-client": "^0.8.54",
"ledger-publisher": "^0.8.54",
"lru_cache": "^1.0.0",
"random-lib": "2.1.0",
"qr-image": "^3.1.0",
Expand Down