@chhoukdean/lotide

A mini vesion of lodash which has functions which performs checks or other functions for the purpose of learning

Usage no npm install needed!

<script type="module">
  import chhoukdeanLotide from 'https://cdn.skypack.dev/@chhoukdean/lotide';
</script>

README

Lotide

A mini clone of the Lodash library.

Purpose

BEWARE: This library was published for learning purposes. It is not intended for use in production-grade software.

This project was created and published by me as part of my learnings at Lighthouse Labs.

Usage

Install it:

npm install @chhoukdean/lotide

Require it:

const _ = require('@username/lotide');

Call it:

const results = _.tail([1, 2, 3]) // => [2, 3]

Documentation

The following functions are currently implemented:

  • head(array): Returns the first item in an array.
  • tail(array): Returns everything but the first item in an array.
  • middle(array): Returns the middle function of an array.
  • assertArraysEqual(actual, expected) : Checks if a function that outputs an array is running correctly.
  • assertEqual(actual, expected) : Checks if a function that outputs a basic data type (string, number) is running correctly.
  • assertObjectEqual(actual, expected) : Checks if a function that outputs an object is running correctly.
  • countLetters(word) : Counts the number of lettters in a word.
  • eqObjects(object1, object2) : Checks if two objects are equivalent.
  • findKey(object,callback) : Uses the value to output the first key that with the same value.
  • findKeyByValue(object, value) : Search for a key on an object where its value matches given a value.
  • countOnly(allItems,itemsToCount) : Take in a collection of items and returns counts for a specific subset of those items.
  • eqArrays(array1,array2) : Check if two arrays are equivalent.
  • flatten(array) : Flattens a nested array into one array.
  • letterPositions(setence): Returns an object which outputs the key-value pair of the letter and their index position.
  • without(source,itemsToRemove): Returns an array (source) with specific items removed (itemsToRemove).
  • takeUntil(array, callback) : Returns an array until the callback function returns true.
  • map(array, callback) : Iterate over an array an apply the callback function to each element.