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,322 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
219 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 ...
8
votes
0answers
148 views

React Typescript Boilerplate

I'm trying to build a React Boilerplate Using multiple tools. They are all: React, TypeScript, ESLint, Webpack, Babel, Prettier, VSCode and with Airbnb's code style guide. Actually, this is my first ...
6
votes
0answers
54 views

Monitoring a view model for changes to display a save button

I'm working with Knockout3 in a Chromium 40 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 ...
6
votes
0answers
165 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
427 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
0answers
222 views

Spacial hashing Library

Old code ...
5
votes
0answers
165 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
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: ...
5
votes
0answers
77 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 ...
4
votes
0answers
55 views

Find and replace text in a webpage with JavaScript

I am new to web development and would like to get feedback on a JavaScript library that automatically finds and replaces text on a webpage using the MutationObserver interface. EDIT: Seeing that this ...
4
votes
0answers
95 views

This recursive function encrypts a string

Is there a way to rewrite these last 2 recursive functions with fewer arguments (preferably 2) while keeping them recursive? The entire code can be seen here: https://github.com/GirkovArpa/hutton-...
4
votes
0answers
78 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
74 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
1answer
45 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
50 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
288 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
36 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
397 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
0answers
140 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
327 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
136 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
191 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
759 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
144 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
133 views

Node.js tool to update Cisco UCCX with CSV data

What this tool does update skills for agents on a Contact Center Cluster (Cisco UCCX). The tool reads a csv file called agents.csv from the current working directory. This file has a list of agents ...
4
votes
0answers
168 views

Find the starting indices of all occurrences of the pattern in the string - KMP algorithm follow-up

The task was initially solved here, but was too buggy: Given a string and a pattern, find the starting indices of all occurrences of the pattern in the string. For example, given the string "...
4
votes
0answers
57 views

Formatting CSV as a table using BDD

This is the problem: Write a function to create a table from CSV data. The input to the function is a list of strings. Each string is formatted as a CSV record. Here’s an example for a ...
4
votes
0answers
261 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
38 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
492 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
1answer
554 views

Sorting function from a React app to display JSON data in a sortable table

I created this simple react application for a coding challenge, which is described in the linked README file. Basically, I created the components and helper logic to display dynamic JSON data in a ...
4
votes
0answers
114 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
0answers
64 views

JavaScript attempt at an aspect oriented logger using proxies and reflect

I've been playing around with AOP in JavaScript to create a Logger that I can attach to classes and output what is going on (mainly instantiation, calling of functions and the results from functions). ...
4
votes
0answers
37 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
94 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
260 views

React.js defaultMemoize as container

this is the code I wrote ...
4
votes
0answers
673 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
67 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
263 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
174 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
673 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
316 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
321 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. ...
4
votes
0answers
94 views

Angular controller scope inheritance vs service

On my site I have a navbar component that I want to customize for each and every ng-view I end up loading. Currently I'm doing ...
4
votes
0answers
88 views

Backbone learning piece, Movie Application using Views, Collection, Models, Routes and Localstorage

I have created a Backbone Movie app as part of a learning exercise, the app is hosted on codepen although I actually have it built on my local but thought this approach would be handier for code ...
4
votes
0answers
744 views

Flash embed angular directive

I have an app that uses HTML5 video and our customer still needs to support IE8. Gross. Anyway, I came up with this directive in Angular to for embedding a SWF for when I need to fallback to Flash. ...
4
votes
0answers
74 views

Comparison of sprite movement implementations

I've come up with two ways to do sprite movement with CreateJS, and I'm wondering if one is better than the other as far as performance and maintainability. The player data is saved in a json file ...
4
votes
0answers
83 views

Changing Component Style

I have a component that I want to render with certain styling based upon the props that it will receive. I'm currently defaulting the prop types, and then creating the styling at render as such: <...
4
votes
0answers
250 views

Mongoose and Hapi/Express promise handling in controllers

I'm switching my code to promises - mostly as delivered by Mongoose. I use Hapi though I think something similar would apply to Express. In my models/services I perform queries such as: ...

1
2 3 4 5
27