« first day (5 days earlier)      last day (165 days later) » 

00:19
type checking as in typeof?
 
6 hours later…
06:12
@thefourtheye If you have already verified that iterable is a null, why are you checking its class with Object..toString? Just throw new TypeError('null object is not iterable') instead?
Also:
  for (const value of iterable) {
    yield value;
  }
is just yield* iterable;
Ahh I see the history. github.com/thefourtheye/itertools.js/commit/… if you want to verify it is an object, just do Object(iterable) === iterable
@AwalGarg Oh, I didn't think of that. Thanks man :-)
I was discussing this in Babel's Slack. I am going to ask them about this now.
don't bring type checking back though :P benji is entirely correct here
I agree. I am just trying to understand if that is the correct way to do that.
06:28
@thefourtheye the "correct" way would probably be to verify that it is not one of the 6 primitives. Also, strings are primitive but have a [Symbol.iterator] :P
That is fine, because I am anyway iterating the Strings.
is what you mean, right?
06:57
@AwalGarg Hmmm, @loganfsmyth is the one who is helping me with this. And again, generators are objects only. So, Object(iterable) === iterable will be true for them as well.
@thefourtheye right. isn't that what you want? why'd you special case generator objects?
Actually I was special casing Objects.
So this check cannot tell if the passed object is really an Object or a Generator :-)
@thefourtheye so special case all objects which are not generators, IIUC?
Not all objects, but only the [object Object] objects
 
5 hours later…
12:22
@thefourtheye why?
@BenjaminGruenbaum I am not doing that now. I removed all the type checks :-)
Basically, in Python, when you iterate an dict, only the keys will be returned.
Hmmm, looks like this is the only way to get GeneratorFunction function object.
console.log(Object.getPrototypeOf(function* () {}()).constructor);
@thefourtheye You don't need the Object.getPrototypeOf part
Oh
How else it can be accessed then?
just (function*(){}).constructor
12:37
Are you able to create a new Generator object with that?
sure. check object equality between your version and mine
const GeneratorFunction1 = Object.getPrototypeOf(function* () {}()).constructor;
const GeneratorFunction2 = (function* () {}).constructor;

console.log(GeneratorFunction1 === GeneratorFunction2);
// false
When I try to create an object with my version, it throws a TypeError
const genObject1 = new GeneratorFunction1();
TypeError: GeneratorFunction1 is not a function
this makes no sense
12:44
But I am able to create objects with yours :-)
Do not type check, that will fail miserably in a wide scenario of cases.
For example - if your code runs in NodeWebkit it might have two different copies of the Generator prototype object.
If the code is transpiled - it won't be a "real" generator, etc.
@BenjaminGruenbaum ^ why is that equality check failing? I can refer to the spec but in the middle of a couple of things :P
@AwalGarg of course they're different - one is the prototype and one is not.
Still the constructor should have been a function, right?
@BenjaminGruenbaum no?
@thefourtheye the error message is wrong, but the class is correct
12:47
Actually console.log(typeof GeneratorFunction1); is printing object
I think I am making a very basic mistake somewhere.
@thefourtheye wait, you confused me with syntax :(
Don't type check - what if I just create a function that returns an iterator but is not a generator?
> nodes6
> let x = function*(){}
undefined
> x.__proto__.constructor === x.constructor
true
> Object.getPrototypeOf(x).constructor === x.constructor
true
@BenjaminGruenbaum True, but Object.getPrototypeOf(function* () {}()).constructor should be a function object, right?
It's a erm, function like? It has .call and .apply
In short, you're not really supposed to use it that way - the spec makes no guarantees (although I only read that part long ago in 2014) and that makes sense anyway since you shouldn't type check at all here.
12:51
@BenjaminGruenbaum Oh okay. I am just playing with it.
function notAGenerator() {
     var i  = 0;
     return { next() { return i<10? i++ : undefined },
                 done() { return i >= 10; },
                 return() { i = 10; return next() },
                 throw(e) { i = 10; throw e; },
}
@thefourtheye your code should be able to deal with the above although it is not a generator
I see. It is very generic.
@AwalGarg You are right :-) I was doing something like this x().__proto__.constructor === x.constructor. That is why it was failing.
13:08
That's what I said :D
13:30
@thefourtheye yeah, I was quite astonished as well :D
14:10
@BenjaminGruenbaum nit: should return objects :P
15:07
Yeah lol, that was silly, I started typing correctly in the console and got confused :D
15:26
@thefourtheye by the way, you didn't register for github.com/nodejs/docs/issues/52
Hey Petka :)
@Esailija by the way, regarding iterators - I do think it could be interesting to deal with them. Wouldn't keeping it open and having a pr-welcome label be beneficial?
he could have gotten what he wanted literally by replacing mapSeries with coroutine
@Esailija yes, if you have coroutines you don't really need any of the helpers - so there's that. With coroutines or async functions - promises don't even have to be monadic - it might as well not even chain.
15:40
huh?
if you have iterators you have coroutines..
@Esailija no, you can have iterators just fine without coroutines.
iterators are much more recent feature
Than coroutines? Coroutines return iterators, you can have iterators in ES3
he was writing yield and using function*
@Esailija I'm talking about it as an optimization.
Although I admit it's a lot of work for something that's not that big of a deal. The only bluebird features I use often with babel is debugging and performance.
15:43
it's a huge deoptimization and rewrite
;D
And swapping Promise.all(col.map(fn)) with Promise.amp(col, fn)
@Esailija it's just a case (if not array, do X else do Y).
it's literally a rewrite of like 50% of the code base
maybe more
I don't think you get it
@Esailija It's to add a lazy case and not create a PromiseArray, I understand it's not trivial but it's not 50% rewrite.
@Esailija How's the audio player thing coming along btw?
15:48
i've been optizmining it recently since it had 4 fps on android chrome
so not a lot of features added
The worst browser is iOS Chrome - be sure to test there - it doesn't have a JIT
I shit you not.
they do in recent ios
and why would you use chrome on ios since it's just safari with different skin
They can but they don't. They use UIWebView and not UIWebkitView
@Esailija I don't, but a lot of people apparently do - we had to do a lot of work to get it to run. Also - you don't have dev tools there or a debugger.
issue wasn't even javascript performance but graphics
you have to use webgl just to draw a static picture
and canvas to update text
also if you do anything the whole thing collapses and you go from 50 fps to 4 fps again
like saying minimum-scale=1 in metadata lowers fps by 2x
lol
@Esailija wait, what?
15:53
yea if you use Show layer borders [x] in devtools
you can see how saying minimum-scale=1 changes the tile borders
in a way that was devastating to the app
lol
We ended up tuning our app for like 2 weeks and now it's super fast - turns out it was fast to begin with and the problem is Azure (600ms to serve a static file). So now we have like 400ms load lol.
also i of course had to implement scrolling from scratch (though Zynga had a nice library)
the scroll libraries I found were fucking shit, using .scrollTop etc
lol, scrollTop.
scrollTop like it's 1995
of course later on I found this cubiq.org/iscroll-5
at that point I had already implemented it
I had someone lecture me on how awesome and stable node is the other day by the day. Ended up sending him the __proto__ trick in an object and watched his app crash. That was hilarious.
15:57
old node? proto shouldn't do anything in json
@Esailija shouldn't :D
JSON.parse('{"__proto__": {"x":3} }').__proto__ // {x: 3}
yea it doesn't do anything that any other property wouldn't do
if you have updated node
They accessed __proto__ to make an assertion :P It was much dumber.
omg 2016 and you still cannot copy paste a screenshot here?
Like, obj.__proto__.isValid.
16:11
@loktar ping me if you wanna see what I did with your "hacker" thing
 
3 hours later…
19:35
@crl welcome to ECMAScript
 
2 hours later…
21:34
If anyone's around, do you have a preferred DI framework for Node?
Got a neat little Redis thing but the tests require, well, Redis
21:45
proxyquire was the best last time I tried, but none of them played nicely with Babel
namely that they both overwrite require
If you are transpiling, do it first (rather than on the fly), then you might have better luck
welcome, @ydaniv
@phenomnomnominal I'm using TS, so wheeeee
I've never used TS server side, do you always have to transpile before?
22:00
Yeah, there's no insta-run
but this is for a library anyway so that's not too harsh
Just added a getClient method and overrode that.
you don't use interfaces?
oh I see
I do, just not there. I'll have an IExternalClient interface before the 0.7 branch gets merged in
22:17
@SomeKittens I'm actually looking for one.
Angular made all of that so easy
Angular 1 had terrible DI with a global container and singletons :D
still, easy :P
Angular 1 basically doesn't have good DI at all (it does have easy DI) - it's mostly surprising because Misko is one of the biggest DI advocates out there.
window.foo is easy too though I suppose
22:20
Write a very influential post on how terrible singletons are. Write a framework whose core way to deal with data passing is singletons. Angulra logic.
I think the more important part was that it had default DI
and thus a generation of developers learned how great DI is.
That doesn't actually do very good DI - how many people in Angular do you know that actually use the benefits of DI?
They just use the DI for glorified globals since the injector is global, they never .provider and always `.service.
anyone who's testing?
DI is not about testing.
well, mocking then
22:22
sez you
DI is very good for testing
DI is about configuration in how a module gets its dependencies - it's moving creation to outside the piece of code and making it possible to configure code.
which helps with testing.
So, for example, you can configure logging to work differently in different pieces of code - or can configure some parts of the code to pool DB connections and another to not.
You can configure different priorities in outbound http requests and propagate those dependencies with DI.
It's not just "to make testing easy", testing is super easy in JS anyway - it's a dynamic language you can swap out anything anyway. You can do testing just as easily with a service locator.
just is a very powerful word :)
DI is definitely extremely useful for testing, and it's useful for other things.
Really? Name one place you actually need that configurability in testing.
22:25
But I stand by what I said, people in Angular who are writing tests and mocking stuff using $provide are using the benefits of DI.
@BenjaminGruenbaum Dealing with Redis
I have a window.log and a window.db, what advantage does DI give me over window.db = new MockDB() before my tests run?
@SomeKittens no, that's just swapping the whole thing out globally. In JS you don't need DI for that. It doesn't even help that much
not having to deal with it after my test runs
DI has a nice mental model (every object created is explicit about what it needs) - but it's not about testing. Testing is like 20% of why it's useful.
I never said it was solely about testing though
22:26
@phenomnomnominal just have a beforeEach that sets the dependencies - that's as easy and no injector.
I think we agree that DI is useful for testing
We also agree that DI is useful for many other things
Testing doesn't actually exploit the usefulness of DI very much. It's useful there since you have to know what to swap out since dependencies are explicit - but that's an artifact of DI being useful - not its core value IMO.
So, you'd say that it's using the benefits of DI then?
7 mins ago, by Benjamin Gruenbaum
That doesn't actually do very good DI - how many people in Angular do you know that actually use the benefits of DI?
Angular 1 created the false impression testing is very related to DI. It also created the impression you need an injector.
@phenomnomnominal no, it's not - not in most tests I've seen.
Show me one test where it does a better job than swapping globals and I'll be satisfied.
22:32
Angular 1 also created codebases where a cyclomatic complexity of 30+ was acceptable.
grrrr....
better is subjective and you know it
I could just say that it's better because you're not explicitly swapping globals, and that could be good enough
It's better to know that DI is a thing, even if it is only using singletons that are configured once at boot up, than to just swap shit out on window.
I'm a big advocate of understanding the problem you're solving before attempting to solve it. I think there is a cultural and education problem with Angular 1 devs.
22:51
no kidding

« first day (5 days earlier)      last day (165 days later) »