A mini clone of the Lodash library.
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.
Install it:
npm install @khnrv/lotide
Require it:
const _ = require('@khnrv/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
The following functions are currently implemented:
Function that takes in two arrays and print out if they match or not
Param | Type | Description |
---|---|---|
actualArray | array |
Array to test |
expectedArray | array |
Array expected |
Compare two value and print out if they match or not
Param | Type | Description |
---|---|---|
actual | * |
Enter the variable to test |
expected | * |
Enter the expected value of the variable |
This function compares two objects and print out if they match or not
Param | Type | Description |
---|---|---|
actual | * |
Enter the object to test |
expected | * |
Enter the expected object |
This function takes in a sentence (as a string) and then return a count of each of the letters in that sentence.
Param | Type | Description |
---|---|---|
stringToCount | string |
Sentece to count (only alphbetical characters will be counted) |
Function, given an array and an object, return an object containing counts of everything that the input object listed.
Param | Type | Description |
---|---|---|
allItems | array |
an array of strings that we need to look through |
itemsToCount | object |
an object specifying what to count |
Function that takes in two arrays and returns true or false, based on a perfect match.
Returns: boolean
- Return whether the arrays are identical
Param | Type | Description |
---|---|---|
firstArray | array |
- |
secondArray | array |
- |
This function takes in two objects and returns true or false, based on a perfect match.
Returns: True if both objects have identical keys with identical values. Otherwise you get back a big fat false!
Param | Type |
---|---|
object1 | object |
object2 | object |
This function takes in an object and a callback. It scans the object and returns the first key for which the callback returns a truthy value. If no key is found, then it returns undefined.
Param | Type |
---|---|
object | object |
callback | callback |
This function scan a given object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined.
Param | Type |
---|---|
objectToSearch | object |
valueToFind | * |
This function will take in an array containing elements including nested arrays of elements, and return a "flattened" version of the array.
Param | Type | Description |
---|---|---|
arrayToFlatten | array |
Array to flatten |
Output the value at index 0 of a given array
Returns: *
- Value at index 0 of the input array
Param | Type | Description |
---|---|---|
inputArray | array |
Input an array to find its head |
This function returns all the indices (zero-based positions) in the string where each character is found.
Param | Type | Description |
---|---|---|
sentence | string |
Sentence where to count letters |
This function creates a new array populated with the results of calling a provided function on every element in the calling array.
Param | Type | Description |
---|---|---|
arr | array |
Array to map |
callback | callback |
Edit parameters |
This function takes in an array and return the middle-most element(s) of the given array.
Returns: array
- - Middle element(s) of the given array
Param | Type | Description |
---|---|---|
arrayToAnalyse | array |
Array where to find the middle element(s) |
For a given array, returns everything except for the first item (head).
Returns: - Returns a copy of the array without the first item (head)
Param | Type | Description |
---|---|---|
inputArray | array |
Input the array for which you want to return the tail |
This function keeps collecting items from a provided array until the callback provided returns a truthy value.
Kind: global function
Param | Type |
---|---|
array | array |
callback | callback |
This function take in a source array and a itemsToRemove array. It return a new array with only those elements from source that are not present in the itemsToRemove array.
Returns: array
- New array with only those elements from source that are not
present in the itemsToRemove array
Param | Type | Description |
---|---|---|
arrayToEdit | array |
Array where to remove element from |
itemsToRemove | array |
Array of elements to remove from the arrayToEdit |