1.0.0 • Published 4 years ago

@vbedardl/lotide v1.0.0

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • function tail([array]): return the tail of the array as an array (the array minus the first element)
  • function head([array]): return the head of the array as an array (the first element of the array)
  • function middle([array]): return the middle of the array as an array. 1 element when the array's length is odd, 2 element when the length is even
  • function countLetters(string): return an object with each letters from the string and their count. "LOL" => {L:2, O:1}
  • function countOnly([arrayOfItems], {objectOfItemsToCount}] ): return an object with the element to count and their count in the given array of items
  • function eqArray([array1], [array2]): return true if the two arrays are identical
  • function eqObject({obj1}, {obj2}): return true if the two objects are identical
  • function findKey({obj1}, callback): return the value given a key from a defined object
  • function findKeyByValue({obj1}, string): return the key given a value from a defined object
  • function flatten([array1]): return a flatten array from an array with nested arrays
  • function letterPositions(string): return an object with letters and their position from a given string
  • function map([array], callback): create a map function. given an array of element and a callback
  • function takeUntil([array], callback): return the elements of an array up to a breaking point, defined by the callback
  • function without([array1], [array2]): return array1 without the element of array2
1.0.0

4 years ago