« first day (1600 days earlier)      last day (3350 days later) » 

9:00 PM
just in case you've figure out how requirejs handles paths, karma is here to break that again
 
@MLM what are you trying to do?
 
MLM
14 mins ago, by MLM
Anybody know of function that will see if an object only has certain keys verifyObjectShape(x, shape)? I made a function that handles non-nested objects and before I refactor for nested recursiveness, I was wondering if this was already in a nice package.
Verify a JSON API response in tests to make sure I am not leaking/exposing any unecessary data
 
what is x supposed to be?
 
MLM
@Shmiddty Another JS object that we want to verify: var x = { a: 1 };
 
You're not using a class pattern?
 
MLM
9:06 PM
@Shmiddty explain further, not quite sure what you mean by that? x would be an API response that is JSON.parsed in?
 
Perhaps your naming conventions are causing the confusion. What is an "ObjectShape" supposed to be?
 
MLM
JS object on which to verify with: var shape = { a: undefined }
 
@RLEMON SHE DONE GON BEEN DELIVERED
 
So, you basically want to see if an object has a specific set of keys?
 
MLM
@Shmiddty Correct
 
9:08 PM
just got the txt
 
And you're using lodash?
 
function lookup(needle, objHaystack) {
  if( needle in objHaystack ) return objHaystack[needle];
  for( var key in objHaystack ) {
    if( needle in objHaystack[key] ) return objHaystack[key][needle];
    return lookup(needle, objHaystack[key]);
  }
  return undefined;
}
@SterlingArcher nice
 
@SterlingArcher Baby?
 
MLM
@Shmiddty No, taco suggested a method in lodash might've taken care of it.
 
@Shmiddty vape pen :D
 
9:09 PM
not a pen
regulated mod
personal vaporizer
 
@SterlingArcher Oh ok. I just assumed everyone was having babies and weddings up in here
I think @Zirak's wife is pregnant with twins, right?
 
@Shmiddty I AM NOT!
@SterlingArcher how many hours till you will be home?
 
function strictPropertyCompare(obj, props){
    var keys = Object.keys(obj);
    return keys.length === props.length && keys.filter(x => props.contains(x)).length === props.length;
}
I think that would do it
Might be able to simplify further
 
MLM
@Shmiddty Thanks, making tests
 
@Shmiddty filter(it => x.contains(it)) is going to iterate over both arrays a lot
 
9:17 PM
function strictPropertyCompare(obj, props){
var keys = Object.keys(obj);
return keys.length - keys.filter(x => props.contains(x)).length === 0;
}
@ssube I know
 
there's probably way to optimize that, likely by sorting first
sort each array, then compare x[i] === y[i] until they mismatch?
 
premature optimization. ;)
 
If you're hitting each property more than once, you're doing something wrong
Or I'm misunderstanding what you're trying to do
 
function compareKeys(a, b) {
  var aK = Object.keys(a).sort(), bK = b.sort();
  if (aK.length !== bK.length) return false;
  for (var i = 0; i < aK.length; ++i) {
    if (aK[i] !== bK[i]) return false;
  }
  return true;
}
 
function strictPropertyCompare(obj, props){
    var keys = Object.keys(obj);
    return keys.length === props.length && props.filter(x => obj.hasOwnProperty(x)).length === props.length;
}
 
9:19 PM
does that have the behavior you're looking for?
 
Does Object.keys return a sorted list?
!!> Object.keys({z: 0, a:1, f:2, b:3})
 
@Shmiddty ["z","a","f","b"]
 
looks undefined
 
> The Object.keys() method returns an array of a given object's own enumerable properties, in the same order as that provided by a for...in loop (the difference being that a for-in loop enumerates properties in the prototype chain as well).
Though...
> The for..in statement iterates over the enumerable properties of an object, in arbitrary order. For each distinct property, statements can be executed.
So, yes. It's defined to be arbitrary.
(Both above from MDN)
 
@Retsam It's probably hinting that the internal implementation uses a for..in
 
9:24 PM
@Shmiddty I should hope not, that would be incredibly slow.
Most VMs should have that information cached anyway
 
Okie dokie
 
MLM
@Shmiddty @ssube Both fail with nested properties: jsfiddle.net/MadLittleMods/qjrjzr1b/3
 
Just add a recursive check
 
MLM
kk
 
:(
 
9:34 PM
best comment on stackoverflow:
i am from future and dart still doesn't run in chrome as is. — Muhammad Umer Jul 30 '14 at 19:26
 
@MLM The method I wrote expects an array for the second param
@Meredith can't ping and format. We prefer formatted code. The ping isn't really necessary
 
yowsa
 
@rlemon I wont leave work for like another hour 20 and then another hour 12 to get home?
 
@SterlingArcher so two and a half hours
 
MLM
9:40 PM
@Meredith Thanks, fails both tests: jsfiddle.net/MadLittleMods/qjrjzr1b/4
(I am working on them)
 
about that yes
I'm usually home a little before 8
 
wow thats a long commute
 
@SterlingArcher what time (local) do you leave work?
6?
 
ouch
 
9:41 PM
give or take 10-20 minutes
 
@MLM Your test says it should return false and it does
Am I missing something?
 
MLM
@Meredith The first simple test (it should be true)
 
> should be false because missing x.nested.cool
 
@MLM I made a thing. probably not helpful for you, but I made a thing. jsfiddle.net/s984bfs8
 
9:43 PM
it is
mind you mine is much less robust than yours
 
MLM
@Meredith The first test should be true, it compares var shape = { usename: undefined }; var x = { usename: 'eric' };
 
mine is also like 5 lines of cod e:P
 
meh, mine is super simple
there are a million little variations you can do, though
single string with dots vs rest param
 
@ssube I wanna be able to do k(obj, 'foo.bar')
 
9:48 PM
@FlorianMargaine that and abstract infix are on my todo list, but out of curiosity, why do you want k(obj, "foo.bar") instead of k(obj, "foo", "bar")?
 
shorter
and more dot notation like
 
how would you expect k(obj, 'foo.bar.baz') to operate if bar was a method taking a parameter or two?
 
how do you handle a method call right now?
 
k(obj, 'foo', ['bar', arg1, arg2], 'baz')
it's not pretty, but it's pretty unambiguous (I believe)
 
k(obj, 'foo', ['bar'], 'baz.buz')
keep this syntax
just support the dot notation for prop accesses
k(obj, 'foo.bar', ['baz'])
for obj.foo.bar('baz')
 
9:51 PM
having an overload for k(obj: object, props: string) works, but having k(obj: object, ...props: string|array) and splitting each on dots does not
what if a property is actually named "baz.buz"?
 
.. I didn't even consider that
 
@ssube then fuck that guy who wrote that
 
@ssube you could make it a constructor option to support this case. a 0.1% case.
 
0.00001
 
constructor option saying "disable this in case you have properties like this, asshole"
 
9:53 PM
I think I've only ever seen it in localization files generated by some backend that used . as a separator
could also say foo.bar gets split but foo\\.bar doesn't
 
for some reason, it makes me think of eval('foo.' + bar) for people who don't know the bracket notation...
 
!!> var foo = { "\\.bar" : 1 }; foo["\\.bar"]
 
@rlemon 1
 
<3 JS
 
yeah, I don't think there's any case that always works
I can't even safely overload get(base, ...steps) to check if steps.length === 1 && typeof steps[0] === "string" && steps[0].indexOf('.') > -1, cause it very well could be 'foo.bar' as the first property name
 
9:58 PM
-3
Q: Turn int 12345 into float 1.2345 in Javascript

Brian NoahI want to turn 12345 into 1.2345 This with different numbers. Here is what I've done so far, and it works, it's just not very pretty, and seems like a hack. var number = 12345 > 12345 var numLength = number.toString().length > 5 var str = number +'e-' + (numLength - 1) > "12345e-4" var float =...

 
Seriously
 
fo sho
 
0
A: Turn int 12345 into float 1.2345 in Javascript

Billy MonksYou should just be able to divide by 10000. No need for a string conversion. > var number = 12345; > var result = number / 10000; > $(result) [1.2345]

$(result) THE FUCK?!
 
user1596138
-2
Q: Is it possible to follow/stop follow the company using javascript?

Sergey TerekhovI am trying to make a line of javascript that i can type into chrome web browser to "follow" businesses inside of my linkedin account. Would it be possible for there to be a delay of 5 minutes between each follow?? HOW TO FOLLOW A COMPANY ON LINKEDIN https://help.linkedin.com/app/answers/detail...

 
crl
!!> var f=function(x){return x/Math.pow(10,Math.floor(Math.log10(x)))}; f(12345)
 
user1596138
10:04 PM
I wonder why
 
@crl "undefined"
@crl "undefined" Logged: "undefined"
 
$($(number).divide($(10000)))
 
._.
 
@ssube I think we submitted those almost at the exact same time
 
@rlemon damn near
 
10:05 PM
2 seconds :P
 
@crl 1.2345
 
you linked that answer and I went to comment pretty quick
 
@rlemon doesn't hurt that the answer was incomplete anyway, apparently
but srsly, the OP didn't ask for an array, why jQ?
 
10:07 PM
yea OP stated that 10000 wouldn't work already. so I -1 him
the $() is just WTF
anyways,
!!afk HOLM THYME
 
same bros
 
crl
@Meredith lol you really want rep stackoverflow.com/a/28866004/3183756
 
I havent posted an answer in like
6 months
it was time
 
crl
it would have been better if it was your answer though
 
what
 
crl
10:11 PM
nvm
 
@Meredith add a brief explanation pls :D
 
Is it not obvious
Like am i supposed to explain what log10 does
 
It's just to avoid looking like a code dump answer (not saying it's wrong or bad)
I'm personally a stickler for, "If it was obvious, OP wouldn't have asked"
 
It's also quite derivative
 
@rlemon lol
 
10:14 PM
@BenjaminGruenbaum rlemon is afk: HOLM THYME
 
crl
!!> var x="12345".match(/^(\d)(\d+)$/); x[1]+'.'+x [2]
 
@crl "1.2345"
 
MLM
@ssube Updated your snippet to support nested structures. (most clear/straight forward to me): jsfiddle.net/MadLittleMods/qjrjzr1b/8
 
@copy Idk how you give an answer to that question that isn't derivative
 
MLM
@Shmiddty @Meredith Thank you for the help and different implementations, I'll try to get them fully recursive working as well.
 
10:17 PM
You only give an answer if there is no correct answer yet or your answer contributes something additional
 
There wasnt a correct answer
So ???
 
Paul's answer isn't correct?
 
It wasn't when I posted
 
ok
 
crl
!!> var f=function(x){var r = x.match(/^(-?\d)(\d+)(.\d+)?$/); return r[1]+'.'+r[2]+(r[3]?r[3].slice(1):'')+'e'+r[2].length}; f('-12345.678')
 
10:23 PM
@crl "-1.2345678e4"
 
how to sort filtered data?
using angular
 
@BenjaminGruenbaum mobile is tits so I have no idea what your lol was in response too. But now I'm curious.
 
10:41 PM
@rlemon jake
weary
 
Ahhhh
 
I want one :D
 
I want 10!
 
^ if you want to laugh
 
I survive design meetings that should have been instant messages
 
10:45 PM
@SomeKittens why :(?
 
@BenjaminGruenbaum I'll let you come to your own conclusions.
 
Awww I missed it and I can't see deleted content on mobile.
 
@rlemon it's your mannips pic
That one:
!!mannips
 
Thanks for the effort kittens. But I don't angular so the joke is lost on me.
@BenjaminGruenbaum sounds like someone is jelly.. Or turned on. Could go either way.
 
10:53 PM
@rlemon its jquery :P
 
@rlemon Why not both?
 
I didn't know the mannips picture. Saved in fap material folder.
2
 
Now that I'm engaged to @Zirak I suddenly feel the urge for some lemon juice.
 
oh yeah
@SterlingArcher if @rlemon marries a Jewish woman and they have kids they'll be Lemon Jews :D
 
10:58 PM
omg lmao
thats so bad lol
 

« first day (1600 days earlier)      last day (3350 days later) »