1.0.1 • Published 5 years ago

@psran/lotide v1.0.1

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

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(actualArray, expectedArray): compares if two arrays are equal and prints a statement to the console

  • assertEqual(actual, expected): compares if two primitive values are equal and prints a statement to the console

  • assertObjectsEqual(actualObject, expectedObject): compares if two objects are equal and prints a statement to the console

  • countLetters(str): returns an object with each letter within str as a key and the parameter as its count

  • countOnly(allItems, itemsToCount): returns counts for a specific subset of items, given all items and items to count as inputs

  • eqArrays(arr1, arr2): compares two arrays and determines if both are equal in size and if all elements match

  • eqObjects(object1, object2): compares two objects and determins if both are a perfect match

  • findKey(object, callback): scans a given object and returns the first key for which the callback returns a truthy value. If no key is found, returns undefined

  • findKeyByValue(): scans a given object and returns the first key which contains the given value and if no key is is found (based on given value), then it returns undefined

  • flatten(array): returns a single-level array, given an array with multiple arrays inside

  • head(arr1): returns the first element from an array

  • letterPositions(sentence): returns indices in the form of an array, indicating where each character is found, all enclosed within an object

  • map(array, callback): returns a new array based on restults of the callback function

  • middle(array): returns the middle-most element(s) of a given array (input)

  • tail(arr1): returns every other element within an array, except the first (or head)

  • takeUntil(array, callback): returns a "slice of the array with elements taken fromt the beginning" and continues until callback returns a truthy value. Inputs to the function are an array from which the function collects items and the callback from which the function keep collecting until a truty value

  • without(source, itemsToRemove): returns a subset of a given array, removing unwanted elements