1.0.0 • Published 5 years ago

@cmastel/lotide v1.0.0

Weekly downloads
2
License
ISC
Repository
github
Last release
5 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 @cmastel/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • countLetters(stringToCount): counts the number of letters in a string, ignoring spaces
  • countOnly(allItems, itemsToCount): returns an object that contains the number of occurences of values in an array
  • findKey(object, callback): scans an object and returns the first key for which the call back returns a truthy vale
  • findKeyByValue(object, value): loops through an object and returns the first key with the desired value
  • flatter(array): takes a nested array, and flattens it into a single layer array
  • head(array): returns the first element of an array
  • letterPositions(sentence): returns an object that contains the index of each letter in a sentence
  • map(array, callback): loops through each element of any array, and creates a new array based on the callback funtion
  • middle(array): returns the middle element of an array, or an array of the two middle values if the array length is even
  • tail(array): returns an array containing every element other than the first of the provided array
  • takeUntil(array, callback): will return a slice of an array with elements from the beginning, until when the element returns a truthy value from the callback function
  • without(source, itemsToRemove): returns an array without the specified items from the provided array