UNPKG

@stdlib/esm

Version:

ES module distribution for Stdlib, a standard library for JavaScript and Node.js.

3 lines 1.56 kB
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0 import e from"./../../assert/is-positive-integer.js";import r from"./../../assert/is-array-like-object.js";import i from"./../../math/base/assert/is-positive-zero.js";import t from"./../../math/base/assert/is-negative-zero.js";import s from"./../../math/base/assert/is-nan.js";import a from"./../../constants/math/float64-pinf.js";import o from"./../../constants/math/float64-ninf.js";var f=e.isPrimitive,n=r,m=i,l=t,u=s,p=a,v=o;function b(e,r){var i,t,s,a,o,b,h;if(1===arguments.length)i=[0,0],o=e;else{if(!n(e))throw new TypeError("invalid argument. Output argument must be an array-like object. Value: `"+e+"`.");i=e,o=r}if(!f(o))throw new TypeError("invalid argument. Window size must be a positive integer. Value: `"+o+"`.");return t=new Array(o),s=p,a=v,h=-1,b=0,j;function j(e){var r,f,n;if(0===arguments.length)return 0===b?null:i;if(h=(h+1)%o,u(e))b=o,s=e,a=e;else if(b<o)b+=1,(e<s||e===s&&l(e))&&(s=e),(e>a||e===a&&m(e))&&(a=e);else if(t[h]===s&&e>s||t[h]===a&&e<a||u(t[h])){for(s=e,a=e,n=0;n<o;n++)if(n!==h){if(f=t[n],u(f)){s=f,a=f;break}(f<s||f===s&&l(f))&&(s=f),(f>a||f===a&&m(f))&&(a=f)}}else if(e<s)s=e;else if(e>a)a=e;else if(0===e){if(r=l(e),e===s)if(t[h]===s&&l(t[h])&&!1===r){for(s=e,n=0;n<o;n++)if(n!==h&&l(t[n])){s=t[n];break}}else r&&(s=e);if(e===a)if(t[h]===a&&m(t[h])&&r){for(a=e,n=0;n<o;n++)if(n!==h&&m(t[n])){a=t[n];break}}else!1===r&&(a=e)}return t[h]=e,i[0]=s,i[1]=a,i}}var h=b;export default h; //# sourceMappingURL=mminmax.js.map