1.0.1 • Published 2 years ago
@kethnal/lotide v1.0.1
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 @kethnal/lotide
Require it:
const _ = require('@kethnal/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
head(array)
: return the first item of a given arraytail(array)
: return everything except the first item of a given arraymiddle(array)
: return the middle item of a given array with odd amount of items or return the middle two items of a given array with even amount of itemsletterPositions(string)
: return an object with letters as keys and index positions as values from a given stringmap(array, callback)
: return a new array given some array and the callback function to be applied to ittakeUntil(array, callback)
: returns a new array given some array and a callback function that describes when to stop taking values (starting from index 0)without(array1, array2)
: returns a new array given some array and another array with contents that are meant to be left out of the new array (from some array)countLetters(string)
: returns an object with letters as keys and how often they appear in a given string as valuesfindKey(object, callback)
: returns the first key of a given object that matches requirement given by the callback functioneqArrays(array1, array2)
: returns boolean by checking if 2 arrays are equal
The following functions are coming soon (maybe):
flatten(array)
: returns a new array with no nested arrays given some array with nested arrays (max 1 level of nesting)countOnly(array, object)
: returns a new object given an array and an object with boolean values- true items are added to the new object and the number of their instances in the given array are valuesfindKeyByValue(object, value)
: returns the key of a given object by a given valueeqObjects(object1, object2)
: returns boolean by checking if 2 objects are equal