Git Product home page Git Product 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 @hansori/lotide

Require it:

const _ = require('@hansori/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • eqArrays(arr1, arr2): takes two arrays as arguments and returns true if their lengths and contents are equal.
  • eqObjects(obj1, obj2): takes two objects as arguments and returns true if their lengths and contents are equal.
  • head(arr): takes an array and returns the first element.
  • tail(arr): takes an array and returns a new aray without the first element.
  • middle(arr): takes an array and returns the middle element. If the array's length is even, it returns the two middle elements. If the array's length is less than 2, an empty is returned.
  • findKey(obj, callback): takes an object and a callback function. The callback function is called to each element in a loop, and stops and returns the first value that returns true.
  • findKeyByValues(obj, value): takes an object and a value and returns the first key that matches the value.
  • flatten(arr): takes an array and flattens all nested arrays within and returns the flattened array.
  • letterPositions(sentence): takes a string and returns an object with all characters and its position index as key-value pairs.
  • map(arr, callback): takes an array and a callback function that modifies every element and returns a new array.
  • takeUntil(array, callback): takes an array and a callback function and returns a new array with all the elements until the callback function returns a truthy value.
  • without(arr1, arr2): takes two arrays and returns a new array of unmatched items.
  • countLetters(str): takes a string and returns a object with each character as a key, and the number of apperances in string as a value.
  • countOnly(allItems, itemsToCount): takes an array of strings and an object of key-value pair with truthy values. Returns a count of the specified items in a new object.

lotide's People

Contributors

sorihan01 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.