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,230 questions with no upvoted or accepted answers
Filter by
Sorted by
Tagged with
10
votes
0answers
119 views

Resizable containers with VueJS

Some time ago 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
100 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 ...
7
votes
0answers
139 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
1answer
179 views

Way to delegate command to methods in different files

What I want to do is for an example command have it defined in its own file - e.g. command.js - and the same for the other methods. I want to make a separate file for every module - for example "...
6
votes
0answers
47 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 ...
5
votes
0answers
298 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
212 views

Spacial hashing Library

Old code ...
5
votes
0answers
159 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
156 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
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
1answer
60 views

Generate all partitions of a set of items

Here are the items: var item = ['a', 'b', 'c', 'd']; Desired output: ...
4
votes
0answers
90 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
58 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
67 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
37 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
38 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
189 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
35 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
345 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
89 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
235 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
95 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
82 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
681 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
125 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
121 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
48 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
201 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
36 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
420 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
366 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
113 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
210 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
115 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
93 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
229 views

React.js defaultMemoize as container

this is the code I wrote ...
4
votes
0answers
655 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
66 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
240 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
531 views

Recursively list files in provided directory in the style of `npm ls`

I've written a small CLI node program to list the contents of a directory with an output similar to that provided by npm ls but listing both files and directories, ...
4
votes
0answers
163 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
618 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
313 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
278 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
91 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
734 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. ...

1
2 3 4 5
25