UNPKG

@stdlib/esm

Version:

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

3 lines 1.58 kB
// 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-collection.js";import t from"./../assert/is-plain-object.js";import n from"./../assert/has-own-property.js";import e from"./index-of.js";var o=t,i=n,s=e,a=["values","indices","*"];function u(r,t){return o(t)?i(t,"returns")&&(r.returns=t.returns,-1===s(a,r.returns))?new TypeError('invalid option. `returns` option must be one of the following: "'+a.join('", "')+'". Option: `'+r.returns+"`."):null:new TypeError("invalid argument. Options must be an object. Value: `"+t+"`.")}var l=n;function f(r,t){var n,e,o,i;for(e=r.length,n={},i=0;i<e;i++)o=t[i].toString(),l(n,o)?n[o].push(r[i]):n[o]=[r[i]];return n}var m=n;function g(r,t){var n,e,o,i;for(e=r.length,n={},i=0;i<e;i++)o=t[i].toString(),m(n,o)?n[o].push(i):n[o]=[i];return n}var p=n;function v(r,t){var n,e,o,i;for(e=r.length,n={},i=0;i<e;i++)o=t[i].toString(),p(n,o)?n[o].push([i,r[i]]):n[o]=[[i,r[i]]];return n}var h=r,c=u,w=f,d=g,b=v;function j(r,t,n){var e,o,i;if(!h(r))throw new TypeError("invalid argument. First argument must be a collection. Value: `"+r+"`.");if(e={returns:"values"},2===arguments.length)i=t;else{if(o=c(e,t))throw o;i=n}if(!h(i))throw new TypeError("invalid argument. Last argument must be a collection. Value: `"+i+"`.");if(r.length!==i.length)throw new RangeError("invalid arguments. First and last arguments must be the same length.");return"values"===e.returns?w(r,i):"indices"===e.returns?d(r,i):b(r,i)}var y=j;export default y; //# sourceMappingURL=group.js.map