<commit_before>---
layout: post
title: ES6 functions to use as an alternative to lodash
published: true
---

Lodash is great, we have an article about [most useful lodash functions](http://dev.sebastienlucas.com/lodash-best-of/). But those function are pretty low level. They should be at the level of the language it self javascript. With ES6, javascript got more powerful, so it is time to stop using some of lodash function to use their ES6 equivalent. The advantage is that we could more easily tweak the function for our needs which is not possible with lodash. And get more knowledge and confidence about ES6

### array.reduce instead of _.keysBy

<script src="https://gist.github.com/sinsunsan/4b733d2e03fb77c6bb8cea160fbb8ef7.js"></script><commit_msg>add Object Keys<commit_after>---
layout: post
title: ES6 functions to use as an alternative to lodash
published: true
---

Lodash is great, we have an article about [most useful lodash functions](http://dev.sebastienlucas.com/lodash-best-of/). But those function are pretty low level. They should be at the level of the language it self javascript. With ES6, javascript got more powerful, so it is time to stop using some of lodash function to use their ES6 equivalent. The advantage is that we could more easily tweak the function for our needs which is not possible with lodash. And get more knowledge and confidence about ES6

### array.reduce instead of _.keysBy


<script src="https://gist.github.com/sinsunsan/4b733<PASSWORD>03fb77c6bb8cea160fbb8ef7.js"></script>


### Object.keys instead of _.keys

<script src="https://gist.github.com/sinsunsan/39c3573696e953fe075c317a77590c5a"></script>

{'fraction_non_alphanumeric': 0.07845503922751962, 'fraction_numerical': 0.038020519010259504, 'mean_word_length': 4.639455782312925, 'pattern_counts': {'":': 0, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '979967', 'n_tokens_mistral': 517, 'n_tokens_neox': 475, 'n_words': 211}