npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@tai-de/lotide

v1.0.3

Published

Lodash clone for LHL

Downloads

1

Readme

Lotide JS Library

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 @tai-de/lotide

Require it:

const _ = require('@tai-de/lotide');

Call it:

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


********** Equality checks **********


Functions used to compare, returning true or false.

eqArrays(arrayOne, arrayTwo)
  • Returns true or false after checking if the arrays are equal
    • Supports nested arrays & array items being objects using recursion
  • arrayOne and arrayTwo can be given any array arguments
eqObjects(object1, object2)
  • Returns true or false after checking if two objects are equal
    • Supports arrays as object values & nested objects using recursion
  • object1 and object2 can be given any array arguments

********** Assertion functions **********


Functions used to return Assertion Passed or Assertion Failed whether two arguments are equal.

assertEqual(actual, expected)
  • Returns Assertion Passed or Assertion Failed after checking if the passed arguments are equal.
  • actual and expected can be given any argument (primitive values. see below for Array and Object variants)
assertArraysEqual(actual, expected)
  • Returns Assertion Passed or Assertion Failed after checking if the two arrays are equal.
  • actual and expected can be given any two arrays as arguments
assertObjectsEqual(actual, expected)
  • Returns Assertion Passed or Assertion Failed after checking if the two objects are equal.
  • actual and expected can be given any two objects as arguments

********** String functions **********


Functions used to manipulate or parse a string

countLetters(string)
  • An object will be returned containing counts of all unique letters in the string
    • Spaces are excluded/trimmed from the input
  • countLetters("Hello") => { h: 1, e: 1, l: 2, o: 1 }
letterPositions(string)
  • An object will be returned containing the index positions of all unique letters in the string
    • Spaces are excluded from the output, but do contribute to the positions
  • letterPositions("hello") => { h: [0], e: [1], l: [2,3], o: [4] }
  • letterPositions("lighthouse in the house") => { l: [0], i: [1, 11], g: [2], h: [3, 5, 15, 18], t: [4, 14], o: [6, 19], u: [7, 20], s: [8, 21], e: [9, 16, 22], n: [12] }

********** Array functions **********


Functions used to manipulate or parse an array

countOnly(array, object)
  • An object will be returned containing counts of everything within the array that the object parameter listed as true
    • If the object lists true for a key that does not exist in the array, include an undefined value in the object output
  • countOnly(["Jason", "Jason", "Fang", "Agouhanna"], { "Jason": true, "Karima": true, "Fang": true, "Agouhanna": false }) => { Jason: 2, Karima: undefined, Fang: 1 }
flatten(array)
  • Returns a new array after doing a flattening of any nested values/arrays
  • flatten([1, 2, [3, 4], 5, [6]]) => [1, 2, 3, 4, 5, 6]
  • flatten([1, 2, [3, 4, [5, 6, [7, 8, [[[[[9, [10]]]]]]]]]]) => [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
head(array)
  • Returns the head (first value) in a given array
  • head(["Hello", "Lighthouse", "Labs"]) => "Hello"
middle(array)
  • Returns the middle value of an array
    • If array length is less than 2, return empty array
    • If array length is odd, return exact middle value
    • If array length is even, return middle two values
  • middle([1]) => []
  • middle([1, 2, 3]) => [2]
  • middle([1, 2, 3, 4]) => [2, 3]
tail(array)
  • Returns the tail (array minus head) in a given array
  • head(["Hello", "Lighthouse", "Labs"]) => ["Lighthouse", "Labs"]
without(array, itemsToRemove)
  • Parses array and returns a new array that excludes all of the values passed through itemsToRemove
  • without([1, 2, 3], [1]) => [2, 3]
  • without(["1", "2", "3"], [1, 2, "3"]) => ["1", "2"]
map(array, callBackFn)
  • Mimics .map() behavior and applies the callBackFn argument against the array items
  • map(["never", "gonna", "give", "you", "up"], word => word[0]) = ["n", "g", "g", "y", "u"]
takeUntil(array, callBackFn)
  • Loops through a given array until the condition in the callBackFn returns true. A new array is returned with the preceeding values.

const data1 = [1, 2, 5, 7, 2, -1, 2, 4, 5];

  • takeUntil(data1, x => x < 0) => [1, 2, 5, 7, 2]

const data2 = ["I've", "been", "to", "Hollywood", ",", "I've", "been", "to", "Redwood""];

  • takeUntil(data1, x => x < 0) => ['I've', 'been', 'to', 'Hollywood']

********** Object functions **********


Functions used to manipulate or parse an object

findKey(object, callback)
  • Given an object of single key/value pairs, this will return the first key where the value is found
    • If no matching key is found for the value, return undefined

const data = {
  "Blue Hill": { stars: 1 },
  "Akaleri": { stars: 3 },
  "noma": { stars: 2 },
  "elBulli": { stars: 3 },
  "Ora": { stars: 2 },
  "Akelarre": { stars: 3 }
}

  • findKey(data, x => x.stars === 2) => "noma"
findKeyByValue(object, value)
  • Given an object of single key/value pairs, this will return the first key where the value is found
    • If no matching key is found for the value, return undefined

const bestTVShowsByGenre = {
  sci_fi: "The Expanse",
  comedy: "Brooklyn Nine-Nine",
  drama: "The Wire",
  space: "The Expanse"
}

  • findKeyByValue(bestTVShowsByGenre, "Brooklyn Nine-Nine") => "comedy"
  • findKeyByValue(bestTVShowsByGenre, "Scandal") => undefined