Questions tagged [javascript]

JavaScript is primarily a language focused on web development. Being a monopoly on the front end and having Node on the back end. Use this tag for questions regarding vanilla JavaScript; optionally tagged with an ECMAScript version. If you are using a preprocessor such as TypeScript please tag with that too.

1,198 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
8
votes
2answers
119 views

Return probability (Javascript)

I've been working on a personal project. There's this game called TFT which is an autochess game. Each match is played by 8 players and there's a shared pool of champions. Each champion has their cost ...
7
votes
0answers
85 views

Resizable containers with VueJS

I reviewed the code in Resizable split DIVs Vue.js, suggesting that the OP use computed properties and bound styles to simplify the code (at least reducing the need to use ...
7
votes
0answers
127 views

Nested cross-origin iframes for secure user-configurable javascript tools

Context I'm trying to build a system in which a tool (the Client) will generate a header to be used as part of an HTTP request from the user's browser. The user should be able to choose their own ...
6
votes
0answers
114 views

Node.JS Protobuf socket client with TLS support

I'm working with one environment which allows me to execute node.js code from single file without installing additional modules. My task is to write simple ssl socket client which will send protobuf ...
5
votes
0answers
223 views

React Context & Hooks custom Vuex like store

I've been experimenting with Hooks lately and looking more into how can I replace Redux with useContext and useReduer. For me, ...
5
votes
1answer
58 views

User-focused timeline logging

I'm working on a small piece of my personal website. I'd like a timeline logging all of my relevant achievements in my career in Computer Science, in general. I'd like to implement a feature that ...
5
votes
0answers
69 views

Resolving Git conflicts with Javascript

Challenge: Resolve git conflict by resolveGitConflict(linesArray, resolveMode), where linesArray is an array of strings Example: ...
5
votes
0answers
73 views

JS deep merging of objects- removing empty keys

I've written a helper for combining objects (deep merge). It works, and is flexible to add options (like uniq and replace). ...
5
votes
1answer
249 views

Sierpinski triangle html canvas Implementation

I wrote my Sierpinski Triangle fractal animation using HTML canvas with JavaScript: JsFiddle Code: ...
5
votes
0answers
202 views

Spacial hashing Library

Old code ...
5
votes
0answers
382 views

Object-oriented fractal tree

I made an object oriented fractal tree in javascript using the p5 library, it consists of three files: Fraternal Tree.js branch.js flower.js Here is the github repo with the source code. All the ...
5
votes
0answers
157 views

Assembling and traversing a graph, given a list of items and parent pointers

I've written a function which takes input such as this: ...
5
votes
0answers
154 views

2d game enemy entities factories, probably in need of refactoring

So I'm making a 2d shoot'em up game as a way of learning canvas, and larger-scale programming than what I'm accustomed to. I'm a purely front-end web dev, I can't say I'm very experienced in this. ...
5
votes
0answers
76 views

Using components instead controllers in EmberJS v2

I am beginner in EmberJS. I have made todomvc for ember v2 for learning Ember. My implementation works without controller. I use components instead controllers. In the documentation I see: ...
5
votes
0answers
1k views

Mocking the file system within a test

I've been using this method to test file-system functions as an alternative to mock-fs due to its lack of symlink support. I'd love to hear what others think and ...
5
votes
0answers
750 views

Exiting a Promise early

I'm using a Promise chain to write some data to a file, execute a command on it, inspect its results, and send the results, using Express.js. The thing about my function is that I need to be able to ...
4
votes
0answers
38 views

JS Stopwatch - Is this a good way to implement the observer pattern?

I'm learning oop and also trying to learn and implement some design patterns. This question is a follow up of Stopwatch interface OOP (Vanilla JS) The app is available in https://nacho-p5.github.io/ ...
4
votes
0answers
57 views

Created a paperfold like effect

I am trying to recreate a neat effect that I saw posted on Stack Overflow as a GIF . I am trying to recreate this with CSS and JavaScript and I have created a similar effect with a button press. I ...
4
votes
0answers
33 views

TypeScript simple localStorage cache

I have a simple localStorage cache class written in TypeScript, would love to have some insights on any way/aspect you think it can be improved (making it more readable, maintainable, usable, etc.): <...
4
votes
0answers
32 views

Monitoring a view model for changes to display a save button

I'm working with Knockout3 in a Chromium 28 environment (ES5). I have a series of preset difficulty options, and a player has an option to switch to custom difficulty and tweak the options. When they ...
4
votes
1answer
30 views

Changing the environment if it sees the incorrect environment in the setting

I am using the function below to change the environment. If it sees the wrong environment values, it clicks on it and it changes the environment. In this function, I am just using if and else ...
4
votes
0answers
32 views

Simple Pretty-Bytes Size (SI System)

This is a simple and short "Pretty Bytes" javascript function using the SI Decimal System for quantifying bytes. The code does not use complex maths such as ...
4
votes
0answers
79 views

JavaScript AVL Tree

I have been working through Introduction to Algorithms 3rd Edition, and have implemented an AVL tree through prototypal inheritance. The code presented here does work as expected based on the tests ...
4
votes
0answers
57 views

Opinion on a small app I created using JavaScript

Recently I created a small app using JavaScript, and I would love for some JavaScript developers if they have the time of day, to tell me their opinions so I can grow and improve. I'm mostly working ...
4
votes
0answers
34 views

Browser and Node.js compatible code require

The Reason The reason I designed this code was that in many cases, when I wanted to test code in the browser that would be running on a Node instance, the code that I was copying (Don't worry, ...
4
votes
0answers
267 views

nodejs 401 request retry mechanism

I'm working on a project in which I have a backend in nodejs and from there I need to call external APIs, those APIs require authentication token which is valid for 15 minutes. So if response status ...
4
votes
2answers
69 views

Fixed size 2d array of objects

My Objective is to create a fixed column array object of size 4 columns so that I can form a 2d array in the following format which I can use to print to a pdf later. The solution is working fine. But ...
4
votes
0answers
64 views

A generic DFS in JavaScript

I implemented a general function for a depth-first-search (DFS) using JavaScript with default arguments and functions that need to be provided in order for it to work. This function is using ...
4
votes
0answers
151 views

RxJs memoized singleton selectors

I am working on an angular stack that has n amount of services that hold data in stores of this type: ...
4
votes
0answers
78 views

Running a JavaScript program from C# with sandboxing

I am using EdgeJS in my application. The application is used to run a user-provided javascript program from C#. Because we allow execution of user scripts some sandboxing is required. I am using vm2 ...
4
votes
0answers
44 views

MongoDB BulkWrite - create or update a sub document within an array

I have a series of Events (roughly 10-20 events that will be dynamically created per month): Event Model: ...
4
votes
0answers
612 views

Node JS | From Excel to Json

Intro -> I have to convert an excel file, which comes usually in this way: to a Json file that must looks like this: ...
4
votes
0answers
107 views

Vuejs - input validation

I'm in a project that's currently using vue. I'm at the moment developing validations for the inputs and in a way to make them more flexible, my idea was to create an intermediate component "Group ...
4
votes
0answers
141 views

Chess AI Using Minimax and Alpha-Beta Pruning

I am working on a Chess AI using chess.js, and currently, it can run 3 layers in under 10 seconds, but 4 or more takes minutes. How can I optimize my current code to be able to run 4 or 5 layers, or ...
4
votes
0answers
32 views

Get current user middleware from JWT using express

I'm using Sequelize and Google oAuth for authentication, I want to create a middleware that Verifies the sent token passed in the headers matches the one the user was initially signed to. Finds the ...
4
votes
0answers
364 views

Client-side routing using Knockout and HTML5 History API for a single-page web application

The full question is... "Please, how can this code base or project (for client-side routing using Knockout and HTML5 History API) be further enhanced as regards security, production-readiness, ES6, ...
4
votes
0answers
108 views

All the paths from the root to the leaves

Given a binary tree, return all root-to-leaf paths. Example: -- 1 / \ 2 3 \ 5 Output should be: ["1->2->5", "1->3"] My approach: I walk the branches ...
4
votes
1answer
182 views

Testing higher order reducer with jest

I'm trying to understand conception of creating unit tests for the frontend applications. I have created higher order reducer: ...
4
votes
1answer
95 views

Resource closing in a promise chain

This is some code that fetches a result from a database. It connects, makes a query, processes the query, then has to close the DB (under all possible code paths) and return the result. It seems ...
4
votes
0answers
36 views

Parsing root-level elements out of HTML fragment file

I have the following code written in NodeJS, using the parse5 library. It's purpose is to parse out the root-level elements in a file containing HTML fragments (Vue ...
4
votes
0answers
90 views

UI testing for a web application, with variant scenarios

I'm pretty new to software testing and am currently working on a cloud-based web application. Briefly, the application uses: Ext JS as a framework Bryntum's Siesta framework for testing Currently, ...
4
votes
0answers
204 views

React.js defaultMemoize as container

this is the code I wrote ...
4
votes
0answers
636 views

Generating Bitly links in a Google Sheet

I have this set of functions in my Google Sheet to create a Bitly bitlink whenever data in a row is changed. While this does work, it seems really slow to me. Looking at the Execution transcript, it ...
4
votes
0answers
65 views

Angular directive to fetch resources to fill a table

I created a directive that solves my immediate problem, but I'm trying to find ways to make it more reusable. My immediate problem was, I have a table and needed to fill in one of the columns with ...
4
votes
0answers
229 views

Parsing BibTeX in JavaScript

I have a project for which I need to parse BibTeX strings. In v0.2.9 and before, I used Regex, and I want to change that. I set up a while loop system that reads ...
4
votes
0answers
155 views

Extensible factory method for starting D3 charts

I'm working on refactoring some existing code to be a bit more extensible and am wanting to create a generic factory API for starting D3 charts. Currently, my factory looks like this: ...
4
votes
0answers
534 views

Hunt n' Kill algorithm

Last day I implemented the Hunt and Kill algorithm in JavaScript, using HTML5 without any libraries. I would like my code to be reviewed. How it works I start with a 2D array filled with walls (1-s),...
4
votes
0answers
312 views

Passport user authentication

I'm using Passport in Node.js app to authenticate user by email and password (login) and also by token. Email and password are used only when user is logging in. Passport local strategy generates ...
4
votes
0answers
2k views

Finding all paths between nodes in a graph

I wanted to write a function paths that returns the possible routes between two nodes in a graph. For example: ...
4
votes
0answers
263 views

Restructure of Express CORS middleware for unit test

How should one break this component down to better perform unit test on its behaviors? Issues: Authentication middleware component makes external request. Must recognize preflight and final flight. ...

1
2 3 4 5
24