1.0.0 • Published 5 years ago
@nataliesokolova/lotide v1.0.0
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 @nataliesokolova/lotide
Require it:
const _ = require('@nataliesokolova/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
function1(head)
: returns 'head' (the first element of an array);function2(tail)
: returns 'tail' (elements of an array after the first one);function3(middle)
: returns an array with only the middle element(s) of the provided array. For arrays with one or two elements, it returns an empty array. For arrays with odd number of elements, an array containing a single middle element should be returned. For arrays with an even number of elements, an array containing the two elements in the middle should be returned;function4(eqArrays)
: compares two arrays for a perfect match;function5(assertArraysEqual)
: asserts that two arrays are equal;function6(assertEqual)
: compares the two values it takes in and prints out a message saying if they match or not;function7(assertObjectsEqual)
: takes in two objects and console.logs an appropriate message to the console, based on wether objects are equal or not;function8(countLetters)
: takes in a sentence (as a string) and then returns a count of each of the letters in that sentence;function9(countOnly)
: This function takes in a collection of items and returns counts for a specific subset of those items. It won't count everything. In order to decide what to count, it will also be given an idea of which items user cares about and it will only count those, ignoring the others.function10(eqObjects)
: takes in two objects and returns true or false, based on a perfect match.function11(findKey)
: takes in an object and a callback. It should scan the object and return the first key for which the callback returns a truthy value. If no key is found, then it should return undefined;function12(findKeyByValue)
: takes in an object and a value. It should scan the object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined,function13(flatten)
: takes in an array and if an element in array is a nested array, extracts its elements and returns one array;function14(letterPositions)
: returns all the indices (zero-based positions) in the string where each character is found;function15(map)
: returns a new array based on the results of the callback function.function16(takeUntil)
: returns a "slice of the array with elements taken from the beginning." It should keep going until the callback/predicate returns a truthy value.function17(without)
: filters our data by removing some unwanted items;
1.0.0
5 years ago