Giter Site home page Giter Site logo

lotide's Introduction

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 @mat.davis/lotide

Require it:

const _ = require('@mat.davis/lotide');

Call it:

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

  • NOTE:
    use findLib{...} for:
    const findKey = _.findLib.findKey(object, callback)
    const findKey_Obj = _.findLib.findKey_Obj(object, callback)

Documentation

The following functions are currently implemented:

  • countLetters(string): This function takes a single argument, a string, and will return a object containing { letter: [appearanceCount] } spaces are ignored.

  • countOnly(array, object): This function takes two arguments an array of items to count and an object that contains a boolean value to indicate if that key should be counted. If the key doesn't exist in the array undefined is returned.

  • eqArrays(array1, array2): A function which takes in two arrays and returns true if they are equal, false otherwise. This function works recursively with any level of nested arrays.

  • eqObjects(obj1, obj2): A function which takes in two objects and returns true if they are equal, false otherwise. This function works recursively on nested data.

  • findLib {... : An Object that contains the following methods:

    • .findKey(object, callback): A function which takes in an object and a callback and returns the key as soon as the callback is true.
    • .findKey_Obj(object, callback): A function which takes in an object and a callback and returns an object that contains the properties that pass the callback test.
      }
  • findKeyByValue(object, value): A function that takes two arguments, an object and a value of that object the corresponding key of that value is returned.

  • flatten(array): A function that takes an array with one level of nesting and returns the array without the nested elements. Note a very simple version here, this would be a good case for recursion if I have time in the future.

  • head(array): A function takes in an array and returns the first element of that array.

  • letterPositions(string): A function that takes a string and returns an object that contains each letter and the index that each letter occurs at.

  • map(array, callback): This is my attempt at re-making the map function. This function takes two arguments, an array, and a callback, it returns a new array populated with elements from the callback.

  • middle(array):A function that takes in an array and returns the middle-most element(s if length is even).

  • tail(array): A function that returns all but the first element of an array.

  • takeUntil(array, callback): This function takes two arguments, an array, and a callback. The function returns elements of the array to a new array until the callback condition is met.

  • without(array, toRemove): This function takes two arguments a source array, and an item(s) to remove array and returns the array without those item(s).

lotide's People

Contributors

teddygavi avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.