1.0.1 • Published 10 months ago
@dafttrash97/lotide v1.0.1
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 @dafttrash197/lotide
Require it:
const _ = require('@dafttrash197/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
assertArraysEqual
: takes in two arrays and console.logs a message if they are a perfect match or notassertEqual
: compares two values and prints out a message telling us if they match or notassertObjectsEqual
: takes in two objects and console.logs a message to the console if they are a perfect match or notcountLetters
: takes in a sentence (as a string) and then returns a count of each of the letters in that sentencecountOnly
: takes in a collection of items and returns counts for a specific subset of those itemseqArrays
: takes in two arrays and returns true or false, based on a perfect matcheqObjects
: takes in two objects and returns true or false, based on a perfect matchfindKey
: takes in an object and a callback and returns the first key for which the callback returns a truthy value, If no key is found, then it returns undefinedfindKeyByValue
: takes in an object and a value and returns the first key which contains the given value If no key with that given value is found then returns undefinedflatten
: takes in an array containing elements including nested arrays of elements, and return a "flattened" version of the arrayhead
: function which returns the first item in the arrayletterPositions
: takes in a string and returns all the indices (zero-based positions) in the string where each character is foundmap
: takes in two arguments, an array to map and a callback function. The function will return a new array based on the results of the callback functionmiddle
: takes in an array and returns the middle-most element(s) of the given arraytail
: function that retruns everything except for the first item of the provided arraytakeUntil
: takes in item in the array and returns a slice of the array with elements taken from the beginning and continues until the callback returns a truthy valueWithout
: returns a subset of a given array, removing unwanted elements