1.0.0 • Published 3 years ago
@nolelle/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 @nolelle/lotide
Require it:
const _ = require('@nolelle/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
- head(arr): returns the first element of the array
- middle(arr): returns the middle element of the array (returns an array of two numbers if the input array length is even)
- tail(arr): removes the first element of the array
- countLetters(str): counts the number of occurences of each character given a string
- countOnly(allitems, itemsToCount): given an allItems array, and an itemsToCount object, returns an object with the value true/false if the item in itemsToCount is present in allItems
- eqArrays(arr1, arr2): returns true if two arrays are equal else false
- eqObjects(obj1, obj2): returns true if two objects are equal else false
- findKey(obj, callback): returns a key in the obj given a callback function with a conditional
- findKeyByValue(obj, val): returns the first key in the obj that matches the val input
- flatten(arr): flattens a nested array letterPositions(str): returns an array of indices for each char in the string
- map(arr, callback): changes the array given a callback function *tailUntil(arr, callback): returns part of the array depending on the callback conditional
- without(source, itemsToRemove): removes items in source given an itemsToRemove array
1.0.0
3 years ago