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

m6node-day3-npm-package-class-assignment

v1.0.1

Published

learning how to create and publish node packages.

Downloads

3

Readme

npm package | Day 3 Classwork (Node Js Module #6 MERN Stack)

Objectives

To learn how to develop and publish my own Node.js package for binary search algorithm.

  • Performs a Binary search operation on the provided numbers and check if target is present.
  • Additonal Feature: Algorithm will automatically detect if data is unsorted, and if so, will sort it using built in sort method, and perform binary search!

How to install this package in yours local machine

npm i m6node-day3-npm-package-class-assignment

Tech. Stack Used:

alex21cBinarySearch

/***
 * Binary Search
 * Performs a Binary search operation on the provided numbers and check if target is present.
 * Additonal Feature: Algorithm will automatically detect if data is unsorted, and if so,
 * will sort it using built in sort method, and perform binary search!
 *
 * @params nums, target 
 * nums: Array of numbers,
 * target: target number
 *
 * @return empty array | idx
 * empty array: if no nums or target is provided
 * idx : index of target otherwise, if not found -1
 *
 * @Time & Space Complexity 
 * Overall Time Complexity (if provided nums are not sorted ): 
 *    O(n log n + log n) = O (n log n)
 * Overall Time Complexity (if provided nums are sorted ):
 *    O (log n)
 * Overall Space Complexity: 
 *  O(1) Not extra space was used
 *
 * Author: Abhishek kumar
 * LinkedIN: https://www.linkedin.com/in/alex21c/
 * Initial Release: May-04-2024
 * License : MIT
 */

Demo examples

import alex21cBinarySearch from "m6node-day3-npm-package-class-assignment";

in yours package.json file make sure to have

"type": "module"

Example #1: Binary Search on Unsorted Data

let nums = [25, 75, 33, 22, 21];
let target = 75;
let idxTarget = alex21cBinarySearch(nums, target)
console.log(`${target} found at index ${idxTarget}, inside [${nums}]`);

OUTPUT:

[ 21, 22, 25, 33, 75 ]
75 found at index 4, inside 21,22,25,33,75

Example #2: Binary Search on Sorted Data

let nums = [25, 50, 75, 125, 500, 750];
let target = 35;
let idxTarget = alex21cBinarySearch(nums, target)

if(idxTarget == -1){
  console.log(`${target} Not present, inside [${nums}]`);
}else{
  console.log(`${target} found at index ${idxTarget}, inside [${nums}]`);
}

OUTPUT:

[ 25, 50, 75, 125, 500, 750 ]
35 Not found , inside [25,50,75,125,500,750]

Author

Abhishek kumar, (Geekster MERN Stack FS-14 Batch)