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

extra-sorted-array

v1.1.0

Published

A sorted array is a collection of values, arranged in an order.

Downloads

130

Readme

A sorted array is a collection of values, arranged in an order. 📦 Node.js, 🌐 Web, 📜 Files, 📰 Docs, 📘 Wiki.

This package includes comprehensive set of functions that operate on a sorted array with which you can search a value using binary search, merge multiple sorted arrays, or perform set operations upon it.

We use a consistent naming scheme that helps you quickly identify the functions you need. All functions except from*() take array as 1st parameter. Some functions operate on a specified range in the array and are called ranged*(), such as rangedMerge(). Functions like slice() are pure and do not modify the array itself, while functions like slice$() do modify (update) the array itself. Some functions accept a map function in addition to a compare function. Further, functions which return an iterable instead of an array are prefixed with i, such as isubsequences(). We borrow some names from other programming languages such as Haskell, Python, Java, and Processing.

With this package, you can simplify the implementation of complex algorithms, and be able to achieve your goals faster, regardless of your level of expertise. Try it out today and discover how it can transform your development experience! This package is available in Node.js and Web formats. To use it on the web, simply use the extra_sorted_array global variable after loading with a <script> tag from the jsDelivr CDN.

Stability: Experimental.

const xsortedArray = require('extra-sorted-array');
// import * as xsortedArray from "extra-sorted-array";
// import * as xsortedArray from "https://unpkg.com/extra-sorted-array/index.mjs"; (deno)

var x = [10, 20, 20, 40, 40, 80];
xsortedArray.searchValue(x, 40);
// → 3

var x = [10, 20, 20, 40, 40, 80];
var y = [20, 50, 70];
xsortedArray.merge(x, y);
// → [ 10, 20, 20, 20, 40, 40, 50, 70, 80 ]

var x = [10, 20, 20, 40, 40, 80];
var y = [20, 50, 70];
var z = [30, 60, 90];
xsortedArray.mergeAll([x, y, z]);
// → [ 10, 20, 20, 20, 30, 40, 40, 50, 60, 70, 80, 90 ]

var x = [10, 20, 20, 40, 40, 80];
var y = [20, 50, 70];
xsortedArray.isDisjoint(x, y);
// → false

var x = [10, 20, 20, 40, 40, 80];
var y = [20, 50, 80];
xsortedArray.intersection(x, y);
// → [ 20, 80 ]

Index

| Property | Description | | ---- | ---- | | includes | Check if sorted array has a value using binary search. | | hasValue | Check if sorted array has a value using binary search. | | indexOf | Find first index of value using binary search. | | lastIndexOf | Find last index of value using binary search. | | searchValue | Find first index of value using binary search. | | searchValueRight | Find last index of a value using binary search. | | searchValueAny | Find any index of a value using binary search. | | searchClosestValue | Find index of closest value using binary search. | | | | | merge | Merge values from two sorted arrays. | | mergeAll | Merge values from sorted arrays. | | | | | isUnique | Examine if there are no duplicate values. | | isDisjoint | Examine if arrays have no value in common. | | unique | Remove duplicate values. | | union | Obtain values present in any sorted array. | | intersection | Obtain values present in both sorted arrays. | | difference | Obtain values not present in another sorted array. | | symmetricDifference | Obtain values present in either sorted array but not both. |

References

ORG Coverage Status Test Coverage