1.0.0 • Published 3 years ago

@idiljei/lotide v1.0.0

Weekly downloads
1
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 @username/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(array): Given an array, it returns the first element
  • middle((array): returns middle element of array - If array is even, returns both middle ones, if odd returns the middle one
  • tail(array): Returns the last element of an array
  • takeUntil(array): given an array and callback function, returns all elements up to a match
  • without(array, array): returns new array when given an exclusion list that doesnt have excluded elements
  • countLetters(string): when given a string, returns object with the number of occurence for each
  • countOnly(allItems, itemsToCount): Given an object and list of values, it returns number of occurences for each
  • eqArrays(array1, array2): Checks if both arrays are the same
  • eqObjects(object1, object2): Checks if both objects are the same
  • letterPositions(string): Given a string, returns object with an array of positions for each
  • findKey(object, callback): Given a object and callback, it returns the key associated with it
  • findKeyByValue(obj,val): Given a object and callback, it returns the key associated with it
  • map(array, callback): Given an array and callback function, returns an array with callback applied