GithubHelp home page GithubHelp 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 Vincent McKen as part of my learnings at Lighthouse Labs.

Usage

Install it:

npm install @mcken-vince/lotide

Require it:

const _ = require('@mcken-vince/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • countLetters(string): Counts how many times each character occurs in a given string. Takes a string as an argument, returns an object {uniqueCharacter: characterCount}
  • countOnly([array1], [array2]): Takes two arrays as arguments, returns an object, counting how many times the items in arr2 occur in arr1 {uniqueStringOrCharacter: characterCount}
  • findKey(object, callbackFunction): Takes an object and a function as arguments, returns first key where callbackFunction returns true/truthy.
  • findKeyByValue(object, value): Takes an object and a value as arguments, returns first key whose value matches given value.
  • flatten([array]): Takes an array as an argument, iterates through array, pulls single layer of sub-arrays out into main array '[[1], [2], [3]]' => '[1, 2, 3]', returns an array.
  • head([array]): Returns first item of a given array.
  • letterPositions(string): Takes a string argument, returns an object with a key for each unique character, each assigned an array value containing the index numbers of each occurrence of that character.
  • map([array], callbackFunction): Works like the default method .map(). Iterates through the array, applying the callbackFunction to the array. Returns a new array populated with the return value of the callbackFunction for each item of the array given as arguments.
  • middle([array]): Returns the middle element in a given array. If array has two middle elements, it will return both. Returns an array with one or two elements.
  • tail([array]): Takes an array as an argument, returns a new array without the first element of the given array. If array has fewer than two elements, it will return an empty array.
  • takeUntil([array], callbackFunction): Takes an array and a function as arguments. Iterates through given array, pushing elements into a new array, will stop when the callbackFunction(element) returns true on an element of the array. If the function criteria is never met, it will return a duplicate of the original array.
  • without([array1], [array2]): Takes two arrays as arguments. Returns an array containing only elements from array1 that do not exist in array2.

lotide's People

Contributors

mcken-vince 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.