1.0.6 ā€¢ Published 6 months ago

extra-sorted-array.web v1.0.6

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

A sorted array is a collection of values, arranged in an order. šŸ“¦ Node.js, šŸŒ Web, šŸ“œ Files, šŸ“° Docs, šŸ“˜ Wiki.

npm.io

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

PropertyDescription
includesCheck if sorted array has a value using binary search.
hasValueCheck if sorted array has a value using binary search.
indexOfFind first index of value using binary search.
lastIndexOfFind last index of value using binary search.
searchValueFind first index of value using binary search.
searchValueRightFind last index of a value using binary search.
searchValueAnyFind any index of a value using binary search.
searchClosestValueFind index of closest value using binary search.
mergeMerge values from two sorted arrays.
mergeAllMerge values from sorted arrays.
isUniqueExamine if there are no duplicate values.
isDisjointExamine if arrays have no value in common.
uniqueRemove duplicate values.
unionObtain values present in any sorted array.
intersectionObtain values present in both sorted arrays.
differenceObtain values not present in another sorted array.
symmetricDifferenceObtain values present in either sorted array but not both.

References

npm.io ORG Coverage Status Test Coverage

1.0.6

6 months ago

1.0.5

12 months ago

1.0.4

12 months ago

1.0.3

12 months ago

1.0.2

12 months ago

1.0.1

12 months ago

1.0.0

12 months ago

0.1.0

12 months ago

0.0.77

12 months ago

0.0.76

12 months ago

0.0.75

12 months ago

0.0.74

12 months ago

0.0.73

12 months ago

0.0.72

12 months ago

0.0.71

12 months ago

0.0.70

12 months ago

0.0.69

12 months ago

0.0.68

12 months ago

0.0.67

12 months ago

0.0.66

12 months ago

0.0.65

12 months ago

0.0.64

12 months ago

0.0.63

12 months ago

0.0.62

12 months ago

0.0.61

12 months ago

0.0.60

12 months ago

0.0.59

12 months ago

0.0.58

12 months ago

0.0.57

12 months ago

0.0.56

12 months ago

0.0.55

12 months ago

0.0.54

12 months ago

0.0.53

12 months ago

0.0.52

12 months ago

0.0.51

12 months ago

0.0.50

12 months ago

0.0.49

12 months ago

0.0.48

12 months ago

0.0.47

12 months ago

0.0.46

12 months ago

0.0.45

12 months ago

0.0.44

12 months ago

0.0.43

12 months ago

0.0.42

12 months ago

0.0.41

12 months ago

0.0.40

12 months ago

0.0.39

12 months ago

0.0.38

12 months ago

0.0.37

12 months ago

0.0.36

12 months ago

0.0.35

12 months ago

0.0.34

12 months ago

0.0.33

12 months ago

0.0.32

12 months ago

0.0.31

12 months ago

0.0.30

12 months ago

0.0.29

12 months ago

0.0.28

12 months ago

0.0.27

12 months ago

0.0.26

12 months ago

0.0.25

12 months ago

0.0.24

12 months ago

0.0.23

12 months ago

0.0.22

12 months ago

0.0.21

12 months ago

0.0.20

12 months ago

0.0.19

12 months ago

0.0.18

12 months ago

0.0.17

12 months ago

0.0.16

12 months ago

0.0.15

12 months ago

0.0.14

12 months ago

0.0.13

12 months ago

0.0.12

12 months ago