1.0.0 • Published 4 years ago
@mckennaleo/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 @mckennaleo/lotide
Require it:
const _ = require('@mckennaleo/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
function1(head)
: returns the first element of an arrayfunction2(tail)
: returns the last element of an arrayfunction3(middle)
: returns the middle element of an odd-numbered array, and the two middle elements of an even-numbered arrayfunction4(assertEqual)
: checks if two strings are equalfunction5(eqArrays)
: checks if two arrays are equalfunction6(eqObjects)
: checks if two objects are equalfunction7(countLetters)
: returns an object with each letter from a string as keys, and the number of iterations of said letters as a valuefunction8(countOnly)
: takes an array as a first parameter, an object as the second parameter, returns an object counting the number of times each keys from the second parameter appear in the arrayfunction9(findKeyByValue)
: finds which keys have a designated value within an objectfunction10(findKey)
: returns first key with searched value in objectfunction11(flatten)
: flattens nested arrays one levelfunction12(letterPositions)
: takes a string as a parameter and returns an object with the letters within the string for keys, and the position of each iteration of the letter as a valuefunction13(map)
: takes in an array as a parameter, returns a new array with just the first letter from each string within the first arrayfunction14(takeUntil)
: takes in an array as a first parameter, a string or number as the second. returns a new array formed from the first array, stopping at the first iteration of the secon parameterfunction15(without)
: takes in an array as a first parameter, and an array as a second parameter. returns a new array constituted of every number or string in the first array that didn't also exist in the first
1.0.0
4 years ago