DateTime Format using Intl in es-AR return date without am/pm

There is a very strange behavior of Intl.DateTimeFormat in case of ‘es-AR’ local when I try to format date for example :

    const date = Date.UTC(2012, 1, 2, 14, 5, 42);
    let format: Intl.DateTimeFormatOptions = {
      year: 'numeric',
      month: 'numeric',
      day: 'numeric',
      hour: 'numeric',
      minute: 'numeric',
      second: 'numeric',
      timeZone: 'UTC',
    }

    let result = Intl.DateTimeFormat('es-AR', format).format(date);

I get the date 2/2/2012, 02:05:42

But when I use this formatOptions:

let format: Intl.DateTimeFormatOptions = {
      year: 'numeric',
      month: 'numeric',
      day: 'numeric',
      hour: 'numeric',
      minute: 'numeric',
      second: '2-digit',
      timeZone: 'UTC',
    }

I am getting
2/2/2012, 2:05:42 p. m.

Why does this act so strangely?
Why I don’t get the AM/PM in the first case?
What should I do to get the AM/PM (my code should show am/pm in case the current local is 12h but don’t show it in case we use 24h )

Thanks

How to change candlestick logic in Chart.js on the previous close

By now, everyone knows that the candles on a financial chart should be green if the close is higher than the open and red if the close is higher than the open.

This is a sample

https://www.chartjs.org/chartjs-chart-financial/

But as you can see, many are adapting by setting the color of the candles on the close of the previous candle. That is, if the current close is higher than the close of the previous point, the candle will be green, otherwise red.

https://it.tradingview.com/chart/?symbol=NASDAQ%3ATSLA

The logic adapts to the closing price of the previous point and no longer to the opening and closing of the single point.


Now see the question

Is there a way to adapt this logic to chart.js?

Starting from the financial graph provided by chart.js already exposed above

https://www.chartjs.org/chartjs-chart-financial/

is there a way to adapt the new candlestick logic for the previous point, so not for the opening and closing price of the single candle?

trouble dynamically changing the value of parameter in js

I’m trying to update the values to the passed to the neonInstance i have tried to change the value using different approaches it does change the value but the neonInstance doesn’t take thew given values as input.

The code works fine but a small dot remains in the middle of the page which is the cursor starting point i don’t want it to be visible when the cursor is not on the page so when i change the value of the shaderPoints parameter to 0 the cursor starting point disappears and when the value is set to 10 the cursor becomes visible(this is when i change the values manually) what i want is that when a person hovers the cursor over the page then the value of the shaderPoints gets set to 10 and as soon as the cursor leaves the page then the value is set to 0 so like only when the person comes on to the page only then it shows the cursor i have tried a few approaches trying to figure out a way to do this but to no success if anyone could guide me on what i am doing wrong and how i can achieve this also if there is any other approach that i can follow.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <style>
        body, html {
            margin: 0;
            width: 100%;
            height: 100%;
            overflow: hidden;
            touch-action: none;
        }

        body {
            color: #ffffff;
            font-family: 'Montserrat', sans-serif;
            text-align: center;
            text-shadow: 0 0 5px #ffffff, 0 0 20px #000, 0 0 30px #000;
        }

        h1 {
            --fontSize: 60px;
            --lineHeight: 80px;
            width: auto;
            height: calc(2 * var(--lineHeight));
            line-height: var(--lineHeight);
            margin: calc(50vh - var(--lineHeight)) auto 0;
            font-size: var(--fontSize);
            text-transform: uppercase;
        }

        a {
            margin-top: 10px;
            display: inline-block;
            text-decoration: none;
            color: #fff;
        }

        canvas {
            display: block;
            position: fixed;
            z-index: -1;
            top: 0;
        }
    </style>
    <script type="module">
        import { neonCursor } from "https://unpkg.com/[email protected]/build/threejs-toys.module.cdn.min.js";

       
// Ensure that neonCursor is properly initialized
let neonInstance = neonCursor({
    el: document.body,  // Target the entire body
    shaderPoints: 10,    // Initial shaderPoints when cursor is outside
    curvePoints: 40,
    curveLerp: 0.7,
    radius1: 3,
    radius2: 19,
    velocityTreshold: 1,
    sleepRadiusX: 0,
    sleepRadiusY: 0,
    sleepTimeCoefX: 0.00,
    sleepTimeCoefY: 0.00
  });
  
  console.log(neonInstance); // Debugging: check if neonInstance is initialized properly
  
  document.body.addEventListener("mouseenter", function() {
    console.log("mouseenter triggered");
  
    if (neonInstance) {
      var before = neonInstance.shaderPoints;
      console.log("Before:", before);
      // Update the neonInstance properties
      neonInstance.shaderPoints = 10;
      neonInstance.curvePoints = 40;
      neonInstance.curveLerp = 0.7;
      neonInstance.config.radius1 = 3;
      neonInstance.config.radius2 = 19;
      neonInstance.velocityTreshold = 1;
      neonInstance.sleepRadiusX = 0;
      neonInstance.sleepRadiusY = 0;
      neonInstance.sleepTimeCoefX = 0.00;
      neonInstance.sleepTimeCoefY = 0.00;
  
      var after = neonInstance.shaderPoints;
      console.log("After:", after);
    } else {
      console.log("neonInstance is not defined");
    }
  });
  
  document.body.addEventListener("mouseleave", function() {
    console.log("mouseleave triggered");
  });

       
    </script>
</head>
<body>
    <h1>Your Neon Text</h1>
    <a href="#">Your Link</a>
    <canvas></canvas>
</body>
</html>

what i want is when the mouse enters the body of the website the cursor becomes visible and when the cursor it out of the webpage it should not be visible

Make Click Counter and Progress Bar work hand in hand

I have a Click counter that for some reason no matter what I do I am unable to get it to count on click, I would also like the progress bar to grab it’s value by the amount the button has been click. (Granted I am wanting to be able to click the follow button on a different page and have the counter “You Will See This In RED” go up in the account info page).

My understanding is that if it is called from script it doesn’t matter what page the button is on it should still be able to retrieve the information and apply the count to the achievement.

would some please be able to take a look for me.

(I understand I’m here asking quite a bit for context I’m not a coder it’s taken alot to achieve what I have in what little spare time I have, I originally started building my site with a friend and he was teaching me before leaving the project)

This may be better to understand if you are to look at my codepen:
https://codepen.io/Elixble/pen/gbYXBjR

Summary: The Progress Bar works it just needs to grab data from the counter but the counter doesn’t work

HMTL

<body id="Background">
  <div id="SettingsBox">
    <div>

  <button id="follow-button" class="main-button" userFollowed="$profile->username" onclick ="clickCounter()"><span>Follow</span></button> 
      
<div class=achievements-levels-Container>
  <div class=subtitle> 
    <text class=number-one>Level 1</text> 
  </div>
  
<div class=achievement-the-starter>
  <text class=thestartertext>The Starter</text>
  <h1 id="clicks">0</h1>
 <text class=tasks-text>Follow    /5 Other User</text>
  <div class="progress">
    <div class="progress__fill"></div>
  </div>
</div>
  
<div class=subtitle> 
  <text class=number-Two>Level 2</text> 
</div>
<div class=achievement-gains>
  <text class=thegains>Gains</text>
  <text class=tasks-text>Gain 0/10 Followers</text> 
</div>
  
<div class=subtitle> 
  <text class=number-Three>Level 3</text> 
</div>
<div class=achievement-connect>
  <text class=thegains>Connect</text>
  <text class=tasks-text>Connect Accounts</text> 
</div>
</div>
</body>

CSS

.achievements-levels-Container
{
    position:absolute;
    display: grid;
    height:300px;
    width: 425px;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    background-color: #1616167c;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: hidden;
    overflow-y: auto;
    left: 615px;
    Top: 30px;
    align-content: center;
}


.subtitle
{
  position: relative;
    display: grid;
  left: 15px;
  top:35px;
}



.number-one
{
  Margin-top: 30px;
    display: grid;
    font-family:Montserrat;
  font-size: 18px;
  color: #c2c2c2;
  font-weight: bold;
  margin-bottom: 10px;
}

.number-Two
{
    display: grid;
    font-family:Montserrat;
  font-size: 18px;
  color: #c2c2c29f;
  font-weight: bold;
  margin-bottom: 10px;
}

.number-Three
{
    display: grid;
    font-family:Montserrat;
  font-size: 18px;
  color: #c2c2c29f;
  font-weight: bold;
  margin-bottom: 10px;
}

.tasks-text
{
  position:relative;
    display: grid;
    font-family:Montserrat;
  font-size: 18px;
  color: #c2c2c29f;
  font-weight: none;
  text-align: center;
  bottom:4px;
  
}

.achievement-the-starter
{
    position:relative;
    display: grid;
    resize: none;
    height:60px;
    width: 384px;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    background-color: #161616a6;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: hidden;
    overflow-y: hidden;
    left: 10px;
    top: 40px;
}

.thestartertext
{
    display: grid;
    font-family:Montserrat;
    font-size: 20px;
    color: #b92525;
    text-align: center;
}

.achievement-gains
{
    
    position:relative;
    display: grid;
    resize: none;
    height:60px;
    width: 385px;
    padding: 10px;
    margin-bottom: 10px;
    border-radius: 10px;
    background-color: #161616a6;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    overflow-y: auto;
    left: 10px;
    top: 40px;
}

.thegains
{
    display: grid;
    font-family:Montserrat;
    font-size: 20px;
    color: #9b2a2a;
    text-align: center;
}

.achievement-connect
{
    
    position:relative;
    display: grid;
    resize: none;
    height:60px;
    width: 385px;
    padding: 10px;
    margin-bottom: 50px;
    border-radius: 10px;
    background-color: #161616a6;
    white-space: pre;
    overflow-wrap: normal;
    overflow-x: auto;
    overflow-y: auto;
    left: 10px;
    top: 40px;
}

.connect
{
    display: grid;
    font-family:Montserrat;
    font-size: 20px;
    color: #9b2a2a;
    text-align: center;
}


.progress
{
  position:absolute ;
  display:grid;
  width:410px;
  height:15px;
  background: #9b2a2a62;
  border-radius: 40px;
  overflow: hidden;
  bottom:-8px;
}

.progress__fill
{
  width: 20%;
  height: 100%;
  background: #9b2a2a;
  transition: all, 1s;
}


/* ===== Scrollbar CSS ===== */
  /* Firefox */
  * {
    scrollbar-width: auto;
    scrollbar-color: #9b2a2a00 #40404000;
  }

  /* Chrome, Edge, and Safari */
  *::-webkit-scrollbar {
    width: 16px;
  }

  *::-webkit-scrollbar-track {
    background: #40404000;
  }

  *::-webkit-scrollbar-thumb {
    background-color: #9b2d2d;
    border-radius: 10px;
    border: 3px none #ffffff00;
  }

#follow-button
{
    position:relative;
    width:75px;
    height:30px;
    margin-right:6px;
    line-height:0px;
    outline:none;
}

body {
  width: 100%;
  height: 100vh;
  background-repeat: no-repeat;
  background-size: cover;
  background-image: url("https://i.postimg.cc/q78KTSXn/Dark-Mode-Background.png");
  position: absolute;
  margin: auto;
}

#clicks
{
  position:absolute;
    display: grid;
    font-family:Montserrat;
  font-size:18px;
  color: #9d2a2a;
  font-weight: bold;
  text-align: center;
  top:25px;
  left:176px;
  
}

JS

function updateProgressBar(progressBar, value) {
  value = Math.round(value);
  progressBar.querySlector(".progress__fill").style.width = `${value}%`;
}

Var clicks = 0
function clickCounter(){
    clicks += 1
    .document.getElementById.("clicks").innerHTML = clicks + "clicks"}

modules in javascript import

What does it mean when it says like this

import {objectName} from 'object';

does it mean calling the “whole” set (object), so you could use it’s functions? idk.

Because I’ve seen packages that doesn’t need the curly brackets.

please explain like you are explaining to a beginner (which I really am)

Thank you!

How to pass data from client to middleware in uploadthing?

I have the button from uploadthing and i try to pass data by headers to the middleware but i get noting.

the button:

      <UploadButton
        endpoint="imageUploader"
        headers={{
          "X-Custom-Header": "custom-value22222222", // data i test to submit
          data: "test",
        }}

the middleware:

  .middleware(async ({ req }) => {

    console.log('middleware to get test data header:', req) // can't get above headers

    return { userId: user.id};
  })

any ideas? their docs are not fully complete

How do I format plain query to hierarchy json object?

I want to format plain query to hierarchy json to display on front-end but I don’t know how

I may have relational database that has Table called “Todo” which has following column

  1. ID
  2. Name
  3. ParentID

for example

[
    {id: 2, Name:"Task 1.1", ParentID: 1},
    {id: 5, Name:"Task 2", ParentID: null},
    {id: 6, Name:"Task 2.1", ParentID: 5},
    {id: 1, Name:"Task 1", ParentID: null},
    {id: 3, Name:"Task 1.2", ParentID: 1},
    {id: 4, Name:"Task 1.3", ParentID: 1},
    {id: 7, Name:"Task 2.2", ParentID: 5},
    {id: 8, Name:"Task 2.3", ParentID: 5},
    {id: 9, Name:"Task 3", ParentID: null}
]

to

[
  {
    "id": 5,
    "Name": "Task 2",
    "ParentID": null,
    "subtasks": [
      {
        "id": 6,
        "Name": "Task 2.1",
        "ParentID": 5,
        "subtasks": []
      },
      {
        "id": 7,
        "Name": "Task 2.2",
        "ParentID": 5,
        "subtasks": []
      },
      {
        "id": 8,
        "Name": "Task 2.3",
        "ParentID": 5,
        "subtasks": []
      }
    ]
  },
  {
    "id": 1,
    "Name": "Task 1",
    "ParentID": null,
    "subtasks": [
      {
        "id": 2,
        "Name": "Task 1.1",
        "ParentID": 1,
        "subtasks": []
      },
      {
        "id": 3,
        "Name": "Task 1.2",
        "ParentID": 1,
        "subtasks": []
      },
      {
        "id": 4,
        "Name": "Task 1.3",
        "ParentID": 1,
        "subtasks": []
      }
    ]
  },
  {
    "id": 9,
    "Name": "Task 3",
    "ParentID": null,
    "subtasks": []
  }
]

For two level (root and children) my attempt is to push Todo that has no parent ID (root) into an array and then push Todos that have parent into the parent todo

I have tried 2 levels hierarchy and I think it works fine but don’t know how to implement more level in my next.js project and I’m not quite sure this is good practice or not.

here the code I have tried.

const data = [
    {id: 2, Name:"Task 1.1", ParentID: 1},
    {id: 5, Name:"Task 2", ParentID: null},
    {id: 6, Name:"Task 2.1", ParentID: 5},
    {id: 1, Name:"Task 1", ParentID: null},
    {id: 3, Name:"Task 1.2", ParentID: 1},
    {id: 4, Name:"Task 1.3", ParentID: 1},
    {id: 7, Name:"Task 2.2", ParentID: 5},
    {id: 8, Name:"Task 2.3", ParentID: 5},
    {id: 9, Name:"Task 3", ParentID: null},
];

function buildHierarchy(data) {
    let result = [];
    let todos = [...data];

    // construct root level
    todos.forEach((task)=>{
        if(task.ParentID === null){
            const new_task = {...task, subtasks:[]}

            result.push(new_task)
        }
    })

    // constrct child level
    result.forEach((parent, index)=>{
        todos.forEach((task)=>{
            if(task.ParentID === parent.id){
                const new_task = {...task, subtasks:[]}
    
                parent.subtasks.push(new_task)
            }
        })
    })
    
    return result
}

const result = buildHierarchy(data);
console.log(JSON.stringify(result,null,2));

How to “catch all” in NodeJS

I’m building an infra layer that should run “handlers” periodically.
I’m not the one writing the handlers, their logic can vary.
handlers can run concurrently.
I want the infra to provide isolation, i.e. the infra should make sure that a failure, any application-level failure, in one handler, doesn’t effect other handlers running “in the same time”.
Currently, I surrounded every handler run with try-catch, but as it seems, there are many types of errors that when happen, aren’t being caught in the catch clause and thus crashing the service (cause they are running from a different context).
I assume that at the handler level, one can build the handler in such way all errors are handled, and in many places this is what happen. My problem is that if someone “forgot” to handle the error at the handler level, I, as the infra layer, can’t “catch” those errors for him, thus I can’t enforce isolation and make sure failure in 1 handler doesn’t effect others.
What’s the typescript way of handling such case?

A code illustrating the problem is (assume it’s inside an async function):

try {
    await new Promise((resolve, reject) => {
        setTimeout(() => {
            throw new Error('This error is not caught!');
        }, 0)
    })
} catch {
  console.log("the error never gets here");
}

One solution is find, is to listen on the uncaughtException event and handle it there, so to add to my service initialization something like:

process.on('uncaughtException', (err) => {
    console.error('uncaught exception', err.message);
});

This solves it, but i’m not sure if it’s a good practice and in any way i’m lacking context here, but maybe that’s fine.

Is there a better way of achieving what i want?

nextjs: Link element leads to hydration errors

i’m investigating many hydration errors on my page that seem to come from my migration last year from an old next version into the most current 15.x. See Screenshots at the bottom:

Unhandled Runtime Error Expected server HTML to contain a matching <div> in <a>.

and

Uncaught Error: Hydration failed because the initial UI does not match what was rendered on the server.

what i understand from these errors is: the clients current html mismatches what we precalculated on the client side.

which is weird because i used the ‘use client’ statement in the component.

i could nail all of these down into one button component that uses a next/link component. I therefore simplified it as much as possible but no matter how i edit this component, it will throw hydration errors in the console. I tried various ways of no container element, etc:

'use client'
import React from 'react'
import Link from 'next/link'

const ButtonComponent = function () {
  return (
     <button>
      <Link href="/">Button</Link>
    </button>)
}
export default ButtonComponent

however, the moment i get rid of next/link in this situation, all hydration errors are resolved

'use client'
import React from 'react'

const ButtonComponent = function () {
  return (
     <button>
      Button
    </button>)
}
export default ButtonComponent

which is not what i want – this should be a reusable button that gets children and href as props and renders children.

how do i resolve this? Do i have a misconception?

[screenshot of console: Hydration failed]

Handling onClick$ in Qwik with Functions Passed as Props

I’m working on a Qwik component and I’m facing an issue with the onClick$ event handler. I want to pass a function as a prop to the component that handles the click event. However, I understand that Qwik requires onClick$ to use a QRL function for serialization.

I’ve read the documentation on Qwik’s dollar scope and serialization: https://qwik.dev/docs/advanced/dollar/ but I’m still unsure about the best way to approach this situation.

Questions:

  1. What’s the recommended way to handle onClick$ when the button click functionality needs to be passed as a prop to the component?
  2. Are there any potential pitfalls to consider with different approaches?

My Code:


interface ButtonProps {
  type?: "button" | "submit" | "reset";
  variant?: "primary" | "secondary" | "success" | "danger";
  loading?: boolean;
  disabled?: boolean;
  onClick?: () => void;
  style?: string;
}

export default component$<ButtonProps>(
  ({
    type = "button",
    variant = "primary",
    loading = false,
    disabled = false,
    style,
    onClick,
  }) => {
    const handleClick = $(() => {
      if (onClick) {
        onClick();
      }
    });
    return (
      <button
        type={type}
        disabled={disabled || loading}
        onClick$={handleClick}
        class={`${styles.button} ${styles[variant]} ${loading ? styles.loading : ""} ${style || ""}`}
      >
        {loading ? <div class={styles.spinner}></div> : <Slot />}
      </button>
    );
  }
);

Where lint error is happening:

const handleClick = $(() => {
      if (onClick) {
        onClick();
      }
    });

Lint error:*
When referencing “onClick” inside a different scope ($), Qwik needs to serialize the value, however it is a function, which is not serializable.
Check out https://qwik.dev/docs/advanced/dollar/ for more details.eslintqwik/valid-lexical-scope

All possible AI solutions but they keep producing errors

Can this function be called pure?

I think this is a pure function as it abide by the rules to be a pure function.

  1. It always return the same output.
  2. It has no side effects.

But in a medium blog, they said that this is a impure function.

function addNumbers(){
  let num1 = 100;
  let num2 = 1;
  return num1 + num2;
}

addNumbers();

(NOBRIDGE) ERROR TypeError: Cannot read property ‘install’ of null [Component Stack]

I am trying to build an react native app with expo and got stuck herethe terminal log shows that the NOBRIDGE Error

If you understand the problem neglect the below statements:

I am developing a React Native app using Expo, where I aim to integrate an ONNX model for face recognition. The app allows users to pick an image, preprocess it, and run inference using the ONNX Runtime for React Native. However, I am encountering multiple issues during development:

Here is the output i see in the application:

enter image description here

Here is the code i wrote in the index.jsx ~ i replaced index.tsx with jsx:

import React, { useState } from 'react';
import { View, Button, Image, Text, StyleSheet, Platform } from 'react-native';
import * as ImagePicker from 'expo-image-picker';
import { InferenceSession, Tensor } from 'onnxruntime-react-native';
import * as FileSystem from 'expo-file-system';

export default function App () {
  const [imageUri, setImageUri] = useState(null);
  const [output, setOutput] = useState(null);

  // Load the ONNX model
  const loadModel = async () => {
    try {
      const modelPath =
        Platform.OS === 'android'
          ? `file:///android_asset/face_encoder.onnx` // Android path for assets
          : `${FileSystem.documentDirectory}face_encoder.onnx`; // iOS path

      // Load the ONNX model
      const session = await InferenceSession.create(modelPath);
      return session;
    } catch (error) {
      console.error('Error loading model:', error);
    }
  };

  // Process image and run inference
  const processImage = async (session) => {
    if (!imageUri) return;

    try {
      // Convert image to tensor (mocked for simplicity)
      // In practice, preprocess the image (resize to 224x224, normalize, etc.)
      const inputTensor = new Float32Array(3 * 224 * 224).fill(0.5);
      const tensor = new Tensor('float32', inputTensor, [1, 3, 224, 224]);

      // Run inference
      const feeds = { input: tensor };
      const results = await session.run(feeds);

      // Process results
      setOutput(results.output.data);
    } catch (error) {
      console.error('Error processing image:', error);
    }
  };

  const handleLoadImage = async () => {
    const result = await ImagePicker.launchImageLibraryAsync({
      mediaTypes: ImagePicker.MediaTypeOptions.Images,
      allowsEditing: true,
      aspect: [4, 3],
      quality: 1,
    });

    if (!result.canceled) {
      setImageUri(result.uri);
    }
  };

  const handleRunModel = async () => {
    const session = await loadModel();
    if (session) {
      await processImage(session);
    }
  };

  return (
    <View style={styles.container}>
      <Text>Face Recognition App</Text>
      {imageUri && <Image source={{ uri: imageUri }} style={styles.image} />}
      <Button title="Load Image" onPress={handleLoadImage} />
      <Button title="Run Model" onPress={handleRunModel} />
      {output && <Text>Output: {JSON.stringify(output)}</Text>}
    </View>
  );
};

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    alignItems: 'center',
    backgroundColor: '#fff',
  },
  image: {
    width: 200,
    height: 200,
    marginVertical: 20,
  },
});


Here is the app.json:

{
  "expo": {
    "name": "FceDetectionApp",
    "slug": "FceDetectionApp",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/images/icon.png",
    "scheme": "myapp",
    "userInterfaceStyle": "automatic",
    "newArchEnabled": true,
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/images/adaptive-icon.png",
        "backgroundColor": "#ffffff"
      },
      "package": "Face.Files"
    },
    "web": {
      "bundler": "metro",
      "output": "static",
      "favicon": "./assets/images/favicon.png"
    },
    "plugins": [
      "expo-router",
      [
        "expo-splash-screen",
        {
          "image": "./assets/images/splash-icon.png",
          "imageWidth": 200,
          "resizeMode": "contain",
          "backgroundColor": "#ffffff"
        }
      ]
    ],
    "experiments": {
      "typedRoutes": true
    },
    "extra": {
      "router": {
        "origin": false
      },
      "eas": {
        "projectId": "81f38c43-7dd5-4bfc-ad5d-fbb101bd1d3a"
      }
    }
  }
}

Package.json dependencies:

 "dependencies": {
    "@expo/vector-icons": "^14.0.2",
    "@react-navigation/bottom-tabs": "^7.2.0",
    "@react-navigation/native": "^7.0.14",
    "expo": "~52.0.23",
    "expo-blur": "~14.0.1",
    "expo-constants": "~17.0.3",
    "expo-font": "~13.0.2",
    "expo-haptics": "~14.0.0",
    "expo-image-picker": "^16.0.3",
    "expo-linking": "~7.0.3",
    "expo-router": "~4.0.15",
    "expo-splash-screen": "~0.29.18",
    "expo-status-bar": "~2.0.0",
    "expo-symbols": "~0.2.0",
    "expo-system-ui": "~4.0.6",
    "expo-web-browser": "~14.0.1",
    "onnxruntime-react-native": "^1.20.1",
    "react": "18.3.1",
    "react-dom": "18.3.1",
    "react-native": "0.76.5",
    "react-native-gesture-handler": "~2.20.2",
    "react-native-get-random-values": "~1.11.0",
    "react-native-reanimated": "~3.16.1",
    "react-native-safe-area-context": "4.12.0",
    "react-native-screens": "~4.4.0",
    "react-native-web": "~0.19.13",
    "react-native-webview": "13.12.5"
  },
  "devDependencies": {
    "@babel/core": "^7.25.2",
    "@types/jest": "^29.5.12",
    "@types/react": "~18.3.12",
    "@types/react-test-renderer": "^18.3.0",
    "jest": "^29.2.1",
    "jest-expo": "~52.0.2",
    "react-test-renderer": "18.3.1",
    "typescript": "^5.3.3"
  },

disable textbox

<!DOCTYPE html>
<html>
<body>
<form action="/action_page.php">
  <label for="fname">Fname:</label>
  <input type="text" id="fname" name="fname"><br><br>
  <label for="lname">Lname:</label>
  <input type="text" id="lname" name="lname" disabled><br><br>
  <input type="submit" value="Submit">
</form>

<script>
const fname = document.querySelector(".fname");
const lname = document.querySelector(".lname");

lname.readonly = true;
fname.addEventListener("keyup", () => {
if(fname.value.length >0)
{
lname.readonly = false;
}else
{
lname.readonly = true;
}

})

</script>

</body>
</html>

I want to temporarily disable lname textbox because the fname is empty, but if the fname is not empty the lname is enable. I have a code but I don’t think it is correct or wrong, you can visit my code here https://jsfiddle.net/Jayme207/ejks5xqL/12/

Handling Large Decimal Numbers (200+ digits/decimals) in TypeScript: String vs Number and parseFloat() Conversion

I’m working with very large decimal numbers in TypeScript that can have up to 200 decimal places. Currently, I’m storing these numbers as strings to preserve precision.

const largeDecimal: string = "123.456789012345678901234567890..."; // 200+ decimal places

I have two main concerns:

  • Is using string the correct approach for storing such large decimal numbers?
  • In situations where I need to perform calculations, what’s the best way to convert these strings to numbers?
    Should I use Number() or parseFloat()?

// Which approach is better?
const usingNumber = Number(largeDecimal);
const usingParseFloat = parseFloat(largeDecimal);

What I’ve Tried

I’ve attempted both conversion methods, but I’m concerned about potential precision loss:

const sample = "123.456789012345678901234567890";
console.log(Number(sample));     // 123.45678901234568
console.log(parseFloat(sample)); // 123.45678901234568

Questions

  1. Is storing these large decimals as strings a good practice in TypeScript?
  2. What’s the recommended way to handle numeric operations with such large decimal numbers?
  3. Are there any built-in TypeScript/JavaScript solutions, or should I consider using external libraries?

Environment

TypeScript Version: 5.x
Node.js Version: 18.x

Any insights or best practices would be greatly appreciated!

How to refactor very large legacy JavaScript code? [closed]

I have a large JavaScript file with over 20,000 lines of code. The code is organized into objects, with functions like so:

let module1 = {
 fun1:function() {
  console.log("module1 fun1 called");
 },
 fun2:function() {
  module2.fun1();
 },
}
let module2 = {
 fun1:function() {
  console.log("module2 fun1 called");
 },
 fun2:function() {
  module1.fun1();
 },
}

And this pattern continues for other objects. These objects and their functions depend on each other, leading to a lot of circular dependencies. Since everything is currently in a single file, this is not an issue, but I want to refactor this code by separating it into multiple files for better maintainability.

The challenge I’m facing is how to break the code into separate modules without running into circular dependency issues during the refactor. I also need to ensure the structure remains flexible and scalable as I may need to organize modules into sub-modules.

How can I refactor this file?