extra-array
Advanced tools
Comparing version 2.0.25 to 2.0.26
12
index.js
@@ -25,13 +25,3 @@ const exports0 = Array.isArray; | ||
} | ||
function arange(x1, x2, stp=1, z=[], z0=z.length) { | ||
for(var z1=z0+Math.max(Math.ceil((x2-x1)/stp), 0); z0<z1; x1+=stp) | ||
z[z0++] = x1; | ||
return z; | ||
} | ||
function linspace(x1, x2, n=100) { | ||
var z = []; | ||
for(var i=0, dx=(x2-x1)/(n-1); i<n; i++) | ||
z[i] = x1+(i*dx); | ||
return z; | ||
} | ||
function fromEntries(ent, fn, ths) { | ||
@@ -38,0 +28,0 @@ var z = []; |
{ | ||
"name": "extra-array", | ||
"version": "2.0.25", | ||
"version": "2.0.26", | ||
"description": "Standard utility methods for Array.", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -437,3 +437,31 @@ /** | ||
/** | ||
* Returns evenly spaced values within given interval. | ||
* @param {number} v start of interval | ||
* @param {number} V end of interval (excluding) | ||
* @param {number?} stp spacing between values (def: 1) | ||
* @returns {Array} result | ||
*/ | ||
function arange(v, V, stp=1) { | ||
var a = []; | ||
for(; v<V; v+=stp) | ||
a.push(v); | ||
return a; | ||
} | ||
/** | ||
* Returns evenly spaced values withing given interval. | ||
* @param {number} v start of interval | ||
* @param {number} V end of interval | ||
* @param {number?} n no. of values in between (def: 100) | ||
* @returns {Array} result | ||
*/ | ||
function linspace(v, V, n=100) { | ||
var stp = (V-v)/(n-1); | ||
return arange(v, V+stp, stp); | ||
} | ||
function searchl(x, fn, ths=null) { | ||
@@ -440,0 +468,0 @@ for(var i=0, I=x.length; i<I; i++) |
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
33094
1055