extra-array
Advanced tools
Comparing version 2.1.1 to 2.1.2
{ | ||
"name": "extra-array", | ||
"version": "2.1.1", | ||
"version": "2.1.2", | ||
"description": "Standard utility methods for Array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -89,67 +89,6 @@ /** | ||
/** | ||
* Checks if array starts with a prefix. | ||
* @param {Array} x source | ||
* @param {Array} y prefix? | ||
* @returns {boolean} true if prefix | ||
*/ | ||
function isPrefix(x, y) { | ||
var i = 0; | ||
for(var v of y) | ||
if(x[i]!==v) return false; | ||
return true; | ||
} | ||
/** | ||
* Checks if array ends with a suffix. | ||
* @param {Array} x source | ||
* @param {Array} y suffix? | ||
* @returns {boolean} true if suffix | ||
*/ | ||
function isSuffix(x, y) { | ||
var i = x.length - y.length; | ||
for(var v of y) | ||
if(x[i]!==v) return false; | ||
return true; | ||
} | ||
/** | ||
* Checks if array contains an infix. | ||
* @param {Array} x source | ||
* @param {Array} y infix? | ||
* @returns {boolean} true if infix | ||
*/ | ||
function isInfix(x, y) { | ||
var i = 0, I = y.length; | ||
for(var v of x) { | ||
if(v===y[i]) i++; | ||
else if(i<I) i = 0; | ||
} | ||
return i===I; | ||
} | ||
/** | ||
* Checks if array has a subsequence. | ||
* @param {Array} x source | ||
* @param {Array} y subsequence? | ||
* @returns {boolean} true if subsequence | ||
*/ | ||
function isSubsequence(x, y) { | ||
var i = 0, I = y.length; | ||
for(var v of x) | ||
if(v===y[i]) i++; | ||
return i===I; | ||
} | ||
/** | ||
* Checks if array has a permutation. | ||
* @param {Array} x source | ||
* @param {Array} y permutation? | ||
* @returns {boolean} true if permutation | ||
*/ | ||
function isPermutation(x, y) { | ||
var xa = x.slice.sort(); | ||
var ya = y.slice.sort(); | ||
return compare(xa, ya)===0; | ||
} | ||
@@ -156,0 +95,0 @@ |
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
95028
1537