1.0.0 • Published 3 years ago
@sophiejoliver/lotide v1.0.0
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 @sjoliver/lotide
Require it:
const _ = require('@sjoliver/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head
: returns the first element in a given arraytail
: returns a (new) array of all elements in a given array except for the first elementmiddle
: returns the middle element in a given array (returns 2 elements if the array length is an even number)assertArraysEqual
: writes an assertion message to the console when 2 arrays are compared (assertion passes or fails)countLetters
: counts how many instances there are of each unique letter in a given string (returns an object)eqObjects
: checks if 2 objects are equalmap
: iterates over an array and creates a new array with the first value of each element in the first/original arraytakeUntil
: iterates over an array and creates a new array using elements from the original array until a certain condition is met while iterating through original arrayassertEqual
: writes assertion message when 2 (primitive) values are comparedcountOnly
: returns an object containg counts of each item in the given array (when object value is true)findKeyByValue
: takes an object and returns the key when given the valueassertObjectsEqual
: writes assertion message when 2 objects are equaleqArrays
: checks if 2 arrays are equalfindKey
: returns they when given an object and a valueletterPositions
: returns an object where each key is a unique value in the given argument and the value is an array of that key's index (or indices) -- i.e., tells you where in the array each value is locatedwithout
: removes items from a given array and returns a newArray
1.0.0
3 years ago