Sunday 30 December 2018

How can I improve this SCSS parser of mine?

I am working on a little side/pet project of mine. All I am looking to accomplish (at this stage) is grabbing a .scss classes height attribute value, from all project .scss files.I'm using the npm package lineReader to read through the .scss files line by line, then checking to see if that line has the height attribute with indexOf('height') > -1; .This is where I am concerned I'm doing some hacky stuff.With the lines that have the height attributes, I'm grabbing the height value by parseFloat(line.split(':')[1]); which returns just the height value.But part of me has a sinking feeling that there is a better way to get this as a key-pair value, rather than having to do all of that nonsense to simply get the value from the height attribute. I want to be able to modify the height value, eventually. But for right now, I just want to physically get the value, and output it to the console (for testing purposes).​Any thoughts?

Submitted December 31, 2018 at 06:55AM by WebDevLikeNoOther

No comments:

Post a Comment