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

silver-hasher

v0.0.2

Published

Greatest Functions and Approaches

Downloads

2

Readme

Build Status Coverage Status

silver-hasher

Implementation of most used functions and data structures

Functions

isPrime

isPrime - Returns true or false, indicating whether the given number is prime.

isPrime(0)                          // false
isPrime(1)                          // false
isPrime(17)                         // true
isPrime(10000000000000)             // false

Factorial

factorial - Returns a number that is the factorial of the given number.

factorial(0)                        // 1
factorial(1)                        // 1
factorial(6)                        // 720

Fibonacci

fib - Returns the nth Fibonacci number.

fib(0)                              // 0
fib(1)                              // 1
fib(10)                             // 55
fib(20)                             // 6765

isSorted

isSorted - Returns true or false, indicating whether the given array of numbers is sorted.

isSorted([])                        // true
isSorted([-Infinity, -5, 0, 3, 9])  // true
isSorted([3, 9, -3, 10])            // false

Filter

filter - Implementation of the filter function.

filter([1, 2, 3, 4], n => n < 3)    // [1, 2]

Reduce

reduce - Implementation of the reduce function

reduce([1, 2, 3, 4], (a, b) => a + b, 0) // 10

Reverse

reverse - Reverses the given string.

reverse('')                         // ''
reverse('abcdef')                   // 'fedcba'

IndexOf

indexOf - Implementation of the indexOf function for arrays.

indexOf([1, 2, 3], 1)               // 0
indexOf([1, 2, 3], 4)               // -1

IsPalindrome

isPalindrome - Return true or false indicating whether the given string is a palindrome (case and space insensitive).

isPalindrome('')                                // true
isPalindrome('abcdcba')                         // true
isPalindrome('abcd')                            // false
isPalindrome('A man a plan a canal Panama')     // true

Missing

missing - Takes an unsorted array of unique numbers from 1 through some number n, and returns the missing number in the sequence.

missing([])                         // undefined
missing([1, 4, 3])                  // 2
missing([2, 3, 4])                  // 1
missing([5, 1, 4, 2])               // 3
missing([1, 2, 3, 4])               // undefined

IsBalanced

isBalanced - Takes a string and returns true or false indicating whether its curly braces are balanced.

isBalanced('}{')                      // false
isBalanced('{{}')                     // false
isBalanced('{}{}')                    // true
isBalanced('foo { bar { baz } boo }') // true
isBalanced('foo { bar { baz }')       // false
isBalanced('foo { bar } }')           // false

Permute

permute - Return an array of strings, containing every permutation of the given string.

permute('')             // []
permute('abc')          // ['abc', 'acb', 'bac', 'bca', 'cab', 'cba']

Debounce

debounce - Implementation of the debounce function

let a = () => console.log('foo')
let b = debounce(a, 100)
b()
b()
b() // only this call should invoke a()

Intersection

intersection - Return the intersection of two arrays.

intersection([1, 5, 4, 2], [8, 91, 4, 1, 3])    // [4, 1]
intersection([1, 5, 4, 2], [7, 12])             // []

Uniq

uniq - Takes an array of numbers, and returns the unique numbers.

uniq([])                              // []
uniq([1, 4, 2, 2, 3, 4, 8])           // [1, 4, 2, 3, 8]

Data Structures

LinkedList

let list = new LinkedList()
list.add(4)                           // undefined
list.add(5)                           // undefined
list.remove(1)                        // 4
list.size(6)                          // 1

@Decorators

Debounced

Example:

      class ExampleApp {

          constructor () {
              document.addEventListener('mousemove', this.example)
          }

          @Debounced(500)
          public example() {
              console.log('hello')
          }
      }