Copy rows in sequence in HTML table based on input value and append each with count number

I have recently started learning HTML and Javascript, so please excuse me if this question may seem basic. I am developing a ‘simple’ file manipulator for a project and have come across an issue. Some background, the file is submitted into a javascript array and any excess information is removed. This array is then sent to a HTML table which is what will be displayed on the webpage. A new column is added to the table after this which is a number input. The idea is that this table will then create a javascript array which will then go through further manipulation before being downloaded as a CSV file. I have the initial table creation and input fields sorted, and the end with array manip and CSV creation, the middle part is what I’m stuck with.
example of what it currently looks like.

In essence I need the value in ‘Dilutions’ to be read, and that number of entries created in an array for the ‘SAMPLEID’, in order. So for example, [‘26444563-1′,’26444564-1’,’26444564-2’…] etc. Ideally, this would be attached to a new button or something similar, and the total sum of the input values would be at most 84 and return an error, but that shouldn’t be an issue to check beforehand.

const form = document.querySelector("#sifForm");
const sifFileInput = document.querySelector("#sifInput");


//csv to array logic
function csvToArr(str, delimiter = ",") { //string and delimiter in file
  //slice from start of text, split on new line n regex
  //split creates array on delimiter
  const headers = str.slice(0, str.indexOf("n")).split(delimiter);

  //slice from new line index +1 to the end of the text
  //split creates array on each new line
  const rows = str.slice(str.indexOf("n")+1).split("n");

  //map the rows
  //split values from each row into an array
  //use headers.reduce to create an object
  //object properties derived fromm header:values
  //object passed as element of array
  const arr = rows.map(function (row) {
    const values = row.split(delimiter);
    const el = headers.reduce(function (object, header, index) {
      object[header] = values[index];
      return object;
    }, {});
    return el;
  });

  //return array
  return arr;

}

//logic for form submission
form.addEventListener("submit", function (event) {
  event.preventDefault(); //prevents default refresh on submit button
  const input = sifFileInput.files[0];
  const reader = new FileReader();

  reader.onload = function (e) {
    const text = e.target.result;
    const data = csvToArr(text);
    //document.write(JSON.stringify(data,null,"  "));
    //console.log(data)
    //set field to keep
    function selectFields(sID) {
      const {SAMPLEID} = sID;
      return {SAMPLEID};
    }
    const workSheet = data.map(selectFields);
    //remove undefined
    workSheet.pop();
    console.log(workSheet);

    //add dilutions
    //workSheet.forEach(function (element) {
    //  element.Dilutions = `<input type="number" name="balance" />` ;
    //});
    
    //Create Table
    const table = document.querySelector("#worksheettbl");
    const headers = table.querySelector("thead tr");
    const body = table.querySelector("tbody");
                        
    // Create headers
    for (const key in workSheet[0]) {
      const header = document.createElement("th");
      header.innerText = key;
      headers.append(header);
    }
    
    // Create tbody rows
    workSheet.forEach(obj => {
      // Create row
      const row = document.createElement("tr");
      body.append(row);
      
      // Create row element
      for (const key in obj) {
        const value = document.createElement("td");
        value.innerText = obj[key];
        row.append(value);
      }

    });

    //add dilution number inputs
    function addDilutions(){
      addColumn(table, 'Dilutions');
    }
    
    function addColumn(table, headerText){  
      
      const newHeaderCol = document.createElement('th');
      newHeaderCol.innerText = headerText;      
      table.querySelector('thead > tr:first-child').append(newHeaderCol);
      
      const tableRows = table.querySelectorAll('tbody > tr');
      let iRow = 0;
      for(const tableRow of tableRows){
        const newBodyCol = document.createElement("input");    
        newBodyCol.type = "number"
        newBodyCol.value = 1
        tableRow.append(newBodyCol);
      }
    }
    addDilutions();




  };
  reader.readAsText(input); //reads the file


});
<!DOCTYPE html>
<html>
    <head>
        <title>test</title>
        <meta charset="UTF-8" />
    </head>

    
    <body>
        <form id="sifForm">
            <input type="file" id="sifInput" accept=".sif"/>
            <input type="submit" value="Submit" />
        </form>
        <table  id="worksheettbl">
            <thead>
              <tr>
              </tr>
            </thead>
            <tbody>
            </tbody>
        </table>

          

        <script src="js/input.js"></script>
        
        
    </body>
</html>

Any advice would be appreciated. Thanks.

Iframe with absolute positioning + scrolling?

The bases of the site is iframes, of which only 1 shows at a time. My problem is with the iframes not scrolling, which is a problem of absolute position. I’ve tried wrapping each iframe in its own absolute div, and a few overflow styles. If the iframe is styled with relative, scrolling functionality works but the format is incorrect. Weirdly, the 6th iframe scrolls perfectly Here is the full file

<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Your Website</title>
    <style>
      body {
        margin: 0;
        padding: 0;
        font-family: Arial, sans-serif;
        display: flex;
        justify-content: center;
        align-items: center;
        height: 100vh;
        background-color: #f0f0f0;
        transition: background-color 0.3s ease;
        position: relative;
      }

      #container {
        display: flex;
        width: 100%; /* Adjust the width as needed */
        height: 100vh;
      }

      #left-column,
      #right-column {
        text-align: center;
      }

      #left-column {
        width: 20%;
        background-color: #ddd;
        height: 100%;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        transition: width 0.3s ease, background-color 0.3s ease;
      }

      #left-column:hover {
        width: 25%;
        background-color: rgb(50, 46, 46);
        color: #fff;
      }

      #left-column nav {
        flex-grow: 1;
        display: flex;
        flex-direction: column;
        justify-content: space-evenly;
      }

      #left-column ul {
        list-style: none;
        padding: 0;
        margin: 0;
      }

      #left-column li {
        height: fit-content;
        font-size: 16px;
        margin-top: 30px;
        cursor: pointer;
        transition: font-size 0.3s ease, color 0.3s ease; /* Adjusted transition properties */
      }

      #left-column li:hover {
        font-size: 18px;
        color: rgb(140, 142, 148);
      }

      #middle-section {
        margin-left: 10px;
        margin-right: 10px;
        width: 60%;
        height: 100vh;
        background-color: #fff;
        position: relative;
        transition: width 0.3s ease, background-color 0.3s ease;
      }

      iframe {
        width: 100%;
        height: 100vh;
        border: none;
        opacity: 0;
        position: absolute; /* Use absolute positioning for iframes */
        transition: opacity 0.3s ease;
        overflow: auto;
      }

      iframe.show {
        opacity: 1;
      }

      /* Additional style to make the iframe container responsive */
      #middle-section iframe {
        display: block;
      }

      #right-column {
        width: 20%;
        background-color: #ddd;
        padding: 20px;
        box-sizing: border-box;
        overflow: hidden;
        transition: width 0.3s ease, background-color 0.3s ease;
      }

      #right-column:hover {
        width: 25%;
      }
    </style>
  </head>
  <body>
    <div id="container">
      <div id="left-column">
        <!-- Content for the left column -->
        <nav>
          <ul>
            <li onclick="showIframe(1)">Fall Prep Coaches</li>
            <li onclick="showIframe(2)">Team Real Speed</li>
            <li onclick="showIframe(3)">Real Speed Staff</li>
            <li onclick="showIframe(4)">Small Group Training</li>
            <li onclick="showIframe(5)">Off-Ice Training</li>
            <li onclick="showIframe(6)">Tryouts</li>
          </ul>
        </nav>
      </div>

      <div id="middle-section">
        <!-- Content for the middle section -->
        <iframe
          id="iframe1"
          class="show"
          src="https://nefphlcoaches.eu/"
          scrolling="yes"
          frameborder="0"
        ></iframe>
        <iframe
          id="iframe2"
          src="https://nefphlcoaches.eu/RealSpeed2/index2.html"
          scrolling="yes"
          frameborder="0"
        ></iframe>
        <iframe
          id="iframe3"
          src="https://nefphlcoaches.eu/RealSpeed/index.html"
          scrolling="yes"
          frameborder="0"
        ></iframe>
        <iframe
          id="iframe4"
          src="https://nefphlcoaches.eu/SGT/index.html"
          scrolling="yes"
          frameborder="0"
        ></iframe>
        <iframe
          id="iframe5"
          src="https://nefphlcoaches.eu/Training/index.html"
          scrolling="yes"
          frameborder="0"
        ></iframe>
        <iframe
          id="iframe6"
          src="https://nefphlcoaches.eu/tryout/index.html"
          scrolling="yes"
          frameborder="0"
        ></iframe>
      </div>

      <div id="right-column">
        <!-- Content for the right column -->
        <h2>Right Column</h2>
        <p>Your content goes here.</p>
      </div>
    </div>

    <script>
      function showIframe(index) {
        document.querySelectorAll("iframe").forEach((iframe) => {
          iframe.classList.remove("show");
        });

        document.getElementById(`iframe${index}`).classList.add("show");
      }
    </script>
  </body>
</html>

What is js DOM module and how to import it? Looking for context2d function

I’m learning d3 and React and I’m trying to recreate the following visualisation:

https://observablehq.com/@d3/mona-lisa-histogram

But I am completely stuck on the following piece of code:

const context = DOM.context2d(width, height, 1);
  context.willReadFrequently = true;

I understand that context2d gives us information about the pixels within the “canvas” of width and height. But I need help with basics: where do I import the DOM from? I cannot find anything about it, as any search links to discussion on what DOM is. Can someone help please?

How to draw particles for a pixel rain?

I’ve been trying to make a pixel rain for base64 images with javascript’s context.getImageData(), but the particles used for this don’t get updated nor drawn.

What I expected was a lot of pixels going from the top of the canvas to the bottom with changing speeds depending on the brightness of the image and a color based on their position.

The code is within an addEventListener for loading the image (which is defined in the first lines). Here are some samples:

    const canvas = document.getElementById('canvas');
    const ctx = canvas.getContext('2d');
    canvas.width = 600;
    canvas.height = 714;

    ctx.drawImage(myImage, 0, 0, canvas.width, canvas.height);
    const pixels = ctx.getImageData(0, 0, canvas.width, canvas.height);
    // ctx.clearRect(0, 0, canvas.width, canvas.height);

    let particlesArray = [];
    const ParticlesAmount = 5000;

    let mappedImage = [];

    for (let y = 0; y < canvas.height; y++) {
        let row = [];
        for (let x = 0; x < canvas.width; x++) {
            const red = pixels.data[(y * 4 *pixels.width) + (x *4)];
            const green = pixels.data[(y * 4 *pixels.width) + (x *4 + 1)];
            const blue = pixels.data[(y * 4 *pixels.width) + (x *4 + 2)];
            const alpha = pixels.data[(y * 4 *pixels.width) + (x *4 + 3)];
            
            const brightness = calculateRelativeBrightness(red, green, blue);
            const cell = [
                cellBrightness = brightness,
                cellColor = 'rgb(' + red + ', ' + green + ', ' + blue + ', ' + alpha + ')'
            ]
            row.push(cell);
        }
        mappedImage.push(row);
    }

    // For the human's eye perception.
    function calculateRelativeBrightness(red, green, blue) {
        return Math.sqrt(
            (red * red) * 0.299 +
            (green* green) * 0.587 +
            (blue * blue) * 0.114
        );
    }

Class for crating the Particles:

class Particle {
        constructor() {
            this.x = Math.random() * canvas.width;
            this.y = 0;
            this.speed = 0;
            this.velocity = Math.random() * 0.3;
            this.size = Math.random() * 1.5 + 1;
            this.position1 = Math.floor(this.y);
            this.position2 = Math.floor(this.x);
        }

        update() {
            this.position1 = Math.floor(this.y);
            this.position2 = Math.floor(this.x);

            let movement = this.velocity * 3.5;

            if (
                this.position1 >= 0 &&
                this.position1 < mappedImage.length &&
                this.position2 >= 0 &&
                this.position2 < mappedImage[0].length
            ) {
                this.speed = mappedImage[this.position1][this.position2][0];
                movement = (2.5 - this.speed) + this.velocity;
            }

            this.y += movement;

            if (this.y >= canvas.height) {
                this.y = 0;
                this.x = Math.random() * canvas.width;
            }
        }

        draw() {
            ctx.beginPath();
            if (
                this.position1 >= 0 &&
                this.position1 < mappedImage.length &&
                this.position2 >= 0 &&
                this.position2 < mappedImage[0].length
            ) {
                ctx.fillStyle = mappedImage[this.position1][this.position2][1];
            } else {ctx.fillStyle = 'white'}
            ctx.arc(this.x, this.y, this.size, 0, Math.PI * 2);
            ctx.fill();
        }
    }

Animation loop:

function init() {
        for (let i=0; i < ParticlesAmount; i++) {
            particlesArray.push(new Particle());
        }
    }
    
    init();

function animate() {
        ctx.globalAlpha = 0.05;
        ctx.fillStyle = 'rgb(0, 0, 0)';
        ctx.fillRect(0, 0, canvas.width, canvas.height);
        for (let i=0; i < particlesArray.length; i++) {
            ctx.globalAlpha = particlesArray[i].speed * 0.5;
            particlesArray[i].update();
            particlesArray[i].draw();
        }
        requestAnimationFrame(animate);
    }
animate();

Code splitting not working with webpack 5, react 18, and react router 6

I am trying to set up a new react project with a custom webpack config, and react router. I am using react 18, webpack 5, and react-router 6.

Looking at my App.tsx, it sets up some routes. For now, a few page components are lazy-loaded using React.lazy and Suspense:

import React, { Suspense } from "react";
import { BrowserRouter, Outlet, Route, Routes } from "react-router-dom";

const CarsPage = React.lazy(() => import("pages/cars"));
const PlanesPage = React.lazy(() => import("pages/planes"));


export const App: React.FC = () => {
  return (
    <BrowserRouter>
      <Routes>
        <Route
          element={
            <div>
              <HeaderBar />
              <Outlet />
            </div>
          }
        >
          <Route path="/" element={<div>Homepage here</div>} />
          <Route
            path="/cars/*"
            element={
              <Suspense fallback={<div>Loading . . .</div>}>
                <CarsPage />
              </Suspense>
            }
          />
          <Route
            path="/planes/*"
            element={
              <Suspense fallback={<div>Loading . . .</div>}>
                <PlanesPage />
              </Suspense>
            }
          />
        </Route>
      </Routes>
    </BrowserRouter>
  );
};

I am trying to set up my webpack to codesplit, such that the code for CarsPage or PlanesPage is bundled separately. Following the webpack instructions on codesplitting, this is my webpack config:

module.exports = {
  entry: "./src/index.tsx",
  target: "web",
  output: {
    path: path.resolve(__dirname, "../build"),
    publicPath: "/",
    filename: "[name].js",
    chunkFilename: "[id].[chunkhash].js",
  },
  optimization: {
    splitChunks: {
      chunks: "all",
      cacheGroups: {
        vendors: {
          test: /[\/]node_modules[\/]/,
          name: "vendor",
          chunks: "all",
        },
      },
    },
  },
  resolve: {... some resolve rules},
  module: {...some module rules}
  plugins: [...some plugins],
}

When I load the page, I see that the vendor chunk is correctly separate from the main chunk. (This is also desired, as I want my node_modules to be treated as a separate chunkfile, as they’ll get updates far less often than the production bundle, so cacheing node_modules in the vendorfile is desired).

Running a build, I am not seeing separate chunk files for the CarsPage and PlanesPage components. Running with webpack dev server, when I load the page, I see a massive main.js file. Navigating to /cars or /planes, no additional js chunk is requested. Clearly, my code is not being split.

What am I doing wrong with my setup here? I know create-react-app used to do this automatically, but how can this be acheived with a custom webpack config? Shouldn’t anything imported using the React.lazy import be automatically code-split using webpack 5?

How to ensure an inequality graph updates its shading dynamically in JSXgraph?

I am making a dynamic graph of an linear inequality. I want there to be two draggable points that dynamically change the inequality graph. I also want a button that toggles whether the line is dashed or solid, and another button that toggles the shading direction.

I’m essentially done, but I can’t get the shading to switch sides when the button is pressed.

My current code can be found and run at https://jsfiddle.net/einstien311/kj7udbnh/11/ .

const board = JXG.JSXGraph.initBoard('jxgbox', {
  boundingbox: [-12, 12, 12, -12],
  axis: true,
  grid: true
});


// Initialize points for default graph
var firstBluePoint = board.create('point', [1, -4], {
  name: '',
  snapToGrid: true,
  color: 'blue',
  highlightStrokeColor: 'blue',
  highlightFillColor: 'blue'
});

var secondBluePoint = board.create('point', [2, -2], {
  name: '',
  snapToGrid: true,
  color: 'blue',
  highlightStrokeColor: 'blue',
  highlightFillColor: 'blue'
});


// Create Lines 
var blueLine = board.create('line', [() => -1 * ((secondBluePoint.Y() - firstBluePoint.Y()) / (secondBluePoint.X() - firstBluePoint.X()) * (-firstBluePoint.X()) + firstBluePoint.Y()), () => -1 * ((secondBluePoint.Y() - firstBluePoint.Y()) / (secondBluePoint.X() - firstBluePoint.X())), 1], {
  name: '',
  color: 'blue',
  highlightStrokeColor: 'blue',
  strokeWidth: 2.5,
  dash: 0,
  visible: true
});


// Create Inequalities Shaded Region
var blueInequality = board.create('inequality', [blueLine], {
  color: 'blue',
  fillOpacity: 0.18,
  strokeWidth: 0,
  inverse: true
})


// Blue Line Button
var toggleBlueLinePattern = board.create('button', [-11.5, -9.9, 'Change Blue Line', function() {
  if (blueLine.getAttribute('dash') == 0) {
    blueLine.setAttribute({
      dash: 3
    });
  } else {
    blueLine.setAttribute({
      dash: 0
    });;
  }
}]);


// Blue Shading Button
var toggleBlueShadeDirection = board.create('button', [-12, -11.1, 'Change Blue Shading', function() {
  if (blueInequality.getAttribute('inverse')) {
    blueInequality.setAttribute({
      inverse: false
    });
  } else {
    blueInequality.setAttribute({
      inverse: true
    });
  }
}]);


// Visualize whether the attribute truly changes
var blueInequalityInverseAttributeListener = board.create('point', [() => (blueInequality.getAttribute('inverse') ? 1 : 0), 0], {
  name: 'Blue Inequality Inverse Attribute Listener',
  color: 'green',
  highlightStrokeColor: 'green',
  highlightFillColor: 'green',
  visible: true
});

What I’ve tried so far to diagnose the issue:

I’ve made a point on the graph called “blueInequalityInverseAttributeListener” that dynamically shows the value of the inverse attribute of the inequality. When the button is pressed, the Listener Point toggle between 0 and 1, which (if I’ve done it correctly) indicates to me that the inequality’s attribute truly does get updated as intended by the button.

Therefore, I can only conclude that although the attribute is updated, the change is not reflected on the graph. I’m not sure if there’s some syntax I don’t know or if there’s some function I need to call to re-render the inequality. Any help would be greatly appreciated. 🙂

Einstien311

P.S. I’m only a few months into JSXgraph, and that is my only experience with JavaScript, so my syntax might not be very elegant :/

Founding network request in react JS

I am begiiner at React JS, my app is a simple and basic react app(text editor) with no beckend/database, problem is that my app is running absoluty fine in other browsers(opera,) but whenever i tried to open in chrome,intially,it loads fine but after that whenever is i try to open chrome developer tools, and refresh my site, all site blows away, and network error starts to display on screen. Please note that this only happening in chrome, there is no such problem in other browsers.

I also tried to even clear browser catche and removed unnecessary tool but error continue to presuit!

Invalid hook call, Cannot read properties of null (reading ‘useRef’), Cannot read properties of null (reading ‘useContext’) while using Routes, Route

enter image description hereI am creating React App and everything was ok until I tried to connect the pages using Routes and Route

I got error:

  • “Cannot read properties of null (reading ‘useRef’)” or ‘useContext’ in google chrome
  • “null is not an object (evaluating ‘dispatcher.useRef’)” in Safari
  • “Invalid hook call” in console in google chrome

(I don’t use any useRef, use Context)

Imports work well beacause when I import f.e. only HomePage in App function it works. Problems appears when I try use Routes, Route

Any ideas why and how to solve it?

in App.jsx I got

import { BrowserRouter as Router, Routes, Route } from "react-router-dom";
import HomePage from "./pages/HomePage";
import AboutPage from "./pages/AboutPage";
import "./App.css";

function App() {
    return (
        <>
            <Router>
                <Routes>
                    <Route path="/" element={<HomePage />} />
                    <Route path="/about" element={<AboutPage />} />
                </Routes>
            </Router>
        </>
    );
}

export default App;

in index.js:

import React from "react";
import ReactDOM from "react-dom/client";
import "./index.css";
import App from "./App";
import reportWebVitals from "./reportWebVitals";

const root = ReactDOM.createRoot(document.getElementById("root"));
root.render(
    <React.StrictMode>
        <App />
    </React.StrictMode>
);

reportWebVitals();

And question about script in index.html

<body>
        <noscript>You need to enable JavaScript to run this app.</noscript>
        <div id="root"></div>
        <script type="module" src="../src/index.js"></script>
    </body>

Did I do it correctly? At first I had type=”module” but I got an error in the browser console:
“Failed to load module script: Expected a JavaScript module script but the server responded with a MIME type of “text/html”. Strict MIME type checking is enforced for module scripts per HTML spec.”
At the beginning I changed “module” to “text/html”, but it implements js/jsx so this html does not fit my logic here.

I feel like I’ve already looked through the entire internet, but I can’t figure out what it’s all about and how to improve it.

The problem appeared when Routes, Route was introduced (I mean, I try to introduce).

Any ideas, tips, solutions? Or maybe there is another way to do it?

Or maybe I have the wrong packages installed and/or in a wrong way? What should I install, where and how?

(screenshot of files menu at the beginning)

Match key from Object to element in an array replace match with keys value

I want to exactly match the key from an Object to an element in an array and replace the match in the array with the key value.

I have

Arr = [ 'Saturday', 'niCCCght', 'plans,', 'CCC' ]

Obj = { "AAA": "BBB", "CCC": "DDD", "EEE": "FFF" }

with below I get

[ 
  [ 'Saturday', 'Saturday', 'Saturday' ],
  [ 'niCCCght', 'niCCCght', 'niCCCght' ],
  [ 'plans,', 'plans,', 'plans,' ],
  [ 'CCC', 'DDD', 'CCC' ] 
]

I want

[ 'Saturday', 'niCCCght', 'plans,', 'DDD' ]

Thank you

function test() {
  let Arr = [ 'Saturday', 'niCCCght', 'plans,', 'CCC' ];

  const Obj = {"AAA":"BBB", "CCC":"DDD","EEE":"FFF"};
  
  const Z = Arr.map(v => matchedKey(Obj,v))

  console.log(Z);
}
let matchedKey = (Obj,str) => Object.keys(Obj).map(key => key===str ? Obj[key]: str);

Crafty.js HUD not moving text

I’ve bean developing a game in crafty.js for a while now and I was wondering since I’m using the viewport on the player entity I was struggling on how to keep text in the same relative position as the players viewport moves so I can display score and other information. Could anyone help?

I’ve tried using math to figure out the position but its not fluid with the movement.

Initialize bootstrap tooltips after the DOM is modified (Bootstrap Datepicker)

I’m using bootstrap-datepicker to render a calendar control on the page.

When the datepicker control is created, I set the title tag based on some value, so day will have a title attribute set.

After the component renders I initialize bootstrap tooltips to create popovers. However, when the month is changed the tooltips stop functioning.

$('#datepicker').datepicker({
                    todayHighlight: true,
                    maxViewMode: 1,
                    beforeShowDay: function (date) {
                        return { classes: 'na', enabled: false, tooltip: msgNoSlotsAvailable };
                    },
                    toggleActive: true
                });
 $('.na').tooltip({container:'body'}); // Works, but only on current month
 $('#datepicker').datepicker().on('changeMonth', function (e) {
    $('.na').tooltip({container:'body'}); // Event fires, but the tooltips dont get added
 }

I think the issue is the event is firing before the DOM modifications are complete. I tried changeMonth:after on a whim but that did not work.

how to access multiple files together in single page at react js

Compiled with problems:

×

ERROR in ./src/App.js 6:0-51

Module not found: Error: Can’t resolve ‘./CategoryPreview.js’ in ‘C:awt-sem4-projectsrc’

ERROR in ./src/App.js 7:0-58

Module not found: Error: You attempted to import ../pages/ProductOverview.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project’s node_modules/.

ERROR in ./src/App.js 8:0-53

Module not found: Error: You attempted to import ../pages/PromoSections.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project’s node_modules/.

ERROR in ./src/App.js 9:0-59

Module not found: Error: You attempted to import ../pages/StoreNavigation.jsx which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project’s node_modules/.

ERROR in ./src/App.js 10:0-53

Module not found: Error: You attempted to import ../pages/NumberofList.jsx which falls outside of the project src/ directory. Relative imports outside of src/ are not supported. You can either move it inside src/, or add a symlink to it from project’s node_modules/.

How to repeat RxJS from() but skip first emission

I have the following code which I expect should emit for each member in the scheduleEntries array, and I want the first emission of each array member to be skipped. How can I get it to work?

Right now it doesn’t emit at all with skip(1)

import { Observable, from, mergeMap, of, repeat, skip, timer } from 'rxjs';

class Schedule {
  private scheduleEntries = [
    { value: true, countdown: 48395 },
    { value: true, countdown: 38395 },
    { value: false, countdown: 42394 },
    { value: true, countdown: 4835 },
  ];

  private lockEmitter$: Observable<ScheduleEntry>;

  constructor() {
    this.lockEmitter$ = from(this.scheduleEntries).pipe(
      skip(1), // skip the first emission for each entry
      mergeMap(entry => of(entry).pipe(
        repeat({ delay: () => this.delayedObservableFactory(entry) }),
      )),
    );
    this.lockEmitter$.subscribe(console.log);
  }

  private delayedObservableFactory(entry: ScheduleEntry) {
    return new Observable(observer => {
      timer(entry.countdown).subscribe(() => observer.next({}));
    });
  }
}


interface ScheduleEntry {
  value: boolean;
  countdown: number;
}