1.0.0 • Published 1 year ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

head(array): Takes an array as input and returns the value of the first item of the array tail(array): Takes an array as input and returns the value of the last item of the array middle(array): Takes an array as input and returns the value of the middle position of the array eqArrays(arr1, arr2): Compares two arrays and then returns true or false eqObjects(obj1, obj2): Compares two objects and then returns true or false countOnly(obj, objItemToCount): It takes in a collection of items and returns counts for a specific subset of those items countLetters(string): It takes in a string of words then returns an object with a number count for each letter. findKey(obj, callback): It takes in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined. findKeyByValue(obj, value): It takes in an object and a value. It loops and then returns the first key which contains the given value. letterPositions(string): It takes in a sentense and return an object with the index of each letter positions map(array, callback): It takes in an array and a callback function where it modifies the input array and returns a new array takeUntil(array, callback): It takes in an array and a callback function where it sets a condition and returns a modified array without(array, itemToRemove): Takes in an array and another array of items to be removed from the original array.