1.0.0 • Published 2 years ago
@erick_nuque/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 @username/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertEqual(actual, expected)
: Compare the two values it takes in and print the message if they match or notassertArraysEqual(arr1, arr2)
: Compare the length of two arrays - prints out true if the arrays are of the same length or notcountLetters(string)
: Return a count of each of the letters in the string - used to assertEqual function to testcounOnly(allItems, itemsToCount)
: Loop thru the 'allItems' and return number of count for the that specific items (itemsToCount) - return if true if match or not using the assertEqual function - used to assertEqual function to testeqArrays(arr1, arr2)
: Compare the two given arrays - return true if they are of the same length property otherwise returns false - used to assertEqual function to testfindKey(object, callbackFunc)
: Iterate in an object and return the first key the callback function returns a truthy value - used to assertEqual function to testhead(firstItem)
: Return the first item in a given array - used to assertEqual function to testindex
: List of all the functionmap(arr, callback)
: Return a new array based on the results of the callback function - used eqArrays functionsmiddle(array)
: Return the element in a given array, if the length of the array is even, the middle element will the average of the two middle element - used to assertEqual function to test - used eqArrays functions and assertEqual funstionstail(array)
:Returns the tail of an array - everything except for the head of the array - used assertEqual funstionstakeUntil(array, callback)
: Returns the slice of the array with elemets taken from the beginning - it should keep going until the callback returns a truthy valuewithout(source, itemsToRemove)
: Returns a subset of a given array - removing unwanted elements - used eqArrays functions and assertEqual funstions
1.0.0
2 years ago