1.0.0 • Published 2 years ago

@nkasim/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
2 years ago

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 @nkasim/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): returns first item in an array
  • middle(array): take in an array and return the middle-most element(s) of the given array.
  • tail(array): returns everything except for the first item (head) of the provided array.
  • assertEqual(actual, expected): compares strings
  • eqArrays(arr1, arr2): takes in two arrays and returns true if they are === equal
  • assertArraysEqual(actual, expected): compares arrays
  • eqObjects(obj1, obj2): take in two objects and returns true if they are === equal
  • assertObjectsEqual(actual, expected): compares objects
  • countLetters(string): takes in a string and returns an object containing letters and their frequency within string
  • letterPositions(sentence): takes in a sentence and returns letters and all their corresponding indices
  • findKey(object, callback): looks for a value that makes the callback function truthy and returns its key, else undefined.
  • findKeyByValue(object, value): iterates through an object and looks for the desired value and returns the key.
  • map(array, callback): takes in an array and applies the callback function to all elements and returns an array
  • without(source, itemsToRemove): Take in an array and remove all instances of items in itemsToRemove.
  • takeUntil(array, callback): Iterate through a list and return a new list of values until the condition of the callback function is met.