Samuel Pouyt
1 min readMar 31, 2019

--

Actually in the example code, I use a class that has a method attachementUrl , that actually generates url from a given object for those attachements.

I wanted to simplify my life and not repeat parameters, therefore I did not want to repeat the call to that method attachmentUrl so I created two curried functions: parsePreview and parseStatic that take as arguments the two values that you are asking about: attachement and size . Size is just an integer attachement is on the other hand an object, which attachementUrl knows how to handle.

Now these functions are called in another function parseAttachments that has many arguments, the first one being item item is an object (a content object, think of it as an article, that has images, documents attached to it etc.)

parseAttachements will iterate over all the properties of that content object, to look for certain properties (that can be given as optional arguments as a list for images and documents . So look when I call parsePreview or parseAttachement I am passing an integer as second parameter, and c.image or v . The first one is the default property for the image object, v is the value which is an object that correspond to a key that has been found in one of the two lists of optional properties ( images and/or documents ).

I hope this makes it clear.

Sam

--

--

Samuel Pouyt
Samuel Pouyt

Written by Samuel Pouyt

Tech Lead/Software engineer. I am currently working on Legal Technologies and Computational Law. I enjoy opera, philosophy nature and literature.

No responses yet