1.0.0 • Published 4 years ago
@jyxgao/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 @jyxgao/lotide
Require it:
const _ = require('@jyxgao/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual
: compares two input arrays on whether they are identical and prints an appropriate messageassertEqual
: compares two input values on whether they are identicalcountLetters
: counts letter instances in an input string, returns an object with the countscountOnly
: takes in an array of items and an object that specifies which array items to count, outputs an object containing items being counted and how many times they occurred in totaleqArrays
: compares two input arrays on whether they are identicaleqObjects
: takes two objects and returns true or false based on perfect matchfindKey
: finds the first key of a given valuefindKeyByValue
: finds a key by value in an objectflatten
: takes in an array containing array elements, returns a "flattened" version of the arrayhead
: retrieves the first element in an input arrayletterPositions
: takes a string input and produces an object of all its letters (case-sensitive), with an array of indices they have appeared at in the stringmap
: takes in an array and callback function, returns new array after going through the callback functionmiddle
: returns the middle number in an array of odd number of elements; two of the middle numbers in an array of even number of elemetnstail
: retrieves all except the first element of an input arraytakeUntil
: takes in an array and a callback function as argument, returns the elements of the array from the beginning until it reaches the element that satisfies the callback functionwithout
: removes array elements that match the input itemsToRemove array argument, without changing the initial array
1.0.0
4 years ago