Questions tagged [lodash]
A modern JavaScript utility library delivering modularity, performance, and extras.
6,655
questions
0
votes
1
answer
10
views
Remove same property value duplicate from array of objects using Lodash
I have the below array
const values = [
{
name: 'A',
age: 12
},
{
name: 'B',
age: 1
},
{
name: 'A',
age: 31
}
]
and I want using lodash remove an object from this ...
1
vote
1
answer
31
views
Recreate array on basis of object's child
Some time ago I asked a question about how to filter array based on its key today this function but i am working a new implementation that I'm doing.
create array on basis of object's child
But I'...
0
votes
0
answers
9
views
How to use lodash to filter objects by their property or the property of a subobject?
I have an object like this:
{
1234: {
name: 'biscuit-group',
groupMembers: {
9991: {
name: 'ryan'
},
9992: {
name: 'simon'
...
1
vote
2
answers
14
views
Lodash replacement for a JS check operation to set value
I have been using some code to check the value for a input field which is present at index:1 of an array. It is as below
const inputValue=journeyData && journeyData.birthdate && ...
0
votes
0
answers
9
views
Lodash debounce.cancel() doesn't work in usage of hook
Hi I'm trying to use debounce for a simple event, hover.
When MouseEnter debounce func called and if I stay in hover for a 1 sec, callback is called and if I',m not in element(I mean, MouseLeave is ...
0
votes
1
answer
24
views
Lodash isEqual - How to get keys of objects that differ
I'm trying to obtain an array of keys, that were different as a result of comparing two objects. I was only able to do it using isEqualWith and mapKeys, like so:
const differencies = [];
const ...
1
vote
0
answers
16
views
How to use Lodash to denormalize my arrays of objects?
I am trying to use Lodash to split my nested array and create flattened objects. I was able to use pure Javascript to do so, but I would like to use Lodash instead. Is there an easy way to do so in ...
0
votes
0
answers
13
views
Using _.throttle on a function that needs to take different input values
I am coding in Node.js and would like to use lodash's throttle method on an array of axios requests.
I have a process, being run in an AWS lambda function, that receives as input an array of ...
-1
votes
1
answer
34
views
Remove objects if they are duplicated with javascript [closed]
I'm trying to remove duplicated objects if the ids are the same with lodash _.uniqBy.
Or this doesn't have to be a lodash or _.uniqBy, but is this possible?
Also the id value is always dynamic, so ...
-3
votes
1
answer
25
views
I want to replace common data of base array data and temp array,with temp array data to maintain order of temp array in base. Same structure of object
trying to replace base array with data as sorted in temp array which is common, using splice
method to replace at i index with temp data
Same structure of objects are there in array. On basis of temp ...
0
votes
1
answer
35
views
Lodash template validating nested objects?
Im using the template function for lodash and I want to get lodash to throw an error if the nested object property does not exist but it seems that the function only checks the properties on the ...
0
votes
1
answer
27
views
How to group and sort a nested array and keep the original order based on the first occurrence?
I have an array that is flat and already properly ordered. To display it in the UI, I need to sort it, by the placeId, keeping the placeId order, as well as the order of elements in the data property.
...
0
votes
0
answers
20
views
Running into reference error with lodash.template
Edit
I ended up replacing all '$' in the file with '$' and doing the following:
await fsPromises.writeFile(
targetFilePath,
compiledSourceFile({
schemaName: schema.schema_name
})....
0
votes
2
answers
72
views
How to debounce a function that return a Promise? [duplicate]
I have a base async function that returns a Promise
function asyncFoo(): Promise<void> {
return new Promise<void>((resolve, reject) => {
// I'm using here a setTimeout to fake ...
0
votes
0
answers
11
views
How to using lodash to orderBy data which contains nested objdects which they need to have a specific sort
I'm having the following data in the snippet
CodeSandBox Snippet
What I need to achieve as I don't know is how I can sort/order that data in that way the
siteId will be in ascending order and the ...
-1
votes
1
answer
23
views
Sorting the date string in the DD-MM-yyyy format using lodash
have a following function:
listOfTransactions.map(({ tdate='', out='', in='' }) => {
return {
date: '10 Feb 2022',
out: 'AAA
in: 'BBB'
}
})
// Here multiple objects will be returned from ...
0
votes
0
answers
27
views
How to fix lodash vulnerabilities, is there an alternative to lodash?
I'm working on a react project using a lot of lodash functions. The last update of lodash was 2021. Now yarn audit shows a number of vulnerabilities. Also packages like storybook, that use lodash ...
-1
votes
1
answer
65
views
array of objects filter and sum by similar numbers
I have this array of object and I need to get the sum of the amount column that has number greater than 3 and the same first 3 digits.
The object is :
Acc Number Amount
1 -5425
10 ...
0
votes
2
answers
39
views
Merge two array of objects using lodash
I have two arrays of objects called movies and movieDetails:
const movies = [{
movieID: 0,
movieDetailsID: 9,
movieName: "Dragonball Z",
cost: 10
},
{
...
1
vote
1
answer
39
views
pdfMake - how to get each table data group starts on a new page
With the following code: stackblitz here
itemsArray = [
{ id : 'A1', name : 'Name A1'},
{ id : 'B2', name : 'nameB2'},
{ id : 'A3', name : 'nameA3'},
{ id : 'A2', name : 'nameA2'},
...
2
votes
0
answers
22
views
Avoid sorting in groupBy lodash method [duplicate]
I'm working on an array which needs to be grouped, but original order to be maintained. So I tried alternate solutions but still that is not maintaining original array order. Resulting Order should be ...
0
votes
0
answers
28
views
Is possible get attribute value and manipulate tags added by Javascript?
I am trying to integrate an image matcher into a constructor that uses lodash. The builder uses lodash in the live editor and php for the public part. In the public part everything works correctly.
...
0
votes
1
answer
18
views
Create excel-like data structure from JSON object Javascript Typescript
Hi I would like to convert a JSON type of data to CSV or Excel-like data with columns
here is JSON that contains the date name of the product and the price
let products = [
[
{ date: '2022-...
0
votes
3
answers
27
views
lodash Library k- only extract keys
I need a little help.
I need to get an object from the console log and return only his keys using the lodash library, i tried
const ObjLetters = ({value}) => {
return _.findKey({value}) }
...
-1
votes
0
answers
26
views
compare json strings from two arrays of objects, and find duplicate in Javascript
var array1 = [
{
id: 100,
value: 'value',
children: ["string1", "string2","string3"]
},
{
id: 200,
value: 'value',
children: ["string1&...
0
votes
0
answers
27
views
How to compare strings from two arrays of objects, and find duplicate in Javascript
var array1 = [
{
id: 1,
value: 'value',
children: ["string1", "string2","string3"]
},
{
id: 'child2',
value: 'value',
children: ["...
0
votes
0
answers
43
views
Seeking a method to improve the performance of this JavaScript function
I'm currently looping through two folders (Old DB collection & New DB collection) containing multiple JSON files (Up to 7k files), each of which contains an array of objects (Up to 350 objects). ...
0
votes
2
answers
38
views
Lodash groupBy() Method should be in same order as original array
I'm working on an array using groupBy lodash method, here the
original array order does not exist on performing groupBy, is the any
way to regain it after groupBy()
const groupBy from "groupBy/...
0
votes
1
answer
22
views
How to get second duplicate value rather than first value from JSON Array in React JS using lodash? [duplicate]
I am working on one project where I need to remove duplicate values from JSON array object with some specification in react JS. I have tried to remove using _.uniqBy but in the output it took very ...
0
votes
0
answers
57
views
JavaScript : Fastest way to itterate over elements of collection
I am currently pulling data from excel which I then push into an object of array.
I am doing so unsing lodash. My code looks like the following :
Output = [];
_.forEachRight(data, element => {
...
0
votes
1
answer
21
views
Why do we needed pickBy in Lodash when We can use delete operator instead?
I have a small question.
Why do we needed pickBy in Lodash or similar? Just simple with delete operator.
// Input
const source = {
user: {
firstname: "John",
lastname: "Done&...
-2
votes
1
answer
27
views
Is there a better way to refactor this function using the Lodash library?
My goal was to take a list of blogs and find the author with the most blogs returning an object like this { author: String, blogs: Number }. I was successful, but I want to know a better approach to ...
0
votes
1
answer
24
views
Lodash custom orderBy then by
I need to use lodash to implement a custom sort based on classification, then by creation time, with more recently created items with the same classification having a lower index in the array. I'm ...
0
votes
2
answers
32
views
Using only Lodash, how do i isolate an element that occurs the most in an array?
I am currently following a tutorial that covers Lodash and it is prompting me to return this value :
{
author: "Robert C. Martin",
blogs: 3
}
given this array of objects:
const blogs = [...
-1
votes
2
answers
35
views
Access JSON like object properties
I have a return object like so:
Can you tell me how to access its properties?
I have tried many ways with Lodash too. But no luck yet.
Failure attempts:
t.config['type']
pick(t.config, 'type')
0
votes
1
answer
25
views
Shuffle multiple arrays in the same way but with Lodash
I've got two arrays
const mp3 = ['sing.mp3','song.mp3','tune.mp3','jam.mp3',etc];
const ogg = ['sing.ogg','song.ogg','tune.ogg','jam.ogg',etc];
I need to shuffle both arrays so that they come out the ...
-1
votes
3
answers
103
views
Iterate nested array items and, upon the same value of a specific key, collect any other entry value as data of a merger which is grouped by key+value
I have an array that looks like this:
So as a strucutre it would be something like:
[
[
{ classNumber: '2', status: 'A', terms: [] },
{ classNumber: '32', status: 'B', terms: [] }, ...
0
votes
1
answer
31
views
How can I merge my object with the matching keys in the other object without breaking it?
myData: {
name: "",
surname: "",
family: {
mother: "",
father: ""
},
age: ""
}
responseData: {
name: "...
0
votes
1
answer
27
views
Looking for a better way to extract all parents from a tree object into a simple array
Here's a tree sample fetched via Typeorm:
interface Base {
id: string;
name: string;
parent?: Base;
}
const sample: Base[] = [
{
id: "1",
name: "Son",
parent: {...
0
votes
1
answer
143
views
How to match nested object keys with values from array with matching keys in lodash
Sorry for the confusing title. I have the results of a form generated from the ngx-formly library. They are an object with key and value pairs that look exactly like this:
Form Feedback
{
"...
1
vote
1
answer
21
views
Lodash get single array from nested array objects
sorry for the newbie question.
Using lodash, how to get an array with all nested "machineries" entries from this API response ?
{
"areas": [
{
"name": "...
-2
votes
1
answer
43
views
Map javascript object with array using lodash
I am new using lodash and I would like to solve the following scenario in a clean way using lodash instead a for statement.
The array "data" should be used to search in the JS object "...
0
votes
1
answer
26
views
Filtering a complex JSON tree with Deepdash not working
const dataTree = [
{
"name":"PARENT",
"attributes":{
"id":"6989a7d9-5150-49af-8b01-8829035ef83d",
...
-1
votes
1
answer
31
views
Combine one array's values based on duplicate dates
I am trying to solve this and keep getting stuck. I am currently trying to do this with lodash but open to any solution:
EDIT: I've done many searches and the suggested links are not the desired ...
0
votes
3
answers
118
views
Search a deeply nested array to update an object
I have a deeply nested data structure and I am interested in matching a certain value inside my array (and array of arrays) and then pushing some data inside an accompanying array. For example ...
0
votes
3
answers
79
views
How to build a tree from an array of objects?
I have array with data:
const data = [
{ id: 1, type: 'type 1' },
{ id: 2, type: 'type 2', subtype: 'subtype 2' },
{ id: 3, type: 'type 2', subtype: 'subtype 3' },
{ id: 4, type: 'type 2', ...
-2
votes
2
answers
44
views
Restructure data in javascript or lodash
If I wanted to turn this data structure:
time = [
{id: 'actual', summed: 24000},
{id: 'plan', summed: 8000}
]
in the following data structure using JavaScript or lodash, what would be the best ...
-3
votes
3
answers
80
views
Javascript Lodash replace array with another [duplicate]
I'm trying to manipulate an array like this:
data = [
{
"id":"1",
"items":[
{
"title":"item 1"
},
...
-1
votes
1
answer
27
views
Nested object from an array using lodash in typescript
My Data structure reads this
{property: ["a","b"] , value : "somevalue" , comparision : "somecomparison"}
I want to create a object out of it like
{
"...
0
votes
0
answers
23
views
Formatting objects in array from Firebase Database in React Native
I am testing pulling some data form Firebase Database, not sure if I am doing it correctly.
The data is stored like this in a Firebase Database db named "users"
[{
"2022-01-30":...