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

@m3.code/lotide

v1.0.1

Published

A mini clone of the Lodash library, for educational purposes

Downloads

7

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 @m3.code/lotide

Require it:

const _ = require('@m3.code/lotide');

Call it:

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

Documentation

The following functions are currently implemented:

  • assertArraysEqual(arr1, arr2): compares 2 arrays to see if they're equal and makes an assertion with results.

  • assertEqual(actual, expected): implementation of our assert, comparing 2 values and see if they're equal

  • assertObjectsEqual(actualObj, expectedObj): compares 2 objects to see if they're equal and makes an assertion with results.

  • head(arr): Returns the 1st element of an array

  • tail(arr): Returns the array without its head, all the following elements after the first one.

  • middle(arr): Returns an array of the middle elements of the array, or the 2 middle elements of an array with an even number size length

  • countLetters(sentence): Returns an object with Character key and count value pairs, describing a detailed count of characters inside the sentence.

    Example:

    countLetters('hello') => {h: 1, e: 1, l: 2, o:1}
  • countOnly(allItems, itemsToCount): from an allItems object, we will count how many times the keys in itemToCount exist in this former object.

    Example:

    countOnly([
    "Karl",
    "Salima",
    "Agouhanna",
    "Fang",
    "Kavith",
    "Jason",
    "Salima",
    "Fang",
    "Joe"
    ], {Jason: true}) => 1
  • eqArrays(arr1, arr2): compare 2 arrays and returns true if they're equal.

  • eqObjects(obj1, obj2): compare 2 objects and returns true if they're equal.

  • findKey(obj, callback): given an object, will return the key whose value meets the condition set in the callbback function.

    Example:

    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(obj, value): given an object, will return the key whose value meets the value passed as argument

    Example:

    findKeyByValue({
      // eslint-disable-next-line camelcase
      sci_fi: "The Expanse",
      comedy: "Brooklyn Nine-Nine",
      drama: "The Wire"
    }, "The Wire") => drama
  • flatten(arr): will "flatten" an array, making it unidimensional if there are nested arrays inside.

  • letterPositions(sentence): will return an object with the characters as key and their index positions as array of numbers as values.

    Example:

    letterPositions('hello') => {h: [0], e:[1], l: [2,3], o: [4]}
  • map(arr, callback): our implementation of the Array.map method. Takes an array and returns a new array given the oprations of the callback function.

  • takeUntil(arr, callback): will return a new array from the elements of the passed arr until the condition set in callback is met (true).

    Example:

    takeUntil([1, 2, 5, 7, 2, -1, 2, 4, 5], x => x < 0) => [1, 2, 5, 7, 2]
  • without(source, toRemove): returns a new array from the source from which we want to remove the elements present in the 2nd array toRemove.

    Example:

    without([1, 2, 3], [1]) => [2,3]