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

collection-of-algos

v1.0.71

Published

A collection of mostly common algorithms, data structures with visualizations and explanations.

Downloads

28

Readme

A continuing collection of good to know algorithms mainly in JS

It's also a library that can be used in your projects. It contains algos that are both common and un-common.

codecov test License: MIT NPM Downloads

Edit example: collection of algos in reactjs

To use this package in your project

Installation Open your terminal or command prompt, navigate to your project directory and run the following command:

# using npm
npm install collection-of-algos

# using yarn
yarn add collection-of-algos

This will install version latest version of the package collection-of-algos.

Import For CommonJS (Node.js):

const algos = require('collection-of-algos');

For ES6 syntax:

import algos from 'collection-of-algos';

Usage

algos.nativeSort();

Import specific functions

import { bubbleSort, nativeSort } from 'collection-of-algos';

Usage

let exampleArr = [5, 3, 1, 4, 2];
// create shallow copy of the array
const unsortedArr = [...exampleArr];
const obj1 = { arr: unsortedArr };

// using a promise chain
bubbleSort(obj1).then(({ arr }) => {
  console.log(arr); // [1, 2, 3, 4, 5]
});

// or using async/await
const { arr: arrOfNums } = await bubbleSort(obj1);

console.log(arrOfNums); // [1, 2, 3, 4, 5]

const obj2 = {
  arr: [
    { name: 'John', age: 23 },
    { name: 'Mike', age: 32 },
    { name: 'Chris', age: 11 },
    { name: 'Nick', age: 19 },
  ],
  key: 'age',
};
const { arr: arrOfObjs } = await nativeSort(obj2);

console.log(arrOfObjs);
// [
//   { name: 'Chris', age: 11 },
//   { name: 'Nick', age: 19 },
//   { name: 'John', age: 23 },
//   { name: 'Mike', age: 32 },
// ]

In this code, bubbleSort and nativeSort are specific functions imported from the collection-of-algos package. bubbleSort is a sorting algorithm that's being applied to an array of numbers, while nativeSort is used to sort an array of objects by a specific key.

Remember, before using await, you should ensure that your code is inside an async function. The await operator is used to wait for a Promise. It can only be used inside an async function.

Work with this repo locally

In your terminal

# install dependencies
yarn

# serve the app
yarn dev

Running unit tests

# run all tests
yarn test

# for coverage report
yarn coverage

local server to test functions locally (Ctrl-C to stop)

http://localhost:3000

Connect with me

LinkedIn

/docs-dist (The visualizer codebase)

  • Currently contains the build dist for the documentation folder which is currently hidden.
  • Once it's in a good place I will makde it public.

Todos

  • [ ] Think about separating each algo into its own page
  • [ ] Add notes and drawings for each algo
  • [ ] Unit the helper functions
  • [ ] Docker support

Using Docker (WIP parcel watch is not working)

# build the docker image
docker-compose build

# serve the app
docker-compose up

# Stop & remove the container
docker-compose down