1.0.0 • Published 2 years ago
@stellamaris/stellamaris-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 @stellamaris/lotide
Require it:
const _ = require('@username/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(...)
: retrieves the first element from the arraytail(...)
: retrieves the last element from the arraymiddle(...)
: retrieves the middle element from the arrayassertArraysEqual(...)
: take in two arrays and console.log an appropriate message to the consoleassertEqual(...)
: compares two values it takes in and print out a message if they match or notcountLetters (...)
: takes in a string and returns an object where each unique character encountered in the string is a property of the object and the value for that property/key should be the number of occurrences for that charactercountOnly(...)
: take in a collection of items and return counts for a specific subset of those itemseqArrays(...)
: takes in two arrays and returns true or false, based on a perfect matchletterPositions(...)
: will return all the indices (zero-based positions) in the string where each character is foundmap(...)
: will take in two arguments: an array to map and a callback function; and will return a new array based on the results of the callback function.without(...)
: will return a subset of a given array, removing unwanted elementsfindKeyByValue (...)
: takes in an object and a value. It should scan the object and return the first key which contains the given valuefindKey(...)
: will take in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy valuetakeUntil(...)
: will keep collecting items from a provided array until the callback provided returns a truthy valueeqObjects (...)
: will take in two objects and returns true or false, based on a perfect match; Returns true if both objects have identical keys with identical values.assertObjectsEqual (...)
: will take in two objects and returns true or false, based on a perfect match; Returns true if both objects have identical keys with identical values.
1.0.0
2 years ago