1.0.0 • Published 1 year ago

@samgiorgievski/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
1 year 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 @samgiorgievski/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): returns first item in array
  • tail(array): returns array that includes everything after the first item in the array
  • middle(array): returns the middle item in array, if even, returns 2 of the middle items
  • assertArraysEqual(array1, array2): compares arrays to check if they are equal
  • assertEqual(actual, expected): compares two values to check if they are equal
  • eqArrays(array1, array2): Returns true if arrays are equal, otherwise false
  • countOnly(allItems, itemsToCount): take in a collection of items and return counts for a specific subset of those items
  • countLetters(string): Input string and return object where key = character, and value = how many are in the string
  • findKey(object, callback): scan the object and return the first key for which the callback returns a truthy value
  • findKeyByValue(object, value): search for a key on an object where its value matches a given value
  • letterPositions(string): return all the indices (zero-based positions) in the string where each character is found
  • map(array, callback): creates a new array populated with the results of calling a provided function on every element in the calling array
  • takeUntil(array, callback): returns a slice of array up until callback value is true
  • without(array, itemsToRemove): takes in array, removes itemsToRemove, and returns new array
  • eqObjects(object1, object2): return true if both objects are equal