1.0.0 • Published 4 years ago

@amblinglea/lotide v1.0.0

Weekly downloads
1
License
ISC
Repository
-
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 @amblinglea/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • head(arr): returns the first element of an array
  • tail(arr): returns an array with the first element removed
  • middle(arr): returns the middle element(s) of an array
  • assertArraysEqual(arr1, arr2): checks if two arrays are equal
  • assertEqual(actual, expected): checks if two numbers or strings are equal
  • assertObjectsEqual(actual, expected): checks if two objects are equal
  • countLetters(string): counts a specified letter in a string and returns the number of times it appears
  • countOnly(allItems, itemsToCount): returns how many instances of each string were found in the array of strings
  • eqArrays(arr1, arr2): checks if two arrays are equal
  • eqObjects(object1, object2): checks if two objects are equal
  • findKey(object, callback): returns the first key for which the callback returns a truthy value
  • findKeyByValue(objectToScan, value): returns the first key which contains a given value
  • flatten(arr): returns a flat array
  • letterPositions(sentence): returns all the indices in the string where each object is found
  • map(array, callback): returns a new array based on the results of the callback function
  • takeUntil(array, callback): return a slice of the array with elements taken from the beginning
  • without(source, itemsToRemove): returns a new array with only those elements from source that are not present in the itemsToRemove array