Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mikolalysenko/binary-merge
2-way merge
https://github.com/mikolalysenko/binary-merge
Last synced: about 2 months ago
JSON representation
2-way merge
- Host: GitHub
- URL: https://github.com/mikolalysenko/binary-merge
- Owner: mikolalysenko
- License: mit
- Created: 2013-03-31T15:31:43.000Z (over 11 years ago)
- Default Branch: master
- Last Pushed: 2021-10-03T18:14:06.000Z (about 3 years ago)
- Last Synced: 2024-10-22T08:56:10.616Z (2 months ago)
- Language: JavaScript
- Size: 113 KB
- Stars: 4
- Watchers: 3
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
binary-merge
============
[Merges a pair of sorted arrays.](http://en.wikipedia.org/wiki/Merge_algorithm)Use
===
First install via npm:npm install binary-merge
Then you can use the algorithm as follows:```javascript
var merge = require("binary-merge")console.log(merge([1,3,7], [2,4,6]))
// Prints:
//
// 1,2,3,4,6,7
//
```### `require("binary-merge")(a, b[, compare, result])`
The arguments are as follows:* `a` a sorted array
* `b` again, a sorted array
* `compare` an optional comparison function
* `result` an optional array which gets the result of merging a and b. If not specified, a new array is allocated.**Returns:** A sorted array.
**Time Complexity:** `O(a.length + b.length)`
Credits
=======
(c) 2013 Mikola Lysenko. MIT License