1.0.0 • Published 6 years ago

@susanwz/lotide v1.0.0

Weekly downloads
-
License
ISC
Repository
github
Last release
6 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 @susanwz/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented: 1. head(array): takes an array and returns the first value of that array 2. tail(array): takes an array and returns all elements of the array except for the first 3. middle(array): takes an array and returns the element(s) in the middle 4. assertArraysEqual(array1,array2): takes two arrays and prints a message if they equal 5. assertEqual(a, b): takes two variables and prints a message if they equal 6. assertObjectsEqual({object1}, {object2}): takes two objects and prints a message if they equal 7. countLetters("string", {object}): takes a string and an object and returns the count of the values in the string that need to be counted, as indicated by the object. 8. countOnly("string"): takes a string and returns an object with the number of each character in the string 9. eqArrays(array1,array2): takes two arrays and checks if they equal 10. eqObjects({object1}, {object2}): takes two objects and checks if they equal 11. findKey({object}, callback()): takes an object and a callback. Scans the object and returns the first key for which the callback returns a truthy value. 12. findKeyByValue({object}, "string"): takes an object and a string, and returns the key in the object where the string is found 13. flatten(array): takes a nested array and returns it flattened (only one layer) 14. letterPositions("string"): takes a string and returns all the positions of the letters that are in the string 15. map(array,callback()): takes an array and a callback and returns a new array based on the results of the callback function. 16. takeUntil(array,callback()): takes an array and a callback and continues putting together a new array until the callback returns a truthy value 17. without(array1,array2): takes two arrays and returns the first array without any values of the second array