Questions tagged [lodash]

A modern JavaScript utility library delivering modularity, performance, and extras.

Filter by
Sorted by
Tagged with
0 votes
0 answers
19 views

Lodash mergeWith not giving desired output using customizer

I'm using lodash with nodejs - function customizer(objValue, srcValue, key) { if (key === 'required' && _.isArray(objValue) && _.isArray(srcValue)) { return _.intersection(...
fidato's user avatar
  • 719
-1 votes
1 answer
25 views

How does group by nested array with parent and child?

I have problem with array JSON. I think it nested group by the first is group by _id and second one is group by itemId I do not know how to solve it,Please help me let data=[ { "_id" ...
phan chanra's user avatar
0 votes
0 answers
23 views

How to fix an error on installing packages like lodash and stong-docs in React?

I got a lot of errors installing packages in my React project. I got a lot of errors related to lodash and strong-docs. node_modules/@types/lodash/common/object.d.ts:2448:43 - error TS1005: ';' ...
user18528865's user avatar
0 votes
0 answers
54 views

Omit values with typescript when both are the same in the object

I would like to achieve result of only unique values in object2 and tell also to typescript to omit those keys from T: const diff = <T extends {}>(object1: T, object2: T) => { const ...
Bruce Lee's user avatar
0 votes
0 answers
16 views

Getting type error when using lodash's curryRight with mapValues

I am trying to create a curried function of Lodash's mapValues. const curried = curryRight<{ foo: string }, { foo: boolean }>(mapValues)(value => !!value); curried({ foo: 'bar' }); // { foo: ...
Spencer Carney's user avatar
0 votes
1 answer
51 views

Can I map one object type to another dynamically by return type?

I would like to achieve dynamic value mapping from: type A = { name: string; age: number; dictionary: { type: 'Dictionary'; id: string; name: string } } to: type B = { name: string, age: number; ...
Bruce Lee's user avatar
0 votes
4 answers
117 views

How to access nested object within 2 arrays using Javascript

I'm having problems getting the nested car values using javascript (lodash). Here is the JSON. { "cars":[ { "nestedCars":[ { "car":"...
Sunny's user avatar
  • 147
0 votes
1 answer
38 views

Calculating Weight For Height Zscore

So I am trying to create a React function that calculates Weight For Height Zscore. Here is an example of my code: calcWeightForHeightZscore(weightForHeightRef, height, weight) { let refSection; ...
jonathan's user avatar
0 votes
1 answer
17 views

Can't install redux-mock-store: 404 Not Found - GET lodash.isplainobject

I am trying to install redux-mock-store using npm. I am using node 16.10.0. But, I keep getting this error: npm ERR! code E404 npm ERR! 404 Not Found - GET https://packagecloud.io/github/git-lfs/npm/...
AG_HIHI's user avatar
  • 1,743
0 votes
0 answers
34 views

Using lodash debounce in react on input change

I'm using a service to get address details but im having difficulty using debounce, I'm not sure I'm doing it correctly. I would like to make 2 API requests, when the user types into the input field ...
David R's user avatar
  • 193
0 votes
0 answers
32 views

Organize index of form fields

I'm trying to think of a function that helps me organize the custom positioning of fields within a form structure, but I'm not succeeding. If anyone has any ideas, I would be grateful. This sandbox ...
Gabriel's user avatar
  • 257
0 votes
0 answers
52 views

How to update Apex Chart data via dropdown selection

I'm trying to grasp an understanding of how to change data in Apex Chart from a dropdown selection in Bootstrap vue. This code pen link shows that the bar chart works fine with a simple dataset of ...
Sunny's user avatar
  • 147
0 votes
0 answers
31 views

Typescript with Lodash, Why allow to input wrong key name to function?

I used typescript with lodash, for example _.OrderBY. I found TS allow us to put wrong key to lodash's function. import _ from "lodash"; interface Data { name: string; age: number; } ...
NeungVir's user avatar
0 votes
0 answers
12 views

Preferred way to handle reinitialise of debounce(lodash) timer before timer limit is crossed

In react, preferred way to handle reinitialise of debounce timer, if the event triggers it again before timer ends. should it be used using usecallback like this: const debouncedHandler = useCallback( ...
Raj's user avatar
  • 1,099
-1 votes
3 answers
72 views

Need help optimizing a loop of merging objects and arrays

heres a working example of what I'm trying to do: private mergeData(dataArray) { const mergedData = { items: [], money: { money1: 0, money2: 0, money3: 0, ...
adame21's user avatar
  • 143
0 votes
1 answer
44 views

Managing Cart Updates with React and Debouncing

I'm currently working on an e-commerce application using React, and I'm having issues managing cart updates when users add or subtract the quantity of items in their cart. At the moment, I'm sending ...
Badrudin's user avatar
1 vote
1 answer
44 views

Filter deep nested array by list of rules with JS/lodash

A have a deep structure of statement delivery forms. Each form has own formats and each formats has their own frequency. const forms = [ { value: "1", label: 'Email', ...
Vít Paník's user avatar
0 votes
1 answer
46 views

Lodash debounce is not working in react js

I'm trying to search for a product from my database and using lodash's debounce to send request after a certain time. The problem I'm facing is that the request is going after the specified time only ...
Srivatsa's user avatar
  • 106
0 votes
2 answers
108 views

How to deal with debounced input in Cypress tests?

What is the recommended approach for dealing with a debounced input in Cypress E2E tests. For example, let's assume I have the following component that uses lodash/debounce import React, { useState, ...
George Eracleous's user avatar
0 votes
0 answers
35 views

How to ensure the interval between two requests reaching the server while using Lodash Throttle?

When using the throttle function in lodash, I encountered a situation where it is necessary to ensure a sufficient time interval between two network requests. Due to network latency, two requests ...
yuzhian's user avatar
2 votes
1 answer
41 views

What is the point of Lodash's `_.ary` function?

What is the point of Lodash's _.ary function? The example given is... _.map(['6', '8', '10'], _.ary(parseInt, 1)); ... and I can see that this is helpful because map calls the callback function with ...
Daniel Schilling's user avatar
1 vote
1 answer
66 views

Group responses from 2 arrays based on a common id using lodash

I have 2 arrays one having the Group info and the other having Field info. I want to combine these 2 arrays to create proper Grouped Fields. The API response looks like { "type1": [ { ...
Dhruv Pandey's user avatar
0 votes
0 answers
63 views

Vitest mock doesn't mock modules

I have this simple example where I want to modules in test cases but vi doesn't mock and returns the original function. I'm using vite "vite": "^3.2.0", "vitest": "^...
Nick's user avatar
  • 2,868
1 vote
0 answers
40 views

Why is lodash _.get(jsonObject: JsonObject, path: "somePath") behaving differently after update?

I'm trying to update some CDK that's in Typescript (as part of migrating from CDK v1 to v2). I updated a bunch of typescript and node dependencies, as well as AWS-specific dependencies, but I have a ...
CustardBun's user avatar
  • 3,517
1 vote
1 answer
73 views

Lodash debounce only delays for first call

I have an input box where the user can manually enter the quantity and also plus(+) minus(-) signs so that they can add/remove by clicking on the plus or minus signs. What I am trying to achieve is ...
Rinael's user avatar
  • 155
0 votes
1 answer
34 views

I am trying to add null value based on joi schema

basically i have a joi schema, it can vary, i am trying to create a generic solution, example: const templateSchema = Joi.object({ studentData: Joi.object({ addr: Joi.object({ ...
jos j's user avatar
  • 51
0 votes
1 answer
63 views

Why do sites that use lodash or underscore not work in Opera?

For whatever reason, some update in Opera has caused me to get frustrated for about a week now trying to figure out why Opera no longer works on my productivity sites - like StreamTime or Elementor (...
hazrpg's user avatar
  • 491
-1 votes
1 answer
53 views

Deep search list of objects with hierarchy

I have array of objects like this: let items: MenuPath[] = [ { title: "Archive", path: 'archive' }, { title: "About", path: 'about' }, { title: &...
AlT's user avatar
  • 55
1 vote
0 answers
56 views

Debouncing in JS causes flickering in the component

I have a component where debounce is added for the onChange of an input component. This input component only takes numbers as input. While entering decimal value there is a flicker in the component. ...
Apoorva Ojha's user avatar
0 votes
1 answer
70 views

Grouping objects js [duplicate]

I'm just learning and I can't group the object I need to group objects by the "product" field and filter by the "product" field in the "keyResults" and "metrics"...
darfil's user avatar
  • 21
0 votes
1 answer
36 views

lodash groupBy is a long sync operation starving all other async operations

I'm using lodash group by on a large array, The operation takes a few minutes, which is starving all other async promisees (since we aren't releasing the context) Does anyone have suggestions to use a ...
Ella's user avatar
  • 75
0 votes
1 answer
83 views

React Native with Lodash Debounce: useCallback or useMemo

I made a composant that run a search to an API once the text changes with lodash's debounce. I made it works either by using useCallback and useMemo but I can't understand the differences (advantages/...
Brice's user avatar
  • 786
0 votes
1 answer
38 views

Referencing another interface in a interface when using lodash groupBy method in typescript

I have a database model interface User. I want to fetch all users and store them in a key-value pair with groupBy() from lodash like this: const users: {[_id: string]: User} = _.groupBy(await db.Users....
Rifat Bin Reza's user avatar
1 vote
2 answers
45 views

Is there a Javascript/Lodash function to check if an object is missing ANY properties?

I want to check a javascript object to see if any of it's properties are missing without checking each property individually. I can use "hasownproperty" or do if/else statements to check if ...
Laura Drill's user avatar
1 vote
5 answers
94 views

Average time-series arrays of different length given the same timestamp in Javascript

I would like to average several time-series arrays of different length using Javascript in an efficient manner. The reason for having different length is because some data is missing in some of the ...
Gabriel's user avatar
  • 525
0 votes
1 answer
86 views

Dependabot cannot update lodash.template to a non-vulnerable version

I need help to resolve a GitHub vulnerability issue in dependabot. While doing scan in dependbot I get errors: [email protected] requires lodash.template@^3.0.0 via [email protected] @sxa/celt@...
pratik's user avatar
  • 100
0 votes
1 answer
67 views

How to deal with searching strings and array of strings in JS

_.get(params, "_q") outputs either string or array of strings. On my current code, when I type for example "hello, there", it translates to array of strings and as a result is says ...
Joseph's user avatar
  • 7,116
0 votes
2 answers
52 views

How can I get lodash orderBy to sort list of items using select element in React?

I am trying to use a select element to set internal state to either 'ascending' or 'descending'. Once the state is set, I would like to use that state value to conditionally sort A-Z or Z-A with ...
jonteal's user avatar
-2 votes
2 answers
45 views

Find the number of undefined properties in an object with Lodash

let x = { "name": undefined, "value": "tr", "prop1": undefined, "prop2": "test", "prop3": 123 ...
sarsnake's user avatar
  • 26.9k
0 votes
0 answers
57 views

Maximum update depth exceeded inside socket callback

Im getting the error "Maximum update depth exceeded" using the following implementation: export type InstrumentDetailBaseState = | BaseState | { type: 'success'; detail: ...
Jesús Manuel Ramos Juárez's user avatar
0 votes
1 answer
97 views

How to update Lodash to 4.17.21 to 4.17.20 in angular

when i tried npm update lodash, it is giving error as shown in below image errorenter image description here please help on this. getting this on npm ls lodash @angular-devkit/[email protected] | +...
aquib manzar's user avatar
0 votes
1 answer
60 views

Cypress - Click on several elements with same selector without using {multiple:true} [duplicate]

I have 10 elements with the same selector and I want to click on 5 of them. The {multiple:true} option clicks on all elements. Tried to use lodash with Cypress._.times() but it also returns Cypress ...
Martiross Sedrakyan's user avatar
0 votes
3 answers
89 views

Convert object with single entry to array in Lodash

I'm using lodash to transform a response from a GraphQL. What I've is the following structure: [[ { nodes: [ {}, {} ] }, { nodes: [ {}, {} ] }, { nodes: [ {}, {}, {} ] }, { nodes: [ {}, {}, {} ...
Nrgyzer's user avatar
  • 843
0 votes
1 answer
322 views

How to seed lodash random number generator?

How can I seed the lodash rng so that the random choices for the shuffle function are reproducible? E.g. import _ from 'lodash' console.log(_.shuffle([1,2,3,4])) Run #1 output: [1,3,4,2] Run #2 ...
goastler's user avatar
  • 245
0 votes
0 answers
69 views

Define JavaScript-Class Function outside of class

I have a class called Conv. (Code at the end) It's for converting Objects via the run Function. In the "real" version there is also a runInverse() for simplicity reasons it's left out in ...
Solon's user avatar
  • 101
0 votes
0 answers
134 views

@types/lodash leads to compilation errors

In a command line Node.js app, trying to compile npx ts ... a TypeScript file after installing lodash and @types/lodash: { "dependencies": { "@types/lodash": "^4.14.195&...
porton's user avatar
  • 5,328
0 votes
2 answers
71 views

How to properly replace value of an object in an array and sort it by that value

I want to change priority of a draggedItem with a priority of a targetItem. If they are the same, they should be updated correctly (draggedItem should get priority of targetItem and targetItem ...
Boky's user avatar
  • 11.7k
0 votes
1 answer
47 views

_lodash, sort by 2 fields(numbers, time)

I have an array of object with data: items = [ { ....someFields timeFrom: { hour: 17, minute: 15 } }, { ....someFields timeFrom: { hour: 12, ...
Arams's user avatar
  • 179
0 votes
2 answers
95 views

Flatten complex object/nested object in Typescript

I would like to flatten an object in Typescript. I have tried using lodash flatMapDeep, but get an endless loop. { "extensionId": 1, "assetId": 1996323923, &...
Conrad Addo's user avatar
1 vote
1 answer
822 views

TypeScript 5.1.3 Type errors with lodash (Type instantiation is excessively deep and possibly infinite)

I have just updated my Ionic/Angular project to Angular 16.1.3, and, more relevant here TypeScript 5.1.3. I also have "lodash-es": "^4.17.21", "@types/lodash": "^...
peterc's user avatar
  • 7,163

1
2 3 4 5
140