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

@robertocervantesbetancourt/lotide

v1.0.2

Published

A mini clone of the [Lodash](https://lodash.com) 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 @robertocervantesbetancourt/lotide

Require it:

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

Call it:

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

Documentation

The following functions are currently implemented:

  • assertEqual(actual, expected): Takes two values and prints Pass / Fail to console if the values are the same or not.
//asserEqual example
assertEqual("Lighthouse Labs", "Bootcamp"); // => ❌❌❌ Assertion Failed: ${actual} !== ${expected}
assertEqual(1, 1); // => ✅✅✅ Assertion Passed: ${actual}  ===  ${expected}
  • head(arr): Return the first value on an array.
//head example
head([5,6,7]) // => 5
  • tail(arr): Return the values in the array that come after the first value.
//tail example
tail(["Hello", "Lighthouse", "Labs"]) // => ["Lighthouse", "Labs"]
  • middle(arr): Return the middle value in an array. If the array has even number of values, then the function returns the two middle values.
//middle example
middle([1, 2, 3, 4, 5]) // => [3]
middle([1, 2, 3, 4]) // => [2, 3]
middle([1]) // => []
middle([1, 2]) // => []
  • flatten(arr): Takes a nested array and flatens it by removing the nesting. Returns a flat array.
//flatten example
flatten([1, 2, [3, 4], 5, [6]]) // => [1, 2, 3, 4, 5, 6]
  • eqArrays(arr1, arr2): Takes two arrays and compare them to se if they are equal. Returns true / false
//eqArrays example
eqArrays([1, 2, 3], [1, 2, 3]) // => true
eqArrays([1, 2, 3], [3, 2, 1]) // => false
eqArrays(["1", "2", "3"], ["1", "2", "3"]) // => true
eqArrays(["1", "2", "3"], ["1", "2", 3]) // => false
  • assertArraysEqual(value): Works with .eqArrays and prints Both arrays as equal / Arrays are NOT equal.
//assertArraysEqual example
assertArraysEqual(eqArrays([1,2,3],[1,2,3])) // => "Both arrays are equal"
assertArraysEqual(eqArrays([1,2,3],[3,2,1])) // => "Arrays are NOT equal"
  • without(arr1, arr2): Removes the values in arr2 from the values in arr1.
//without example
without([1, 2, 3], [1]) // => [2, 3]
without(["1", "2", "3"], [1, 2, "3"]) // => ["1", "2"]
  • countOnly(allItems, itesmToCount): Takes in an array (allItems) and an object (itemsToCount) and counts how many times specific items appear.
//countOnly example
const firstNames = [
  'Karl',
  'Salima',
  'Agouhanna',
  'Fang',
  'Kavith',
  'Jason',
  'Salima',
  'Fang',
  'Joe'
];
countOnly(firstNames, {'Jason': true, 'Karima': true, 'Fang': true, 'Agouhanna': false}); // => 3
  • countLetters(sentence): Takes in a sentence and returns an object with the number of times each letter shows up in the sentence. Letter:key , count:values.
//countLetters example
countLetters('lighthouse in the house'); // => { l: 1, i: 2, g: 1, h: 4, t: 2, o: 2, u: 2, s: 2, e: 3, n: 1 }
  • letterPositions(sentence): Takes in a sentence and returns an object with the position of each letter in the sentence.
//letterPositions example
letterPositions('hello'); // => { h: [ 0 ], e: [ 1 ], l: [ 2, 3 ], o: [ 4 ] }
  • findKeyByValue(obj, val): Takes in an object and a specific value and returns the key for that value.
//findKeyByValue example
const bestTVShowsByGenre = {
  sci_fi: 'The Expanse',
  comedy: 'Brooklyn Nine-Nine',
  drama: 'The Wire'
};
findKeyByValue(bestTVShowsByGenre, 'The Expanse') // => sci_fi
findKeyByValue(bestTVShowsByGenre, 'That 70s Show') // => undefined
  • eqObject(obj1, obj2): Takes in two objects and checks if they are equal. Returns true / false
//eqObject example
eqObject({ a: { y: 0, z: 1 }, b: 2 }, { a: { z: 1 }, b: 2 }); // => false
eqObject({ a: { z: 1 }, b: 2, c: [1,2,3]}, { a: { z: 1 }, b: 2, c:[1,2,3]}); // => true
  • assertObjectEqual(actual, expected): Takes in the value from eqObjects and an expected value and returns Pass / Fail.
// assertObjectEqual example
const ab = {a:'1', b:'2'};
const ba = {b:'2', a:'1'};
const abc = {a:'1', b:'2', c:'3'};
assertObjectsEquals(eqObjects(ab,ba),true); // => ✅✅✅ Assertion Passed
assertObjectsEquals(eqObjects(ab,abc),true); // => 🛑🛑🛑 Assertion Failed
  • map(array, callback): Takes a callback and returns the value form the array.
//map example
const words = ["ground", "control", "to", "major", "tom"];
map(words, word => word[0]) // => [ 'g', 'c', 't', 'm', 't' ]
  • takeUntil(array, callback): Takes a callback and return all the nubers from the array up until the callback return nuber.
//takeUntil example
const data1 = [1, 2, 5, 7, 2, -1, 2, 4, 5];
const results1 = takeUntil(data1, x => x < 0);
console.log(results1); // => [ 1, 2, 5, 7, 2 ]
  • findKey(object, callback): Takes the return from the callback and uses it as a value to find its corresponding key in the object. Returns the key.
//findKey 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"