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

cedge

v1.1.0

Published

A collection of major data structures missing from the JavaScript standard library designed for competitive programming but useful for any programming needs.

Downloads

7

Readme

Cedge tests outcome coverage version

Cedge is a collection of major data structures missing from the standard JavaScript library that are designed for competitive programming. The name Cedge is a portmanteau of the words competitive and edge, and as it implies Cedge will give you a competitive edge for whatever JavaScript programming you are doing. Cedge is available for Node.js and competitive programming. If desired a distributable for browsers can be added. Send an email to ask for a browser distributable.

At present the supported data structures are:

  • AVL A self-balancing binary search tree that stores any type of data and allows you to provide a custom comparator for non-standard data or a different desired outcome. It includes inorder, preorder, and postorder outputs along with an includes and amount of verifications.
  • Deque A double-ended queue that stores any type of data desired and allows you to set a limit to the amount of data stored (e.g. ideal for an LRU cache).
  • Heap A minimum or maximum priority queue that stores any type of data, allows you to use a custom comparator for non-standard data or a different desired outcome, and allows you to set a limit to the amount of data stored.
  • Queue A queue that stores any type of data. It also includes pop, push, shift, and unshift rather than just the standard enqueue and dequeue (note that Queue.prototype.pop runs in O(n) time whereas Deque.prototype.pop runs in O(1) time).
  • Stack A stack that stores any type of data. It offers core stack methods like Stack.prototype.top and Stack.prototype.empty that an Array implementation is missing.

Currently the following data structures are scheduled for version 2.0.0:

  • Trie
  • RedBlack

Node.js

npm install cedge
const cedge = require('cedge');
const avl = new cedge.AVL(...);
const deque = new cedge.Deque(...);
const heap = new cedge.Heap(...);
const queue = new cedge.Queue(...);
const stack = new cedge.Stack(...);

Competitive Programming

This method requires bash, GNU sed, git, and xclip. First run this installation script.

# install any missing requirements
#   sudo [apt-get|dnf|...] install [xclip|...]

# cd to wherever you would like to store the cedge repository
git clone https://github.com/imaginate/cedge.git

# save this function for future use
cat <<'EOF' >> ~/.bashrc

##############################################################################
# This function enables you to quickly copy a Cedge JavaScript data structure
# so that you may paste it into your competitive programming editor. You may
# paste the copied code below the JavaScript function that holds your solution
# and reference the data structure class as long as any reference to the class
# is not immediately executed. Otherwise you would need to paste the code
# before the immediately executed expression. Also note when copying the
# `Queue` class that due to a collision in LeetCode you must use the name
# `MyQueue` instead of `Queue`. LeetCode pollutes the environment with a
# disappointing queue class implementation.
#
# @param {string} srcfile
# @return {void}
##############################################################################
c()
{
  cat "$1" \
    | sed -e '/^module\.exports/ d' \
    | xclip -selection clipboard -i
}
EOF

Next all you need to do any time you have a competition is navigate to the src directory within your saved copy of the Cedge repository, use the c function in your terminal to copy the needed class, and paste it in your competition's editor. Note to use the c function immediately after installation you need to run . ~/.bashrc to reload the config file (it is automatically loaded every time you start a new user shell).

cd cedge/src
c queue.js

Participate

Feel free to make a pull request (make sure that all existing tests pass and any new features you add have accompanying tests written for them). It is recommended that you contact the project owner, Adam, to ask if a potential new feature would be accepted before you go through the effort to develop it.