1.0.2 • Published 3 years ago

@hatem.deux/lotide v1.0.2

Weekly downloads
2
License
ISC
Repository
github
Last release
3 years ago

Lotide

A mini-clone of the Lodash library.

Author :

Hatem : Github: @AH82 | npm: @hatem.deux

Author's Notes :

Lighthouse Labs

  • This project is a part of a learning experience as a student at Lighthouse Labs's Full-Stack Web-Developper Bootcamp course.
  • This is my very first project.
  • Main focus:
    • Data manipulation (arrays and objects)
    • Callbacks
    • Recursion
    • export / import (require)
    • TDD / BDD with Mocha & Chai
  • Most commented-out code is kept intentionally for learning, improvement & future awareness purposes.
  • These are especially at the bottom of Test files.
  • This project was revisited post-bootcamp and implemented additional excercises, did major clean up and fixed a couple of bugs.

Table of contents

Setup

back to top

CAUTION: This library is published as a part of a learning process. It is not meant for use in serious projects.

Install via npm:

In your Terminal:

> npm install @hatem.deux/lotide

At the top of your JavaScript code:

const _ = require('@hatem.deux/lotide');

Call it (example):

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

Clone it from GitHub

in your terminal:

> git clone git@github.com:AH82/lotide.git

Dependencies

back to top

Install Dependencies in the terminal:

> npm install

DevDependencies

> npm install --save-dev mocha chai

Documentation

back to top

Main Functions

  • All functions are in files of "./<function name>.js"
  • index.js exports all these functions.
Function nameparameterDescription
headarrayreturns the value of the first (head) element in an array.
tailarrayreturns an array of remaining element in an array.
middlearrayreturns an array of middle element(s) in an array (1 for odd, 2 for even).
withoutSourceArray, itemsToRemoveArrayreturns a filtered-out new array.
flattenarrayreturns a flattened array from a multi-level nested one in the same element-order (i.e. removes nesting)
countOnlyarray, itemsToCountObjectreturns an object containing counts of everything the input object listed.
countLettersstringreturns an object a count of each of the letters in that sentence. ignores whitespaces.
letterPositionsstringreturns an object with all the indices (zero-based positions) in the string where each character is found. (property-value is an array)
findKeyByValueobject, valuescans the object and return the first key which contains the given value. If no key with that given value is found, then it should return undefined.
maparray, callbackreturns an array modified by the callback.
takeUntilarray, callbackreturns a slice of the array with elements taken from the beginning until callback returns a truthy value.
findKeyobject, callbackreturns the first key for which the callback returns a truthy value. If not found, returns undefined.

|

Comparison functions

These functions are not included in index.js.

Function nameparameterDescription
eqArraysarray1, array2deep-compares arrays. returns true if identical. false if not.
eqObjectsobject1, object2deep-compares objects. returns true if identical. false if not.

Custom Assertion functions

These functions are not included in index.js.

These functions were used during development and are no longer required by other functions. They are kept for archiving and the learning experience.

These are side-effects function do not return, they produce console.logs indicating success or failure of Assertion. They typically use the Comparison functions as inputs to assert. | Function name | parameter | Description | | -------------------- | :-----------------------------: | ----------- | | assertEqual | bool | for regular values | assertArraysEqual | bool | for arrays | assertEqualObjects | bool | for objects |

Testing

Using Mocha/Chai

  • All test files are under "./test/"
  • All Test files are named by the convention "./test/<function name>Test.js"

Running Test

  • At project root folder in the terminal
> mocha

or

> npm test

Change History

back to top

v1.0.2

  • upgrades to version 1.0.2 to fix an npm unpublishing/publishing accidental issue.
  • fixes a minor issue in the interlinks of REAMDME.md

v1.0.1


Improvements

  • eqArrays & eqObjects now support deep comparison (through recursion)
  • README.md redesigned.
  • lints, cleans and removes redundant, dead or commented-out code across entire project, except when intentional.
  • Testing
    • The entire code is now covered by tests.
    • Any in-file custom tests (console.log or custom assertions) moved to the "./test/*" folders.
    • Any remaining custom tests are converted to Mocha/Chai code.
      • except: custom Assertions due to side-effect nature (but rapped in Mocha's describe/it )

Bug fixes

  • takeUntil.js
    • Issue: returns undefined if the callback argument does not match an element. (i.e. does not find a truthy element).
    • Fix: returns the entire array if no match.
  • without.js
    • Issue: Does not return a new array. (i.e. modifies the original).
    • Fix: returns a new array.
  • index.js
    • fixes typo: findKeysByValue => findKeyByValue
  • package.json
    • Issue: "main" refered to the incorrect file => { ..., "main": "assertArraysEqual.js", ... }
    • Fix: "main" now referes to the correct file => { ..., "main": "index.js", ... }
  • functions findKeysByValue, letterPositions, map, takeUntil, without, findKey are now implemented. (on npm package only)

v1.0.0


  • Initial release.

back to top

Meet Larry The Duck - Lighthouse labs mascot

Larry the Duck

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

4 years ago