1.0.0 • Published 5 years ago

@g-ram84/lotide v1.0.0

Weekly downloads
1
License
ISC
Repository
github
Last release
5 years ago

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 @g-ram84/lotide

Require it:

const _ = require('@g-ram84/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • `const eqArray = require('./eqArrays');

const assertArraysEqual = function(actual, expected) { if (eqArray(actual, expected)) { console.log(✅✅✅ Assertion Passed: ${actual} === ${expected}); } else { console.log(❌❌❌ Assertion Failed: ${actual} !== ${expected}); } }; module.exports = assertArraysEqual; : Determines if 2 arrays are equal

  • const assertEqual = function(actual, expected) { if (actual === expected) { console.log(✅✅✅ Assertion Passed: ${actual} === ${expected}); } else { console.log(❌❌❌ Assertion Failed: ${actual} !== ${expected}`); } };

module.exports = assertEqual; : Compares content of primitive data types

  • `const eqArray = function(arr1, arr2) { if (arr1.length !== arr2.length) { return false; } for (let i = 0; i < arr1.length; i++) { if (arr1i !== arr2i) { return false; } } return true; }; : compares 2 Arrays

const head = function(input) { return input0; }; : finds the first item in a string, or array

const tail = function(input) { return input.slice(1); }; : removes the first item in a string, or array, and prints the remainders

const middle = function(arr) { // find the length of the array let newArr = []; let arrLength = arr.length; let i = arrLength/2; // is the length odd or even? if (arrLength <= 2) { return newArr; } else if(arrLength % 2 === 0) { newArr.push(arri-1); newArr.push(arri); } else { newArr.push(arri-.5); } return newArr; }; : shows the middle items in an array or string