1.0.1 • Published 1 year ago
@eliza504/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 @eliza504/lotide
Require it:
const _ = require('@eliza504/lotide');
Call it:
const results = _.tail([1, 2, 3]) // => [2, 3]
Documentation
The following functions are currently implemented:
- const head = require('./head');
- const tail = require('./tail');
- const middle = require('./middle');
- const countLetters = require('./countLetters');
- const countOnly = require('./countOnly');
- const findKey = require('./findKey');
- const findKeyByValue = require('./findKeyByValue');
- const flatten = require('./flatten');
- const letterPositions = require('./letterPositions');
- const map = require('./map');
- const assertArraysEqual = require('./assertArraysEqual');
- const assertEqual = require('./assertEqual');
- const assertObjectsEqual = require('./assertObjectsEqual');
- const eqArrays = require('./eqArrays');
- const eqObjects = require('./eqObjects');
- const takeUntil = require('./takeUntil');
const without = require('./without');*
const assertArraysEqual = function(actual, expected)
: function takes in two arrays and outputs whether they are equal or notconst assertEqual = function(actual, expected)
: function takes in two values and outputs if they are equal or notconst assertObjectsEqual = function(actual, expected)
: function takes in two objects and outputs whether they are equal or notconst countLetters = function(sentence)
: countLetters takes in function and outputs the number of occurences for each letter within itconst countOnly = function(allItems, itemsToCount)
: function takes in an array of items and returns a count of occurences for all the items that were called in the objectconst eqArrays = function(a, b)
: function takes in two arrays and outputs whether they are equal or notconst eqObjects = function(object1, object2)
: function takes in two objects and outputs whether they are equal or notconst findKey = function(object, callback)
: function takes in an object and outputs the first key that meets the criteria of the callback functionconst findKeyByValue = function(object, value)
: function takes an object and a value and outputs first key that matches the said valueconst flatten = function(fullArray)
: function takes in an array that contains nested arrays and returns a flattened versionsconst head = function(array)
: function returns first index of a given arrayconst letterPositions = function (sentence)
: function takes in a sentence and outputs and object with the positions of each letterconst map = function(array, callback)
: function takes in an array and outputs the results of each index passing through callback functionconst middle = function(array)
: function that returns middle of a given arrayconst tail = function(array)
: function returns the last index for a given arrayconst takeUntil = function(array, callback)
: function that will take an array and loop through it until output matches callback functionconst without = function(itemsArray, itemsToRemove)
: function takes in an array and outputs array after removing selected items