« first day (4439 days earlier)      last day (503 days later) » 

8:57 AM
Makes sense
I am trying to use my custom useDataFetcher hook
useDataFetcher({ fetcher: getSingleMonthPayslipPdf })
but I am expecting only id of payslip
 
 
4 hours later…
1:07 PM
const person = {
	firstName: 'Mile',
  lastName: 'Mijatovic',
  age: 37,
  getPersonInfo: () => this.firstName + ' ' + this.lastName
}

console.log(person.getPersonInfo())
why it's undefined ?
getPersonInfo: function() { return this.firstName + ' ' + this.lastName }
this works
Ohh, I know , this in arrow function is not the same
Arrow function can never be a method
 
1:48 PM
They could. But either they shouldn't use this or if they do, it should be inside class syntax, not an object literal.
136
Q: Methods in ES6 objects: using arrow functions

foxIn ES6, both of these are legal: var chopper = { owner: 'Zed', getOwner: function() { return this.owner; } }; and, as shorthand: var chopper = { owner: 'Zed', getOwner() { return this.owner; } } Is it possible to use the new arrow functions as well? In trying something like var ...

Also relevant
894
Q: Self-references in object literals / initializers

kpozinIs there any way to get something like the following to work in JavaScript? var foo = { a: 5, b: 6, c: this.a + this.b // Doesn't work }; In the current form, this code obviously throws a reference error since this doesn't refer to foo. But is there any way to have values in an ob...

Because arrow functions work the same way. They capture the this of the surrounding context, not the this of the object literal being initialised right now.
 
 
2 hours later…
3:53 PM
You could use person instead of this, since person is a const and will be accessible inside the arrow function.
 
4:35 PM
hmmmm, this is unexpected: stackoverflow.com/questions/57798609/… python's pickle work as is with node.js??
I mean, I know it's possible to support it, but that's not the point here. What's surprising to me is that it's already supported (instead of being a third party module/package, etc).
 
@NordineLotfi It says it's a package: "jpickle": "git+https://github.com/jlaine/node-jpickle.git"
Also, the error is from node_modules/jpickle/lib/jpickle.js:341 so it's a node_modules package
 
4:58 PM
@VLAZ welp, that's embarrassing. In my defence, I never used nodejs (yet) so I just thought this was the case anyway :O
 
5:13 PM
Hmm, I'm unsure how to name a function. I have a private function that creates a special view on top of an array, and an exported function that creates an array and calls the private function internally. I wanted to call the public function create, but then how should I call the private one...
In dart this would just be a public constructor that calls the private constructor, and I'd probably name the private one NameOfTheClass._() or NameOfTheClass._internal(), but in a more FP-oriented JavaScript code style I'd rather use a verb for function names.
 
5:40 PM
You could just call it _create. Underscore in the beginning is somewhat widely accepted to mean "internal" or otherwise "not exposed".
An alternative to create is make if you wish.
 
 
1 hour later…
6:43 PM
Steam deck says it's GPU is up to 1.6 TFlops
the xbox x says it's 12TFlops
is xbox about 10x faster than steamdeak? that doesn't sound right
 
That depends on how you measure it, right?
 
I don't follow
 
But also Steam deck is smaller. Maybe it's not that far fetched.
 
They have CPU at 400GF and CPU at 1.6TF so even if they added all the flops up you'd get 2TF total
What's better Common JS or ES6 modules? Will ES6 ever adopt support for CJS?
If you use CJS and a JS library uses ES6 you can still use it correct? You just have to use different syntax in the specific module?
you can't combine import and require syntax traditionally?
 
7:31 PM
@Domino to add on top of what @VLAZ said, if your environment supports true privacy, you can just call it #create. In any case, using a verb is a good choice indeed
 
I'm not using classes at all, but a purely functional style. What I meant by private is not exported.
So it's not a method which could be stored in a private property, it's just a function.
 
@1.21gigawatts ESM is not "better", it just is. The ecosystem is going in the direction of having a standardized modile system, which is ESM, so unless you want to have to refactor everything down the line, I'd go for ESM. After all, no one stops you from transpiling to CJS until ESM becomes stable.
 
I see
 
As for support of CJS in ESM, no, never. ESM was designed to replace existing module systems to solve the hell we have been working with for years (although it contributed to the module hell in the process)
 
Yeah, ESM is a case of "let's add another standard to solve the problem of having too many standards", but since it's part of the language specification itself it just makes sense to move to it.
 
7:37 PM
It seems that the language spec seems to be a good bet
but we also have typescript
for what 10 years now?
 
@1.21gigawatts kinda-sorta. Technically, yes, but there is a bunch of interop issues you need to be aware of. You can read about what's generally possible in the Node.js docs
@1.21gigawatts no, you'll have to stick with one of them. There is no require in ESM and there is no static import in CJS. You can do dynamic imports of ESM modules in CJS, though. TypeScript also has a special syntax import name = require but that is not the require of CJS modules
@Domino which module system are you using? If it's just a finction, then yeah, underscoring it is a well-known convention for indicating that it is intended for private use. You can also just not export it if it's in the same module as the dependent functions or not export it from the entry points of your program otherwise
@Domino yeah. At least everyone agrees to use ESM going forward, and that's a huge plus, especially given that TypeScript is moving in that direction more and more with recent releases. We are currently in the interop hell, but ESM is slowly stabilizing the more people use it in their projects
@1.21gigawatts yup, always the best bet
TypeScript's stated goal is to be as close to the ECMA spec as possible, even to the point of making some things quite inconvenient to do with it, so it shouldn't hinder the process of transitioning to the One Module System to Rule Them All
@1.21gigawatts about right - I don't recall when it was released as 1.0, but it is around since, IIRC, 2012?
ah, yes, October 1st, 2012
 
7:55 PM
Here's a minimal example of my code style:
export function create (width, height) {
    return _create(Array(width * height), width, height);
}
function _create (slots, width, height) {
    const grid = Object.freeze({
        get: (x, y) => slots[x + (width * y)],
        set: (x, y, value) => slots[x + (width * y)] = value,
        map: (mapFn) => _create(slots.map((v, k) => mapFn(v, k, grid)), width, height),
        clone: () => _create(Array.from(slots), width, height),
    });
    return grid;
}
You'd use import * as Grid from "..." in another file to then call Grid.create(...)
The reason this needs to be two functions in the first place is so I can implement functions like map efficiently.
 
8:23 PM
looks good to me, pretty idiomatic
 

« first day (4439 days earlier)      last day (503 days later) »