1.0.0 • Published 5 years ago
@armeenhadizadeh/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 @armeenhadizadeh/lotide
Require it:
const _ = require('@armeenhadizadeh/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: head accepts an array and returns the first element of that arraytail(array)
: tail accepts an array and returns the tail of that array(all elements besides first one)middle(array)
: middle accepts an array and returns the middle elements of the array. If the array has an odd number of elements it will return only one element, if it has an even number of elements it will return the two middle elemntsassertEqual(actual, expected)
: will log "🤑🤑🤑Assertion Passed:" if theactual === expected
, and "😡😡😡Assertion Failed:" if theactual !== expected
assertArraysEqual(array1, array2)
: will log "🤑🤑🤑Assertion Passed:" ifarray1 === array2
, and "😡😡😡Assertion Failed:" if thearray1 !== array2
assertObjectsEqual(object1, object2)
: will log "🤑🤑🤑Assertion Passed:" ifobject1 === object2
, and "😡😡😡Assertion Failed:" if theobject1 !== object2
countLetters(string)
: will return an object with the number of occurences of a specific charactercountOnly(allItems, itemsToCount)
: will return an object with the number of occurences of the characters specified in the items to count objecteqArrays(array1, array2)
: checks ifarray1 === array2
eqObjects(object1, object2)
: checks ifobject1 === object2
findKey(obj, callback)
: returns the key that meets the criteria specified by the callback functionfindKeyByValue(obj, value)
: returns the key that contains the specifiedvalue
returns undefined if key does not existflatten(array)
: returns a the given array one level flatterletterPositions(string)
: returns an object with the location of each letter specified in an arraymap(array, callback)
: returns a new array of elements that were modified by the callback functiontakeUntil(array, callback)
: returns a slice of the given array until the specified callback criteria is metwithout(source, itemsToRemove)
: returns a new array with theitemsToRemove
items removed from the source array
1.0.0
5 years ago