Questions tagged [lodash.js]
A JavaScript utility library delivering consistency, modularity, performance, & extras.
55 questions
1
vote
3
answers
109
views
Javascript: Reducing redundancy of notation nested value
Hello I have this function that looks for nested value 3 levels deep currently
...
0
votes
1
answer
680
views
React debounce using Lodash
I need people who have experience with React to review my code.
I want to make a debounce using Lodash.
import debounce from 'lodash/debounce'
...
0
votes
1
answer
403
views
Find number of times a property has a truthy value in a nested object
I have a nested object and I would like to calculate the number of times the property 'error'. I am able to go n levels deep and find the count. Is there a better solution than mine?
...
1
vote
1
answer
3k
views
Compare two arrays of objects and get the objects based on ids
I have two arrays of objects. One has an id property with a list of ids and the second has an object with a unique id property. I want to filter the ids in the second array with the first list and get ...
0
votes
1
answer
374
views
Efficiently performing multiple nested grouping and mapping in Javascript
I have an array of log objects with log_types and dates, like this:
...
4
votes
2
answers
151
views
5
votes
2
answers
2k
views
Transform an object into another object structure
I've got such an input object, which I should modify in order to use it with some charts library.
...
6
votes
1
answer
222
views
Recursive component JSON configuration builder
My goal here is to make data driven nested forms in React. I've created a function that points to a form configuration JSON, which can contain both components and references to other configuration ...
2
votes
0
answers
127
views
Property typed lodash compose function
Here I created a typed version of lodash flow that offers more specific typing.
I'm curious if this exists in any other library, which optimized in tying any way —...
1
vote
1
answer
531
views
Get an object with null values from an array of nested objects
I have an array of nested objects. How do I get an object with null values using only a particular key in the array of objects?
...
4
votes
1
answer
111
views
Finding optimal mapping patterns that transform relational data into a linear format
I'm trying to upgrade my javascript to be more functional. I have used function composition and curry successful on less complicated code but i'm now running into a point where i'm not sure on how to ...
3
votes
3
answers
104
views
Counting duration values
I have a durations as such:
[{'duration': 3600}, {'duration': 3600}]
And I want the output to be ...
3
votes
2
answers
158
views
Mean by properties in array of objects
I have this array of objects:
...
1
vote
2
answers
121
views
Checking if any competitors have a non-empty name [closed]
Take this:
...
3
votes
1
answer
437
views
Transforming data from an API using Typescript and Lodash
As a front-end developer, I am given the following result from an API, an array of objects that looks like:
...
3
votes
0
answers
412
views
Filter properties and format values if they are currency
The function I've written in Typescript works great, but I'm not convinced that it's the cleanest and most efficient function.
The function takes an object, omits properties found in an array, and ...
1
vote
2
answers
126
views
JavaScript library to notify watchers of changes
Background
Last year, while I was still entering the beginning of Immutability and Pure functions and whatnot I created a library for the community called ...
-2
votes
1
answer
154
views
2
votes
1
answer
106
views
JavaScript function to convert an array to an array of strings (formatted)
Input
categories - an array of categories
[
{ id: 1, title: 'Smartphones' },
{ id: 2, title: 'Laptops' }
]
...
11
votes
2
answers
64k
views
lodash filter array of objects by array of exclude property values
I ran into a scenario, I'll simplify the data to user/project, where I needed to take values like:
...
4
votes
1
answer
4k
views
Create list of objects from an object where the key is properCase using Lodash
I'm trying to create a filtered list of objects where each object in the list has both a label and value property.
First I use .pick to select the key/value pairs ...
3
votes
1
answer
2k
views
lodash get method equivalent in javascript
I wanted to build similar to lodash get method. Where you put the object and key name to get value if exist. I have done this but just wanted to have more better approach. Here is what has been done ...
4
votes
1
answer
118
views
Convert object with 'long.property.name' property to object tree
I want to transform such object from:
foo = {
42: 'foo',
'a.b.c[0].42': 'bar',
'a.b.c[0].43': 'zet',
'a.d.c[0].42': 'baz'
}
To:
...
2
votes
0
answers
117
views
Set manipulation (javascript arrays) using lodash
I'd like a more elegant and readable (if possible using functional programming style) for collection filtering (groupToAdd and groupToDelete collection handling)
Just getting rid of multiple _....
1
vote
1
answer
96
views
Create an array which contains specific values of a specific nested object inside an array
So I have this array of objects, which respectively contain other objects:
...
2
votes
1
answer
113
views
Comparing corresponding elements of two equal-length arrays
I have a helper function I wrote, but it feels like something _.lodash already does or could do if I knew the library better.
...
7
votes
1
answer
105
views
Grouping, merging and mapping with a timetable
I want to create a "timetable" for some shop. It should look like, "days - hours".
I get response from the server in this way:
...
2
votes
1
answer
4k
views
Check deep object property and find duplicate value
I use the following code to find if there is duplicate value in property path:
...
0
votes
1
answer
79
views
Function to ensure that at least one choice is selected
First here is my settings object below. insight, spike and ...
2
votes
1
answer
96
views
Create new array by filter origin array
I'm getting an array and I needed to find a duplicate ID inside:
...
5
votes
1
answer
3k
views
Generating an HTML table with colspan and rowspan from a one-dimensional array
I will be given the following input:
...
3
votes
1
answer
2k
views
Concat a collection's sub arrays and merge their parent
I have an array like this:
...
2
votes
1
answer
517
views
Nested loop to transform MongoDB results
I have the following structure returned from MongoDB:
...
5
votes
1
answer
183
views
Animation Template Method for Snake Game
I have recently finished my first iteration of a template method implementation for a JavaScript canvas animation of the snake game. However, I would love for the community to critique this code and ...
1
vote
1
answer
8k
views
Group similar objects into array of arrays
I have the following code, that groups similar todos into an array of arrays, using lodash (https://lodash.com). Here is a plnkr http://plnkr.co/edit/t4J5bKGjMlQxW2z9Zh7x?p=preview (open your console ...
3
votes
4
answers
13k
views
Calculate percentage with lodash
I have data like:
...
1
vote
3
answers
188
views
Converting an array into an object
I have an array of this fashion:
var arr = ["akira",9248,"padilla",100];
I'm using filter to take the names and the points:
<...
7
votes
1
answer
47k
views
Merging two arrays of objects with different keys/properties [closed]
I have two different arrays:
...
7
votes
1
answer
42k
views
Order array of objects by date property
Here's a function that sorts an array of objects with a dateProp by the date. First it uses moment to convert the Date object to ...
2
votes
0
answers
79
views
Extremely redundant HTML templating
This is horrendous.
I'm using lodash's templating engine for this table. Here's the template for an individual record's row. I've got 5 different table and ...
5
votes
6
answers
64k
views
Generating an array of unique values of a specific property in an object array
Given a table represented as a javascript array of objects, I would like create a list of unique values for a specific property.
...
3
votes
1
answer
558
views
Iterating through a range using lodash/AngularJS and saving data
The code below doesn't seem right to me. The scenario is:
User enters in a "quantity" into a form field.
If the user enters in 5, the loop below should iterate 5 times.
There should now be 5 new ...
2
votes
1
answer
239
views
Data transformation using Lodash in a more readable way
I don't like how transforming the data requires a bunch of nested functions. It's not very readable. Is there a more readable way to do the same transformations in Lodash?
...
0
votes
1
answer
118
views
Filtering/mapping strategies
This is real JavaScript/Lodash code used in a project I'm currently working on, but actually this particular question bothers me quite often regardless of the language. Say, I need to generate some ...
3
votes
1
answer
12k
views
Object deep diff function using Lodash
I'm working on an API testing algorithm within the Postman REST client and I wanted a simple and elegant deep diff function to test my JSON responses. I only have access to Lodash within Postman's ...
11
votes
1
answer
240
views
Hunt the wumpus: Functional JavaScript (Node) with Lodash
I'd like a code review of the following simple implementation of the classic game Hunt the Wumpus
I'm trying to use JavaScript in the most "functional" way. To help me, I'm using lodash and ES6.
<...
7
votes
2
answers
5k
views
"Invert" a JavaScript object hash whose values are arrays to produce a new object hash with keys as the elements of those original value vectors
Background
lodash and underscore have an invert function that takes an object hash and converts it to a new one, which has keys as the input object's values and ...
1
vote
1
answer
2k
views
Lodash chain implementation
I am mainly trying to avoid the nested forEach statements and am trying to move towards a lazy evaluation type solution.
jsFiddle
...
3
votes
4
answers
12k
views
Fill an array of objects with some default object
I have an array of objects. Whatever may be the size of this array, I need to ensure the size of the array as n using a default object.
...
4
votes
2
answers
70
views
Function that groups rows returned from SQL DB
I have a data set returned from an SQL database contained below, as you can see all data remains the same apart from one property, "name_alt".
...