@acooper5259/lotide

my lodash-light personal package

Usage no npm install needed!

<script type="module">
  import acooper5259Lotide from 'https://cdn.skypack.dev/@acooper5259/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 @username/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 fist value of an array
  • tail(array): returns all the remaining values of an array, except the first
  • middle(array): returns middle value(s) of the parameter array once sorted.
  • assertArrayEqual(array1, array2: check for strict equality between arrays, logging out to the console
  • assertEqual(actual, expected): check for strict equality of an actual and an expected value.
  • assertObjectEqual(object1, object 2): check for strict equality between objects, logging out to the console
  • countLetters(sentence): returns an object with individual characters as keys and their count as values
  • countOnly(allItems,itemsToCount: counts through an array for instances of a specific value. Returns an object.
  • eqArrays(array1, array2): returns true or false after evaluating for strict equality between 2 arrays
  • eqObject(object1, object2): returns true or false after evaluating for equality between 2 objects
  • findKey(object, callback): returns the key string for an object value determined by the callback
  • findKeyByValue(object, value): returns the key of an object according to its value
  • letterPositions(sentence): return an object letter/index as key value pairs for a given string.
  • map(array,callback): returns a new array after callback applied to initial array.
  • takeUntil(array, callback): returns an array of values from initial array until callback evaluates to false.
  • without(source, itemsToRemove): returns a shallow copy of an array without the itemsToRemove.