JavaScript community

positive-intentions.com

https://positive-intentions.com/blog/qr-codes-as-a%20data-channel QR Codes as a Data Channel the demo in the blog article is a bit cluncky. here is a better link for it: https://chat.positive-intentions.com/#/qr

2
0
positive-intentions.com

Functional Web Components https://positive-intentions.com/blog/dim-todo-list Github: https://github.com/positive-intentions/dim Demo: https://dim.positive-intentions.com

2
0

https://positive-intentions.com/blog/dim-functional-webcomponents/ im investigating an idea i have about functional webcomponents after some experience with Lit. Lit is a nice lightweight UI framework, but i didnt like that it was using class-based components. Vue has a nice approach but i like working with the syntax that React used and i wondered if with webcomponents i could create a functional UI framework that didnt need to be transpiled. i think the article is already quite long, so i think i will create a separate one as a tutorial for it. note: im not trying to push "yet another ui framework", this is an investigation to see what is possible. this article is intended as educational.

3
0

cross-posted from: https://programming.dev/post/12974961 > I have a function as such: > > ```typescript > export type SendMessageParams = { > chatSession?: ChatSession, > // ... other params ... > }; > > const sendMessage = async ({ > chatSession, > // ... other params ... > }: SendMessageParams): Promise<void> => { > // await chatSession?.sendMessage() > // somewhere in implementation > }; > > export default sendMessage; > ``` > > [ChatSession](https://tsdocs.dev/docs/@google/generative-ai/0.7.1/classes/ChatSession.html) is from [`@google/generative-ai`](https://www.npmjs.com/package/@google/generative-ai). > > I'd like to mock it in my test file as such: > > ```typescript > let defaultParams: SendMessageParams; > > beforeEach(() => { > jest.mock('@google/generative-ai', () => ({ > ChatSession: { > sendMessage: async (content: string) => content, > }, > })); > defaultParams = { > chatSession: new ChatSession('', ''), > // ... other params ... > }; > }); > > afterEach(() => { > jest.clearAllMocks(); > }); > > it('should send message', async () => { > // await sendMessage(); > }); > ``` > > When I run `npm run test`, I get the error saying: > > ```plain > FAIL tests/logic/actions/sendMessage.test.ts > ● should send message > > ReferenceError: fetch is not defined > > 43 | const sendMessageInner = async (messages: Message[]) => { > 44 | setMessageListState(messages); > > 45 | const result = await chatSession?.sendMessage(content); > | ^ > 46 | const responseText = result?.response.text(); > 47 | if (responseText) { > 48 | const responseMessage: Message = { > > at makeRequest (node_modules/@google/generative-ai/dist/index.js:246:9) > at generateContent (node_modules/@google/generative-ai/dist/index.js:655:28) > at node_modules/@google/generative-ai/dist/index.js:890:25 > at ChatSession.sendMessage (node_modules/@google/generative-ai/dist/index.js:909:9) > at sendMessageInner (src/logic/actions/sendMessage.ts:45:20) > at src/logic/actions/sendMessage.ts:72:7 > at sendMessage (src/logic/actions/sendMessage.ts:59:3) > at Object.<anonymous> (tests/logic/actions/sendMessage.test.ts:44:3) > > ``` > > ...which hints that `chatSession.sendMessage` method still uses the real implementation instead of mock. > > I'd like to know why this happens and what the solution would be. > > Thanks in advance. > > *** > > # Environment > > - Node 20.11.0 (lts/iron) > - Jest 29.7.0 > - `@google/generative-ai` 0.5.0 (if relevant)

3
0

I'm a full-stack developer, looking for an internship at the moment. I feel like I'm really tired of React and Svelte. I am so done with how there's a lot of moving parts and complexity introduced by various tools, like ESLint, Prettier, TypeScript, and Tailwind. Can I work on a back-end application of my choice, while also having the freedom to not use a JavaScript runtime, in a professional environment? Can I also do modern JS stuff like tree-shaking, minification and code-splitting? How viable would be it to do so? And would it be easier to maintain?

2
2

Validation of javascript forms - name, password, password retype validation and Number Validation It is critical to check the user-submitted form since it may include incor- rect information. As a result, validation is required to authenticate the user. Because JavaScript allows form validation on the client side, data processing is faster than server-side validation.15 JavaScript form validation is preferred by the majority of web developers. We can validate name, password, email, date, cell numbers, and other data using JavaScript. [https://chat-to.dev/post?id=12](https://chat-to.dev/post?id=12) [#javascript](https://kbin.social/tag/javascript) [#web](https://kbin.social/tag/web) [#programmer](https://kbin.social/tag/programmer)

-4
1

ChatGPT used to have this, and there was a popular forum that had it (though I can't remember what it was/is), where, when you'd click a "delete" link, the confirmation was RIGHT THERE: "delete" faded out, "OK / Cancel" faded in. In the same space. It was really elegant and unobtrusive. Does anyone know if there's a library out there for it? I searched over github and google, but didn't find anything, probably because I couldn't get the search terms specific enough.

3
3

Hoping to get the ball rolling on this sub more. There’s too much action in the JavaScript scene for this community to only get a few post a month. I’ll start with a classic, [What the Heck is the Event Loop Anyway?](https://youtube.com/watch?v=8aGhZQkoFbQ&amp;feature=sharea)

2
0

Guys I need your help, where exactly the road map of Javascript Learning [@javascript](https://lemmy.ml/c/javascript)

1
2

I'm writing some javascript (for the web) for the first time in a long time and I am realizing that I would be well served by using a bit of tooling like eslint and standardjs. I am reluctantly willing to `apt install nodejs` but I am not willing to use `npm` because of my impression that it is a fractal of yolo `curl | bash` philosophy which will randomly install and automatically run malware or indistinguishable-from-malware garbage I don't want. So, my question is: how can I install things like [standardjs](https://standardjs.com/) without using npm? Please do not tell me that I should just use npm.

1
1
https://blog.coderspirit.xyz/blog/2022/12/08/animated-gosper-curve-in-ts/

An introductory article on how to leverage some basic mathematical tricks and widely available browser APIs to generate beautiful animations.

1
0
hacks.mozilla.org

cross-posted from: https://lemmy.ml/post/185607 > Some questions: > > - Would you pay to use MDN? > - Do you think MDN Plus is more like a Technical support service or a way to restrict content that used to be free? > - Do you think there are other ways Mozilla can monetize?

1
0
https://en.wikipedia.org/wiki/Structure_and_Interpretation_of_Computer_Programs,_JavaScript_Edition

cross-posted from: https://lemmy.ml/post/152366 > cross-posted from: https://lemmy.ml/post/152365 > > > > [The book (HTML)](https://sourceacademy.org/sicpjs/index) uses JavaScript sublanguages that we call [Source](https://docs.sourceacademy.org/). > > > > [playground](https://sourceacademy.org/playground)

1
0
deno.com

cross-posted from: https://lemmy.ml/post/85715 > One of the great advantages of Deno is the absence of a package manager, this section is practically monopolized by two corporations (MS with npm and FB with yarn); Deno has shown itself to be a more independent ecosystem with respect to its counterpart, Node. Do you think that this decision taken by the core team was the right one? would you have preferred it to become a foundation instead of a company? Will it become a more independent solution or will it end up like Node with OpenJS? being a front entity for a few big techs that lobby the ecosystem?

1
0