1.0.0 • Published 3 years ago

@tripeee/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
3 years ago

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 @tripeee/lotide

Require it:

const _ = require('@tripeee/lotide');

Call it:

const results = _.tail([1, 2, 3]) // => [2, 3]

Documentation

The following functions are currently implemented:

  • head(array) : returns the first element of an array
  • tail(array) :returns the last element of an array
  • middle(array) : returns a single middle element of an array if the array length is odd, and the two middle element of an array of the length is even
  • assertArraysEqual(array1, array2) : verifies that the two passed arrays are equal in both length and value
  • assertEqual(actual, expected): verifies that the two values passed are identical
  • assertObjectsEqual(actualObject, expectedObject) : verifies that the two passed objects are identical
  • countLetters(str : checks the frequency of letters in a string and pushes those values into an object
  • countOnly(allItems, itemsToCount) :checks the frequency of certain values in an array, with itemsToCount being an object whose values have boolean values. Only counts those keys that have true values.
  • eqArrays(array1, array2) : prints an assertion to the console whether two arrays are equal or not
  • eqObjects(object1, object2) : checks whether or not two objects are equal
  • findKey(obj, callback) : scans the object and returns the first key for which the callback returns a truthy value.
  • findKeyByValue(obj, str) : scans the object and returns the first key which contains the given value. If no key with that given value is found, then it will return undefined.
  • flatten(arr) : takes in an array containing elements including nested arrays of elements, and returns a "flattened" version of the array
  • letterPositions(string) : returns all the indices (zero-based positions) in the string where each character is found
  • map(array, callback) : will loop through an array and return a new array with all callback items of the initial array
  • takeUntil(array, callback) : The function will return a slice of the array with elements taken from the beginning until it hits the callback, which will be a value in the array
  • touchOnly(allItems, itemsToCount) : will report back how many instances of each string were found in the allItems array of strings.
  • without(source, itemsToRemove) : will return a new array with only those elements from source that are not present in the itemsToRemove array.
1.0.0

3 years ago