Skip to main content

All Questions

Filter by
Sorted by
Tagged with
5 votes
1 answer
105 views

Converting duplicate JS code into a higher order function

I have a block of code that is re-used and I want to use functional programming to remove this duplication. My code takes an array of items, splits the items into batches of 500 and then does some ...
MSOACC's user avatar
  • 211
3 votes
0 answers
40 views

Decoding request object before use it in an Insert query

I want to decode a request object before use it in an insert query. Request object containes the following JSON body: ...
Karol-Kahn's user avatar
6 votes
1 answer
690 views

“Real world” JSON transformation using Node.js

Background I transformed a non-trivial JSON response that uses arrays into a nested object eliminating some of the original properties inserting a new summary property that is a unique list of ...
Timothy Vogel's user avatar
1 vote
1 answer
113 views

Turning simple Node.JS Postgres query and logging into most-functionally-pure-possible code

After reading "How to deal with dirty side effects in your pure functional JavaScript," I've decided to take something I do on a regular basis ("Original approach" below)—connect to a Postgres ...
rvrabbit's user avatar
  • 113
2 votes
0 answers
45 views

Javascript RPC Call Handles Data and Returns DB Response

I have a service within a larger set of microservices that's handling a RPC call. My function mainly just parses through the request, uses the data to insert data into our MongoDB database, and then ...
abrarisme's user avatar
  • 288
3 votes
3 answers
759 views

Eloquent Javascript exercise: find average age from ancestors array per century

I solved an exercise from the book "Eloquent Javascript". I want to share with you guys the solution. The exercise is from chapter 5. Summing up, I have to find the average age from the ancestors ...
tiagolisalves's user avatar
1 vote
1 answer
94 views

Functional Implementation of Co-prime pairs in array

Program finds the number of pairs of co-primes in an array using functional concepts in Node.js ...
Sanjay Idpuganti's user avatar
1 vote
2 answers
78 views

Getting a string from a range of possible paths

I have a scenario where I need to grab the first occurrence of a string from an object, but only if the match occurs in one of the path's that have been pre-defined. ...
user2627546's user avatar
7 votes
1 answer
416 views

Lightweight JavaScript Math Library

...
stephenlcurtis's user avatar
3 votes
0 answers
43 views

Test Driven Development in JS and Sinon Stub

I am going through some TDD and BDD tutorials which guide one through implementing a simple beverage-ordering system. While I think I understand the material, I am still wondering about some ...
MadPhysicist's user avatar
3 votes
1 answer
121 views

An interesting use of the reduce function to convert tab-delimited data into JSON

I am learning functional programming in JavaScript. This is some code from a video tutorial by funfunfunction. I am particularly concerned about the way the existence of the customer key is checked in ...
antonky's user avatar
  • 133
2 votes
0 answers
98 views

Extracting data for a tag cloud using Lazy.js

I've just started using Lazy.js, which is my first exposure to a "functional style" javascript library. I'm still utterly lost as to which of the hundred different functional javascript libraries to ...
Toadfish's user avatar
  • 295
4 votes
1 answer
81 views

Continuable if error is null

I made a method that I can use to avoid having to handle errors from callbacks. What it does is, call the passed method only if the first argument is null. So essentially it will bypass to the last ...
webjay's user avatar
  • 141