@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 4.53 kB
JavaScript
// 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-nonnegative-integer.js";import r from"./../assert/is-positive-integer.js";import t from"./../assert/is-integer.js";import n from"./../assert/is-function-array.js";import a from"./../assert/is-function.js";import i from"./../assert/is-string-array.js";import o from"./../assert/is-array-like-object.js";import u from"./../math/base/special/abs.js";import s from"./../ndarray/base/buffer-dtype.js";function m(e,r,t,n,a,i,o,u,s){var m,d,f,g;for(m=i,f=0;f<e;f++){for(d=s,g=0;g<r&&t[m+g*a]===o[d];g++)d+=u;if(g===r)return f;m+=n}return-1}var d=e.isPrimitive,f=r,g=t.isPrimitive,p=n,l=a,h=i.primitives,v=o,y=u,w=s,c=m;function b(e,r,t,n,a,i){var o,u,s,m,b,E;if(l(e))E=e;else if(!p(e))throw new TypeError("invalid argument. First argument must be either a function or an array of functions. Value: `"+e+"`.");if(!h(r))throw new TypeError("invalid argument. Second argument must be an array of strings. Value: `"+r+"`.");if(!v(t)&&null!==t)throw new TypeError("invalid argument. Third argument must be an array-like object or `null`. Value: `"+t+"`.");if(!f(n))throw new TypeError("invalid argument. Fourth argument must be a positive integer. Value: `"+n+"`.");if(!d(a))throw new TypeError("invalid argument. Fifth argument must be a nonnegative integer. Value: `"+a+"`.");if(!d(i))throw new TypeError("invalid argument. Sixth argument must be a nonnegative integer. Value: `"+i+"`.");if(0===(s=a+i))throw new Error("invalid arguments. Interface must accept at least one strided input and/or output array. Based on the provided arguments, `nin+nout` equals `0`.");if(E){if(m=r.length/s,!g(m))throw new Error("invalid argument. Unexpected number of types. A type must be specified for each strided input and output array for each provided strided array function.")}else if(m=e.length,r.length!==m*s)throw new Error("invalid argument. Unexpected number of types. A type must be specified for each strided input and output array for each provided strided array function.");if(t&&t.length!==m)throw new Error("invalid argument. The third argument must have the same number of elements as the first argument.");if(2*s+1===n)u=!1;else{if(3*s+1!==n)throw new Error("invalid argument. Fourth argument is incompatible with the number of strided input and output arrays.");u=!0}return b=a*(o=u?3:2)+1,function(){var f,p,l,h,T,j,x,I,V,F,O,k;if((j=arguments.length)!==n){if(j<n)throw new Error("invalid invocation. Insufficient arguments.");throw new Error("invalid invocation. Too many arguments.")}if(!g(I=arguments[0]))throw new TypeError("invalid argument. First argument must be an integer.");for(T=[I],f=[],O=2;O<n;O+=o){if(!g(V=arguments[O]))throw O<b?new TypeError("invalid argument. Input array stride argument must be an integer."):new TypeError("invalid argument. Output array stride argument must be an integer.");f.push(V)}if(u)for(p=[],O=3;O<n;O+=o){if(!d(V=arguments[O]))throw O<b?new TypeError("invalid argument. Input array offset argument must be a nonnegative integer."):new TypeError("invalid argument. Output array offset argument must be a nonnegative integer.");p.push(V)}for(l=[],h=[],O=1;O<n;O+=o){if(!v(V=arguments[O]))throw O<b?new TypeError("invalid argument. Input array argument must be an array-like object."):new TypeError("invalid argument. Output array argument must be an array-like object.");if(k=(O-1)/o,u){if(x=p[k]+(I-1)*f[k],I>0&&(x<0||x>=V.length))throw O<b?new RangeError("invalid argument. Input array argument has insufficient elements based on the associated stride and the number of indexed elements."):new RangeError("invalid argument. Output array argument has insufficient elements based on the associated stride and the number of indexed elements.")}else if((I-1)*y(f[k])>=V.length)throw O<b?new RangeError("invalid argument. Input array argument has insufficient elements based on the associated stride and the number of indexed elements."):new RangeError("invalid argument. Output array argument has insufficient elements based on the associated stride and the number of indexed elements.");l.push(V),h.push(w(V))}if((x=c(m,s,r,s,1,0,h,1,0))<0)throw new TypeError("invalid arguments. Unable to resolve a strided array function supporting the provided array argument data types.");F=E||e[x];t?u?F(l,T,f,p,t[x]):F(l,T,f,t[x]):u?F(l,T,f,p):F(l,T,f);if(1===i)return l[s-1];if(0===i)return;return l.slice(a)}}var E=b;export default E;
//# sourceMappingURL=dispatch.js.map