Skip to content

Forzafonz/lotide

Repository files navigation

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 agolubin/lotide

Require it:

const _ = require('agolubin/lotide');

Call it:

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


Documentation

The following functions are currently implemented:

  • head(array): retruns the first element of array passed to the function;

  • tail(array): returns all elements of array except the first one. If there are less than 2 elements in the array, it returns [];

  • middlearray: return middle elements of array. If an array has an even number of elements the function return two middle elements of the array;

  • without(source, itemsToRemove: returns a new array with only those elements from source that are not present in the itemsToRemove array;

  • takeUntil(array, callBack function: returns a slice of the array with elements taken from the beginning. The function will be going until the callback/predicate returns a truthy value;

  • map(array, callBack function: returns an array with callBack function applied to each element of the array;

  • flatten(array): returns an array without nested arrays.

  • countOnly(inputObject, countCondition): returns an object which contains a count of items in inputObject which meets condition passed in countCondition.

  • eqArrays(array #1, array #2): returns true if array #1 === array #2 and return false otherwise.

  • eqObjects(object #1, object #2): returns true if object #1 === object #2 and return false otherwise.

About

A simple clone of lodash library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published