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

@idogo/i-class

v1.0.2

Published

Usually data structure constructor class.

Downloads

4

Readme

i-class

Usually data structure constructor class.

Install

npm install @idogo/i-class --save

Usage

Browser

<script src="url/i-class/dist/i-class.umd.js"></script>
<script>
  var TreeNode = iClass.TreeNode;
</script>

Es6

import { TreeNode } from '@idogo/i-class';
const node = new TreeNode(10);

TreeNode

const TreeNode = require('@idogo/i-class').TreeNode;
const node = new TreeNode(10);

Interface class

TreeNode

construct tree node

Constructor instance:

import { TreeNode } from '@idogo/i-class';
const node = new TreeNode(10);

Constructor by object element which has required key value and optional key payLoad:

const ele = { value: 90 }; 
const node = new TreeNode(ele);
const ele = { value: 90, payLoad: 'I am old man' }; 
const node = new TreeNode(ele);

Constructor chained instances:

const root = new TreeNode(19);
root.left = new TreeNode(20);
root.right = new TreeNode(22);
const root = new TreeNode(19, new TreeNode(29), new TreeNode(22));

Other api:

  • left default:null

  • rightdefault:null

  • payLoaddefault:undefined

Heap

Constructor instance:

import { Heap } from '@idogo/i-class';
const heap = new Heap({
  data: [67, 78, 23, 56, 12, 2]
});

Constructor a min(default) or max heap with type in config:

const heap = new Heap({
  data: [67, 78, 23, 56, 12, 2],
  type: 'max'
});

Shift top element:

const heap = new Heap({
  data: [67, 78, 23, 56, 12, 2],
  type: 'max'
});
heap.shift(); // 78
heap.size(); // 5

Append an element:

import { Heap } from '@idogo/i-class';
const heap = new Heap({
  data: [67, 78, 23, 56, 12, 2]
});
heap.append(88); // [88, 67, 78, 56, 12, 2, 23]
heap.append(6); // [88, 67, 78, 56, 12, 2, 23, 6]
heap.size(); // 8

BinaryTree

Constructor instance:

import { BinaryTree } from '@idogo/i-class';
const binaryTree = new BinaryTree();

Construct a ordinary binaryTree by Array fill with Number:

const binaryTree = new BinaryTree();
const tree = binaryTree.constructTree([5, 56, 78, 8, 12]); 

Construct a ordinary binaryTree by Array fill with Object, element of Array has required key value and optional key payLoad:

const binaryTree = new BinaryTree();
const tree = binaryTree.constructTree([{ value: 5 }, { value: 56, payLoad: null }, { value: 78}]);
const source = [{ name: 'leo', age: 89 }, { name: 'jack', age: 12 }, { name: 'rose', age: 10 }, { name: 'john', age: 22 }];
const list = source.map(data => {
  const item = {};
  item.value = data.value;
  item.payLoad = data;
  return item;
});
const binaryTree = new BinaryTree();
const tree = binaryTree.constructTree(list);

Construct a Max binaryTree:

const binaryTree = new BinaryTree();
const maxTree = binaryTree.constructMaxTree([5, 56, 78, 8, 12]);

Other api:

  • insert insert a node in already existed BinaryTree instance.if existed BinaryTree instance was MaxTree or other special tree, this handler would change construction.
  • deepestLeaves return depth of BinaryTree instance.
  • nodesOfLevels return nodes of levels by Array.(eg: [[5], [6, 7], [12, 5, 7]])
  • deepestLeavesSum return sum of deepest nodes.

License

MIT.