@stdlib/esm
Version:
ES module distribution for Stdlib, a standard library for JavaScript and Node.js.
3 lines • 1.51 kB
JavaScript
// This file is a part of stdlib. License is Apache-2.0: http://www.apache.org/licenses/LICENSE-2.0
import r from"./../assert/is-function.js";import e from"./../assert/is-integer.js";import i from"./../assert/is-plain-object.js";import t from"./../assert/is-string.js";import s from"./../assert/is-collection.js";import n from"./../assert/has-own-property.js";var a=r,o=e.isPrimitive,u=i,l=t.isPrimitive,f=s,m=n;function p(r,e,i){var t,s,n,p,h,v,g,w,c,d,j;if(n=0,t=["values","indices","*"],!f(r)&&!l(r))throw new TypeError("invalid argument. Must provide an array-like object. Value: `"+r+"`");if(h=r.length,arguments.length<3?(p={},w=e):(p=e,w=i),!a(w))throw new TypeError("invalid argument. Callback argument must be a function. Value: `"+w+"`");if(!u(p))throw new TypeError("invalid argument. Options must be an object. Value: `"+p+"`");if(m(p,"k")){if(d=p.k,!o(d))throw new TypeError("invalid argument. `k` must be an integer. Value: `"+d+"`")}else d=h;if(m(p,"returns")){if(g=p.returns,!l(g)||-1===t.indexOf(g))throw new TypeError("invalid argument. `returns` option must be a string and have one of the following values: `values`, `indices`, `all`. Value: `"+g+"`");"values"===g?n=1:"*"===g&&(n=2)}if(v=[],s=0,0===d)return v;if(d>0){for(c=0;c<h&&(!w(j=r[c],c,r)||(2===n?v.push([c,j]):1===n?v.push(j):v.push(c),(s+=1)!==d));c++);return v}for(d=-d,c=h-1;c>=0&&(!w(j=r[c],c,r)||(2===n?v.push([c,j]):1===n?v.push(j):v.push(c),(s+=1)!==d));c--);return v}var h=p;export default h;
//# sourceMappingURL=find.js.map