1.0.0 • Published 4 years ago

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(arr): returns the head of the array (the first element)
  • tail(arr): returns and array containing the tail of the input array (every element apart from the head)
  • middle(arr): returns an array containing the middle elements of the input array
  • countLetters(str): returns an object with keys as the characters and values as how many times they occur, does not include spaces
  • countOnly(arr, obj): recieves an array of items and an object defining items to count. Returns an object with keys as the original array items and values of the number of times they occur.
  • eqArrays(arr, arr): recieves 2 arrays and returns true if they are equal and false if they are not
  • eqObjects(obj, obj): recieves 2 objects and returns true if they are equal and false if they are not
  • findKey(obj, func): recieves an object and evaluator function and returns the first key that evaluates to true
  • findKeyByValue(obj, value): returns the key that corresponds to the input value in the object
  • flatten(arr): recieves a nested array and returns the flattened array
  • letterPositions(str): takes a string and returns an object with each character as a key and its values as an array containing each index it exits in
  • map(arr, function): takes in an array and a function to perform on each element, returns the new array
  • takeUntil(arr, func): takes in an array and evaluator function. loops through array and writes each element to a new array until function is true
  • without(arr): takes in an array and an array of items to remove. only writes elements to new array if they are not included in the remove array. returns new array