@calvinhwc/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 @calvinhwc/lotide
Require it:
const _ = require('@calvinhwc/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head() - returns the first item in the array.
tail() - returns everything except the firs item (head) of the array.
assertEqual() - will take in two primitive types and will console.log a statement stating whether they match.
eqArrays() - takes in two arrays and returns true or false, based on a perfect match of the contents of the array.
assertArraysEqual() - takes in two arrays and will console.log a satement stating whether they are equal.
without() - will return a subset of a given array, removing unwanted elements.
middle() - takes an array and will take in an array and return the middle-most element(s) of given array. For an input with an even number of elements, this function will return 2 elements. For an input with an odd number of elements, this function will return 1 element.
countOnly() - this function takes an object of items and returns a count for a specific subset of those items. It will only count the specified items.
countLetters() - takes in a string and returns the count of letters in the string.
letterPositions() - takes in a string and returns the index(es) of where the letters are used in the string.
findKeyByValue() - given a value, this function will return the key of where the value is located.
eqObjects() - will test whether the keys and values of the objects are identical. Returns true or false.
assertObjectsEqual() - will take in two objects and console.log a statement stating whether they are equal.
takeUntil() - takes in an array and returns the contents of the array until a specified value in the array.
findKey() - takes in an object, and a value. Returns the key in which the value is located. If no key is found, it will return undefined.
3 years ago