« first day (3258 days earlier)      last day (1680 days later) » 
00:00 - 18:0018:00 - 00:00

user11867329
12:57 AM
nO as I mentioned, first time. I'm certain I can push em from home
 
user11867329
through a thing
 
user11867329
right in front of a bus stop
 
HAMMERTIME!
 
user11867329
lawn so it doesnt touche sidewalk
 
user11867329
HHHhaMMmmMmeeEEeTiiiMmmeee
 
user11867329
12:58 AM
Wait
 
user11867329
What hammer
 
user11867329
not the "B" one?
 
user11867329
2:34 AM
why removed lol
 
user11867329
was funny
 
import numeral from 'numeral'

export const moneyFormat(money){
    return numeral(money).format('0,0.00')
}
aw
it has error in that command
Parsing error: Unexpected Token
 
2:50 AM
@KarelG Actually I'm on step 2.
 
 
2 hours later…
4:33 AM
hi
anyone here tongith
 
what up
 
@sammy Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
christian still there?
some absolute units in this room with the big point scores
 
5:11 AM
Does anyone know how can i achive this type page smooth scroll in a vuejs website using of Tweenmax?
greeeg.com

Thanks for advance
 
@RaydoanAnik Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
 
1 hour later…
6:27 AM
I am confusion...
 
@geisterfurz007 Don't be confusion, friend
 
I got a test where react-native-fs is loaded as a mock from jest with all functions of the library being replaced by jest.fn()
In my test, I can use console.log(jest.isMockFunction(RNFS.readFile)) to make sure it is a mock function indeed and it is.
However in the function that I am testing, I can put the same line of code and it will print false.
 
well yeah, the idea is that you don't actually perform FS operations
 
How comes?
 
they all return false or just some?
 
6:30 AM
Gimme a second
A screenshot is better in explaining because I am poor in that.
On the left side is my test and on the right side the code that I am testing
 
My proxy filters some images sometimes :(
 
(I don't have that console.log in there when not testing; but currently I am trying to find the root of a TypeError that RNFS.readFile is not a function when testing)
 
depends entirely on how you configured the mock
you can make them all be a stub method which does nothing, or you can make some actually return specific things
 
4 hours ago, by AppleCiderYummy
import numeral from 'numeral'

export const moneyFormat(money){
    return numeral(money).format('0,0.00')
}
4 hours ago, by AppleCiderYummy
Parsing error: Unexpected Token
 
so you've made 0 progress in the last 4 hours?
 
6:34 AM
@AppleCiderYummy I'm guessing bad format. check that that is valid syntax
@towc nobody on the chat, you see ;)
 
for starters, it's not nice to ask again like that
secondly, that's not the whole error message
give us the whole error message, and inspect it carefully yourself
 
paste.ofcode.org/BYGqPNTrseisR5ZxBZheu9 Maybe this works better than the screenshot :D
 
@AppleCiderYummy and don't keep me waiting
if you want help
 
@geisterfurz007 oh, that is interesting
 
I find it rather frustrating :D
 
6:38 AM
You've got a problem with the order of operations would be my guess
 
@Neil I tried the upper M in the MoneyFormat but it still shows the error
 
when the test is run, it is mocked, and when _getImageHexString is called, it isn't
 
Oh!
Oh, good sir, that might have given me the hint I just needed
 
if you, say, called _getImageHexString in the test, it would also return _ true
@AppleCiderYummy moneyFormat is the name of your function
that has nothing to do with the actual error
at least I don't think it is
 
Hm, nej. I thought it was because I dereferenced the function.
 
6:41 AM
well try to rule out order of operations. If you call _getImageHexString, what does it return then?
 
test('calls correct functions', async () => {
  // const method = (Sender as any)._getImageHexString;
  const base64Spy = jest.spyOn(Sender as any, '_base64ToHex');

  console.log(jest.isMockFunction(RNFS.readFile)); //true

  (RNFS.readFile as jest.Mock<
    Promise<string>,
    [string, string]
  >).mockImplementation(async () => {
    return 'asdf';
  });

  await (Sender as any)._getImageHexString('imagePath');

  expect(RNFS.readFile).toBeCalledWith(['imagePath', 'base64']);
  expect(base64Spy).toBeCalled();
 
you'll learn something valuable either way
 
That is my entire test; currently it throws a TypeError: _reactNativeFs.default.readFile is not a function
 
oh so you do call it in the test
 
6:44 AM
if you reverse the _getImageHexString line with the console.log(jest.isMockFunction...) line?
there is a point to that, I assure you
 
So put the console.log in the test below the await (Sender as any) one?
 
maybe it is only the mock function for the first call
yes
 
Hm, njet. Still _ false and still the TypeError
 
this solves my problem
I think
import numeral from 'numeral'

export function MoneyFormat(money) {
    return numeral(money).format('0,0.00')
}
 
@geisterfurz007 so it prints out _ false followed by true now rather than true followed by _ false?
 
6:47 AM
No, because the test fails immediately with the TypeError, there is on true. But when wrapping with a try and having the console.log of the test in the respective catch clause, then it does indeed print true after the false
 
that is definitely not behavior kin to what I'm used to
but then I don't know how jest works
 
I bet it is something super stupid again on my end that I am missing and wasting your time with :c
 
could be related to the fact that it is an async function
even if you're awaiting it
 
async stuff works perfectly fine in every other test of mine and all mocks work as well as far as I am concerned
Out of curiosity: What testing framework do you use?
 
I don't program in javascript :)
 
6:52 AM
:o
 
"JUnit" would be the right answer here I suppose
 
Oh, ok :D
Ok, so you got no clue either why that test is kinda broken, right? Guess I will comment that testcase out then for now...
It really makes no sense to me
 
@KevinB wha! Had to cringe 😬
 
7:11 AM
That was absolutely horrible to read
I love how happy he is that he can put functions into a variable tho :)
I also disagree massively with the premise "Learning something new is a waste of time".
 
7:40 AM
Oh, @Neil You were correct! I just found this and it says "Before instantiating a module, all of the modules it requested must be available" which I didn't do! When moving the RNFS import further up above the one of Sender which I am testing, I get _ true and false. Thanks for the hint!
 
@geisterfurz007 no sweat :)
yeah probably because the whole "mocking" thing is just done once on all available modules
 
Funny enough; now it is not a mockFunction in my test anymore but I think I can get through that
 
@Cerbrus lol that edit should not have occurred. Damn robots
 
Oh, now it works without having the RNFS import further above. The mock was just plain wrong it looks like O-o
And test's green \o/
 
8:39 AM
Wooooo, fixed the last test that was behaving weirdly as well.
WOOOOOOOOOOOOOOOOOOOO
 
nice
 
 
2 hours later…
10:49 AM
Hello everyone, does anyone know any library to transform JSON schema into angular 8 forms? I found one but it's a deprecated - last commit was ~2 yr ago and it's was created for Angular 2.
 
@chebad Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
@chebad IIRC angular has a built-in form builder that accepts a simple object
but for a lib that does convert a json to a form? No. Also that is an odd idea. Or solution to a problem.
 
@KarelG Thank you for answering, the solution which I'm pointing in previous message is here: https://angular2-json-schema-form.firebaseapp.com/
You can simply look at it and this project create nice form from json schema.

I don't want to convert JSON object to form, but a JSON Schema.
 
 
1 hour later…
12:20 PM
Hello everyone, have a nice day!
 
@RobsonBraga Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
Hi Robson
 
I HAVE NEVER SEEN THAT WOMAN IN MY LIFE!
 
To shreds, you say..
 
pitter patter
 
12:39 PM
hey @rlemon can you help me with something
I have 2 objects
 
Sep 12 at 16:36, by Cerbrus
Right. @TaylorSpark, don't ping random people. If someone sees your question and wants to help, they will.
this applies to everyone
 
[ { id: 1, question: 'Where do we get off ' },
  { id: 1, question: 'How do I get off the ship' },
  { id: 1,
    question: 'Where do I lkeave' },
  { id: 1, question: 'How do I get going' },
  { id: 1, question: 'Where do I go to get off' },
sorry you're just the best one. all LOVE here man
corresponding is an object that has an id and an answer to the question
like such
{ id: 1,
  answer:
   'you get off like this and over here at this point' }
i need to map that answer per id to each and every question
 
but all your ids are the same...
 
there are 300 id's
but there can be multiple quesitons per id
 
all of them 1
 
12:47 PM
if that makes sense.
and only 1 answer
 
you need to cycle through all your questions, and group them by id
 
[ { id: 1, question: 'Where do we get off ' },
{ id: 1, question: 'How do I get off the ship', answer: 'you get off like this and over here at this point'},
{ id: 1,
question: 'Where do I lkeave', answer: 'you get off like this and over here at this point' },
{ id: 1, question: 'How do I get going', answer: 'you get off like this and over here at this point' },
{ id: 1, question: 'Where do I go to get off', answer: 'you get off like this and over here at this point' },
 
then go through your answers one at a time and associate each id with the group of questions
just a matter of reorganizing your data
 
Why is it considered better the use of spread syntax?
For example:
arr1 = [...arr1, ...arr2]; instead of arr1 = arr1.concat(arr2);
 
i got the data to this point but this is my last hiccup
 
12:50 PM
@SilverSurfer who said it was better?
 
It says "A better way to concatenate arrays"
 
not better per se, just useful
 
it can be better in certain situations.
but you can deal with those as they come up
 
I don't think it's more performant than concat
 
for now use whatever makes more sense
 
12:52 PM
@ChristianMatthew try to think a bit: go through the array, for each object: check its id and assign it to a group that only has that id. So there is a datastructure for that: a map. Use a map for that where the key is the id and the value is an array of those object
 
ideally, send the data you can use without reorganization client-side
ids are only useful to the extent that they let you associate the data
unless you intend on being able to modify the data
 
consult Map - MDN for that. The other things (going through that array and adding it to the map) are basic things that a developer should be capable to do at its own.
 
@KarelG ok let me get something going i am bad with maps
 
I dont undertand how to take advantage of that syntax, when to use it
 
big M or little m
 
12:54 PM
little m
oops sorry, I think we're talking about array.map
 
@SilverSurfer the info in mdn is misleading (and horrifying)
 
in the short term I'd probably just reduce the data back down to an object that contains the id's an array of questions and an answer
 
the author probably meant that it appears nice and "modern" javascript but that is subjective
 
so reduce
 
just stick with .concat if you want to ... concatenate arrays. It is also more meaningful if you want to concatenate more than two arrays
 
12:57 PM
but don't I have to merge them together frist?
 
And for example, this accepted answer, why use a spread syntax? Whats the meaning of that auxiliary function?
https://stackoverflow.com/questions/1044105/how-do-you-get-the-length-of-a-string
 
!!> [{id: 1, question: '1', answer: '1'},{id: 1, question: '1.2', answer: '1'},{id: 2, question: '2', answer: '2'},].reduce((a,b) => (( b.id in a ) || ( a[b.id] = { questions: [] } ), a[b.id].questions.push(b.question), a[b.id].answer = b.answer, a) , {});
 
@rlemon {"1":{"questions":["1","1.2"],"answer":"1"},"2":{"questions":["2"],"answer":"2"}}
 
you can figure out that monstrosity
I answer no more questions about it
😀
@SilverSurfer because they needed to get an array out of the string
 
@SilverSurfer the problem with unicode is that they are sometimes not giving the right length if you use the native String.prototype.length function
 
1:06 PM
wait but that id and the answer aren't together
that's tghe problem
 
we see ð ®· as one character but .length gives it two (2 bytes)
!!> 'ð ®·'.length
 
@KarelG 2
 
sorry the question and the answer are not together
 
it's still the same solution. just add in another check.
 
so in order to "overcome" it, [..."ð ®·"].length is used as a trick
 
even hackers makes mistakes that hackers like to abuse.
 
the answer has to read as such
[ { id: 1, question: 'Where do we get off ' },
{ id: 1, question: 'How do I get off the ship', answer: 'you get off like this and over here at this point'},
{ id: 1,
question: 'Where do I lkeave', answer: 'you get off like this and over here at this point' },
{ id: 1, question: 'How do I get going', answer: 'you get off like this and over here at this point' },
{ id: 1, question: 'Where do I go to get off', answer: 'you get off like this and over here at this point' },
each object must have question and an answer
 
massively inefficient
 
its for an excel file
 
and?
 
1:13 PM
well that is how the excel file wants it
or when loaded it errors
 
that's how the macro someone wrote wants it?
 
tell them to fix it
so you don't have to pass them stupid data
 
its microsoft
lol
don't think that will happen anytime soon
but you do make a fair point it is stupid
 
is the macro really written by MS? Custom macro's exists.
 
1:15 PM
this is how they want the excel file
@KarelG would map make this work
 
the data structure doesn't matter.
you have to write the logic
which isn't that hard.
give it a shot
 
let me see if I can successfully do one
and then go from there
 
that comment gives an impression that you did not even try it.
 
try what
i have tried a lot lol
i have been between reduce and map
to get the data to this point has been hell
        let blue = JSON.stringify(answerArray)
        // console.log(blue);

        function union(setA, setB) {
            var _union = new Set(setA);
            for (var elem of setB) {
                _union.add(elem);
            }
            return _union;
        }

        var setA = new Set(questionArray),
            setB = new Set(altQuestionsArray);

        var combineTypesToArray = ((setOriginal, setNew) => {
            union(setOriginal, setNew).forEach((value) => combinedQuestionAltquestionArray.push(value));
 
okay, loop the entire thing and break the questions and answers out to two arrays.
once you have an array of questions an answers, loop the array of questions
with each question find the answer from the answer array and add it
bingo bango we have it working (albeit quite ugly)
 
1:23 PM
i have done the first part
 
now draw the rest of the f*cking owl
and when you've done that I'll show you the solution I just slapped down
 
1:53 PM
im doing something so wrong
 
show us your wrongness then
 
2:10 PM
Didn't I hear they are putting JavaScript in excel
 
 // var answerObj = {};
        // var testArray = [];
        // for ( let i in uniqueArray) {

        //     answerObj[i] = answerArray[i];
        //     //console.log(uniqueArray);
        // }

        // console.log(answerObj);

        // for (i in answerObj) {
        //     testArray.push(answerObj[i]);
        // }

        // console.log(testArray);
i am just trying to align the 2 objects together and fill in the answer to the question
questions
i guess i am just starting wrong
 
that code doesn't attempt to do anything that I suggested 😛
 
2:50 PM
@All Hi
 
aww, Christain left
I guess I should post the solution now
 
Im trying to get a value from an array and push it to an array object using es6.
 
const [questions, answers] = array.reduce(
  (r, i) => {
    if ("question" in i) r[0].push(i);
    else r[1].push(i);

    return r;
  },
  [[], []]
);

questions.forEach(question => {
  const { answer } = answers.find(answer => answer.id === question.id);
  question.answer = answer;
});
😛
 
1 message moved to Trash can
@SamSam Please don't post unformatted code - hit Ctrl+K before sending, use up-arrow to edit messages, and see the faq. For posting large code blocks, use a paste site like gist.github.com, hastebin.com, pastie.org or a demo site like jsbin.com
 
"myObj": [
		{
			"formId": "test",
			"Desc": ""
		},
		{
			"formId": "test2",
			Desc
		}
]
@CapricaSix yup, already did that.
im trying to get the formId value and push it to some array like below

var newArray = ['test','test2']
 
2:55 PM
const newArray = array.map(({formId})=>formId);
 
@rlemon - yes thanks, did that.
   var myObj= firstArray.map((currentValue, index) =>{
                return currentValue;
        });
 
that's not what I showed you
look again
 
@rlemon im acheiving the same thing with that code, does it have any performance issues?
 
it's not the same thing
my example uses argument destructuring to pull out the formId value. yours literally does nothing
 
why are you calling an array an object
 
3:08 PM
 var myObj= firstArray.map((currentValue, index) =>{
                return currentValue.formId;
        });
 
there we go
however if you're using arrow functions. it's safe to assume you can use destructuring and stop using var
I'd look into those
 
everything is an object in js
right
 
@rlemon great, thanks for the info.
just one more thing, if i have an array as below
 
@ChristianMatthew kinda
 
"myObj": [
		{
			"formId": "test",
			"Desc": "",
			"config":""
		},
		{
			"formId": "test2",
			Desc: "",
			"config":""
		}
]
 
3:14 PM
everything tries to inherit from Object, but not everything does
 
im trying to return two properties (formId, config) to the new array
 
const newArray = array.map(({formId,config}) => { formId, config });
this isn't that different than the first example
 
yes, i had tried exactly that
 
and?
 
but i get error as
"left side comma operator is unused and has no side effect"
 
3:17 PM
so did you see where that error comes from?
 
@ChristianMatthew no
 
you (appears to) understand arrow functions
 
yes, it highlights on formId
 
I made a mistake. figure it out
 
3:19 PM
@rlemon, ok thanks for the help.
:47327050 const newArray = array.map(({formId,config}) => [ formId, config ]);
@rlemon
converting it to array?
 
no, why would you do that?
a => {
  b;
}
do you see what this does?
what is the difference between that and a => b
and why would a => { b } be a mistake
 
3:37 PM
@BenjaminGruenbaum huh
 
3:49 PM
@BenjaminGruenbaum oh lol got ya
ok this is my issue.
i have 2 arrays of objects
 
is this the same problem as before?
 
they each of a similiar id pattern. i just want to map the ids of the objects together and merge or flatten that object down
yes
 
I've already given you the answer
go read it
 
this
[{id: 1, question: '1', answer: '1'},{id: 1, question: '1.2', answer: '1'},{id: 2, question: '2', answer: '2'},].reduce((a,b) => (( b.id in a ) || ( a[b.id] = { questions: [] } ), a[b.id].questions.push(b.question), a[b.id].answer = b.answer, a) , {});
 
no
I described what you wanted, then told you to go write that based on my description. you posted some random code that didn't attempt to do that. then you left for a bit so I cleared out my clipboard and posted a solution above.
please when asking questions, go back and look at the history to see if someone answered it
 
3:55 PM
do you prefer reduce over map?
 
they do different things
there is no "prefer"
 
i have an array of objects, each object contains an array of file information. i want to download each file, run a process on the file, delete the file and then move on to the next file... how best to do that? which loop should i use?
 
Recursive function
 
Recursive function
 
for async
 
4:08 PM
You mean for await
 
oh, right
 
@rlemon Haven't touched it in a few days, and ignore that the content is mismatched, but I made some tweaks to the overall design cdn.discordapp.com/attachments/239722511741222912/…
 
hello
 
user6568562
4:24 PM
Hi Everybody; I've been learning Python for quite some time and just added JS to the mix; I book-hopped before landing on Eloquent JS If anyone has suggestions on resources, materials, blogs, I can check, I will happily accept ; )
 
@randomhopeful Welcome to the JavaScript chat! Please review the room rules. If you have a question, just post it, and if anyone's free and interested they'll help. If you want to report an abusive user or a problem in this room, visit our meta.
 
user6568562
@CapricaSix Copy that
 
@randomhopeful thats our bot. I enjoyed JavaScript Ninja, but I think that might be out of date
it's been awhile
 
user6568562
@StephanS Oh I see, thanks for the tip, lol; I'll check that book out, thank you;
 
you can see how it works
!!sandbox
 
4:32 PM
@StephanS Please go and play in the Sandbox
 
user6568562
I will ; )
 
I'm not trying to make this into the trashbin but law.stackexchange.com/questions/44738/…
 
the fire department is a social program, not a legislative power
it would be like asking if your child's (public) middle school is a legislative power
 
It's all the CIA
 
user6568562
His disproportionate response to your comment is sort of hilarious in a sad way; This website isn't appropriate for your question; MODS ARE BIASED AND 9/11 WAS AN INSIDE JOB !
 
4:47 PM
yeah... you can't just start out a comment thread with 9/11 was an inside job, you kinda have to work into that topic
 
7/11 was a part time job
 
lol
7/11 and 9/11 mmmhm
7+11=18, and 9+11=20, and 9-7=2, and 2+18=20
 
@ndugger I don't know how to feel about non-french putting accents on resume
as in visual noise
 
Well I don't want to confuse it with the word resume, like to continue
 
if most other words had random ticks sprawling up from the letters, then great. If not, you think there's something wrong with your screen for a split second
 
4:51 PM
I love how towc is like nope, not touching that topic.
 
5:32 PM
i keep getting this error
SyntaxError: Identifier 'answerArray' has already been declared
 
are you using const and trying to redeclare it?
let might throw too, if you're redeclaring instead of redefining
not sure
But showing us code might help
 
5:47 PM
const [questions, answerArray] = uniqueArray.reduce(
            (r, i) => {
            if ("question" in i) r[0].push(i);
            else r[1].push(i);
            // console.log(r);
            return r;
            },
            [[], []]
        );

        questions.forEach(question => {
            const { answer } = answerArray.find(answer => answer.id === question.id);
            question.answer = answer;
        });
 
the error message states the identifier has already been used.
so you used it already
change the name
also, write the code in a sensible way. don't just copy paste code and expect it to work in your codebase
they're meant to be isolated examples
 
im not getting this part
const { answer }
 
it's the same as const [ questions, answerArray ] but with objects
 
00:00 - 18:0018:00 - 00:00

« first day (3258 days earlier)      last day (1680 days later) »