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

@chrisarsenault/lotide

v1.0.1

Published

A mini clone of the Lodash library

Downloads

4

Readme

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 @chrisarsenault/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • countLetters(string): returns how many times a letter is in a string.
// countLetters ex:
countLetters("hello"); // => {h:1, e:1, l:2, o:1}
  • countOnly(allItems, itemsToCount): returns how many times items (itemsToCount) appear in a list (allItems).
// countOnly ex:
countOnly(
  [
    "Jim",
    "Pam",
    "Michael",
    "Pam",
    "Dwight",
    "Kevin",
    "Angela",
    "Oscar",
    "Angela",
  ],
  {
    Jim: true,
    Pam: true,
    Angel: true,
    Oscar: true,
  }
); // => {"Jim": 1, "Pam": 2, "Angela": 2, "Oscar": 1}
  • findKey(object, callback): given an object with values containing another object, using a callback, it will return the first key matching the callback.
// findKey ex:
findKey(
  {
    "Blue Hill": { stars: 1 },
    Akaleri: { stars: 3 },
    noma: { stars: 2 },
    elBulli: { stars: 3 },
    Ora: { stars: 2 },
    Akelarre: { stars: 3 },
  },
  (x) => x.stars === 2
); // => "noma"
  • findKeyByValue(object, value): returns the key of an object matching value arg
// findKeyByValue ex:
findKeyByValue(
  {
    sci_fi: "The Expanse",
    comedy: "Brooklyn Nine-Nine",
    drama: "The Wire",
  },
  "The Wire"
); // => "drama"
  • flatten(object, value): given an array with nested arrays no more than 1 level deep, will return simple none nested array with all values in it.
// flatten ex:
flatten([1, 2, [3, 4], 5, [6]]); // => [1, 2, 3, 4, 5, 6]
  • head(arr): returns the first item in an array.
// head ex:
head([1, 2, 3, 4]); // => 1
  • letterPositions(sentence): given a sentence, and the letter you want the indexes of, it will return an array with the indexes of that letter.
// letterPositions ex:
letterPositions("hello").l; // => [2, 3]
  • map(arr): iterates over an passed array and returns a new array with values based of a passed callback.
// map ex:
map(["ground", "control", "to", "major", "tom"], (word) => word[0]); // => ["g", "c", "t", "m" "t"]
  • middle(arr): returns an array of the middle value of an array. If even numbered array, will return the middle 2 values of that array.
// middle ex:
middle([1, 2, 3, 4]); // => [2, 3]
  • tail(arr): returns an array with every value after the first item in that array.
// tail ex:
tail([1, 2, 3, 4]); // => [2, 3, 4]
  • takeUntil(array, callback): returns an array with every value until callback is met.
// takeUntil ex:
takeUntil([1, 2, 5, 7, 2, -1, 2, 4, 5], (x) => x < 0); // => [1, 2, 5, 7, 2]
  • without(source, itemsToRemove): given an array of items, and an array of items you want removed, returns a new array with remaining items.
// without ex:
without([1, 2, 3], [1]); // => [2, 3]
without(["1", "2", "3"], [1, 2, "3"]); // => ["1", "2"]