extra-array
Advanced tools
Comparing version 4.0.126 to 4.0.127
136
index.js
@@ -483,2 +483,70 @@ 'use strict'; | ||
} | ||
function includes(x, v, i = 0) { | ||
return x.includes(v, i); | ||
} | ||
function hasValue(x, v, fc = null, fm = null) { | ||
return searchValue(x, v, fc, fm) >= 0; | ||
} | ||
function searchValue(x, v, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var w = fm(v, 0, null), i = -1; | ||
for (var vx of x) { | ||
var wx = fm(vx, ++i, x); | ||
if (fc(wx, w) === 0) | ||
return i; | ||
} | ||
return -1; | ||
} | ||
function searchValueRight(x, v, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var w = fm(v, 0, null); | ||
for (var i = x.length - 1; i >= 0; --i) { | ||
var wx = fm(x[i], i, x); | ||
if (fc(wx, w) === 0) | ||
return i; | ||
} | ||
return -1; | ||
} | ||
function searchValueAll(x, v, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var w = fm(v, 0, null); | ||
var i = -1, a = []; | ||
for (var vx of x) { | ||
var wx = fm(vx, ++i, x); | ||
if (fc(wx, w) === 0) | ||
a.push(i); | ||
} | ||
return a; | ||
} | ||
function searchAdjacentDuplicateValue(x, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var X = x.length; | ||
if (X <= 1) | ||
return -1; | ||
var w0 = fm(x[0], 0, x); | ||
for (var i = 1; i < X; ++i) { | ||
var w = fm(x[i], i, x); | ||
if (fc(w0, w) === 0) | ||
return i; | ||
w0 = w; | ||
} | ||
return -1; | ||
} | ||
function searchMismatchedValue(x, y, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var X = x.length; | ||
var Y = y.length; | ||
for (var i = 0, I = Math.min(X, Y); i < I; ++i) { | ||
var wx = fm(x[i], i, x); | ||
var wy = fm(y[i], i, y); | ||
if (fc(wx, wy) !== 0) | ||
return i; | ||
} | ||
return X === Y ? -1 : I; | ||
} | ||
function take(x, n = 1) { | ||
@@ -698,5 +766,2 @@ return x.slice(0, n); | ||
} | ||
function includes(x, v, i = 0) { | ||
return x.includes(v, i); | ||
} | ||
function indexOf(x, v, i = 0) { | ||
@@ -758,64 +823,2 @@ return x.indexOf(v, i); | ||
} | ||
function searchValue(x, v, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var w = fm(v, 0, null), i = -1; | ||
for (var vx of x) { | ||
var wx = fm(vx, ++i, x); | ||
if (fc(wx, w) === 0) | ||
return i; | ||
} | ||
return -1; | ||
} | ||
function searchValueRight(x, v, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var w = fm(v, 0, null); | ||
for (var i = x.length - 1; i >= 0; --i) { | ||
var wx = fm(x[i], i, x); | ||
if (fc(wx, w) === 0) | ||
return i; | ||
} | ||
return -1; | ||
} | ||
function searchValueAll(x, v, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var w = fm(v, 0, null); | ||
var i = -1, a = []; | ||
for (var vx of x) { | ||
var wx = fm(vx, ++i, x); | ||
if (fc(wx, w) === 0) | ||
a.push(i); | ||
} | ||
return a; | ||
} | ||
function searchAdjacentDuplicateValue(x, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var X = x.length; | ||
if (X <= 1) | ||
return -1; | ||
var w0 = fm(x[0], 0, x); | ||
for (var i = 1; i < X; ++i) { | ||
var w = fm(x[i], i, x); | ||
if (fc(w0, w) === 0) | ||
return i; | ||
w0 = w; | ||
} | ||
return -1; | ||
} | ||
function searchMismatchedValue(x, y, fc = null, fm = null) { | ||
var fc = fc || COMPARE; | ||
var fm = fm || IDENTITY; | ||
var X = x.length; | ||
var Y = y.length; | ||
for (var i = 0, I = Math.min(X, Y); i < I; ++i) { | ||
var wx = fm(x[i], i, x); | ||
var wy = fm(y[i], i, y); | ||
if (fc(wx, wy) !== 0) | ||
return i; | ||
} | ||
return X === Y ? -1 : I; | ||
} | ||
function searchInfix(x, y, fc = null, fm = null) { | ||
@@ -874,5 +877,2 @@ var fc = fc || COMPARE; | ||
} | ||
function hasValue(x, v, fc = null, fm = null) { | ||
return searchValue(x, v, fc, fm) >= 0; | ||
} | ||
function hasPrefix(x, y, fc = null, fm = null) { | ||
@@ -879,0 +879,0 @@ var Y = y.length; |
{ | ||
"name": "extra-array", | ||
"version": "4.0.126", | ||
"version": "4.0.127", | ||
"description": "An array is a collection of values, stored contiguously.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package