1.0.0 • Published 1 year ago
@samgiorgievski/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 @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 arraytail(array)
: returns array that includes everything after the first item in the arraymiddle(array)
: returns the middle item in array, if even, returns 2 of the middle itemsassertArraysEqual(array1, array2)
: compares arrays to check if they are equalassertEqual(actual, expected)
: compares two values to check if they are equaleqArrays(array1, array2)
: Returns true if arrays are equal, otherwise falsecountOnly(allItems, itemsToCount)
: take in a collection of items and return counts for a specific subset of those itemscountLetters(string)
: Input string and return object where key = character, and value = how many are in the stringfindKey(object, callback)
: scan the object and return the first key for which the callback returns a truthy valuefindKeyByValue(object, value)
: search for a key on an object where its value matches a given valueletterPositions(string)
: return all the indices (zero-based positions) in the string where each character is foundmap(array, callback)
: creates a new array populated with the results of calling a provided function on every element in the calling arraytakeUntil(array, callback)
: returns a slice of array up until callback value is truewithout(array, itemsToRemove)
: takes in array, removes itemsToRemove, and returns new arrayeqObjects(object1, object2)
: return true if both objects are equal
1.0.0
1 year ago