Started reading the strfry-policies code before I implement it on the free relay. And I'm just learning Typescript after not using JS since, uh, before ES5 was a thing? Anyway, I'm learning by trying to read it and then asking copilot "What the hell is that" (`/explain`) when I don't understand some syntax.

TIL about destructuring assignment shorthand:

```Typescript

.. async (msg, opts = {}) => {

const {

interval = 60000,

max = 10,

whitelist = [],

databaseUrl = 'sqlite:///tmp/strfry-rate-limit-policy.sqlite3',

} = opts;

```

Coming from Python that just looks weird.

But yeah, it's shorthand syntax for extracting properties from an object and assigning them to variables with the same name as the properties.

```Typescript

const person = { name: 'Satoshi', age: 99 };

const { name, age } = person;

console.log(name); // 'Satoshi'

console.log(age); // 99

```

Thank you nostr:npub108pv4cg5ag52nq082kd5leu9ffrn2gdg6g4xdwatn73y36uzplmq9uyev6

Reply to this note

Please Login to reply.

Discussion

No replies yet.