1.0.0 • Published 4 years ago

@katebatrakova/lotide v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
4 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 @katebatrakova/lotide

Require it:

const _ = require('@katebatrakova/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 the array
  • function2(tail): returns the last element of the array
  • function3(middle): returns the middle-most element(s) of the given array
  • function4(without): returns a subset of a given array, removing unwanted elements
  • function5(takeUntil): returns a slice of array with elements taken from the beginning. It will keep collecting items from a provided array until the callback (predicate) provided returns a truthy value. The predicate is invoked with three arguments: (value, index, array)
  • function6(map): returns a new array based on the results of the callback function, which will be called for each element in the array
  • function7(letterPositions): returns all the indices (zero-based positions) in the string where each character is found
  • function8(findKeyByValue): takes in an object and a value. It scans the object and returns the first key which contains the given value. It returns undefined if no key with the given value is found.
  • function9(findKey): scans the object and returns the first key for which the callback returns a truthy value. If no key is found, then it should return undefined
  • function10(eqObjects): takes in two objects and returns true or false, based on a perfect match
  • function11(eqArrays): takes in two arrays and returns true or false, based on a perfect match
  • function12(countOnly):takes in a collection of items and return counts for a specific subset of those items. In order to decide what to count, items we care about are 'truthy' and it will only count those, ignoring the others
  • function13(countLetters): takes in a sentence (as a string) and returns a count of each of the letters in that sentence