@stdlib/utils-group 0.2.1 → 0.2.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -240,8 +240,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
240
240
  [npm-image]: http://img.shields.io/npm/v/@stdlib/utils-group.svg
241
241
  [npm-url]: https://npmjs.org/package/@stdlib/utils-group
242
242
 
243
- [test-image]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml/badge.svg?branch=v0.2.1
244
- [test-url]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml?query=branch:v0.2.1
243
+ [test-image]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml/badge.svg?branch=v0.2.2
244
+ [test-url]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml?query=branch:v0.2.2
245
245
 
246
246
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/utils-group/main.svg
247
247
  [coverage-url]: https://codecov.io/github/stdlib-js/utils-group?branch=main
package/dist/index.js CHANGED
@@ -1,7 +1,19 @@
1
- "use strict";var a=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var l=a(function(V,v){
2
- var h=require('@stdlib/assert-is-plain-object/dist'),q=require('@stdlib/assert-has-own-property/dist'),w=require('@stdlib/utils-index-of/dist'),i=require('@stdlib/error-tools-fmtprodmsg/dist'),s=["values","indices","*"];function p(r,e){return h(e)?q(e,"returns")&&(r.returns=e.returns,w(s,r.returns)===-1)?new TypeError(i('1UJ4S',"returns",s.join('", "'),r.returns)):null:new TypeError(i('1UJ2V',e));}v.exports=p
3
- });var o=a(function(j,g){
4
- var m=require('@stdlib/assert-is-collection/dist'),b=require('@stdlib/array-base-group-values/dist'),c=require('@stdlib/array-base-group-indices/dist'),E=require('@stdlib/array-base-group-entries/dist'),f=require('@stdlib/error-tools-fmtprodmsg/dist'),O=l();function x(r,e,d){var u,n,t;if(!m(r))throw new TypeError(f('1UJAh',r));if(u={returns:"values"},arguments.length===2)t=e;else{if(n=O(u,e),n)throw n;t=d}if(!m(t))throw new TypeError(f('1UJAm',t));if(r.length!==t.length)throw new RangeError(f('1UJ1a'));return u.returns==="values"?b(r,t):u.returns==="indices"?c(r,t):E(r,t)}g.exports=x
5
- });var y=o();module.exports=y;
6
- /** @license Apache-2.0 */
1
+ "use strict";var a=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var l=a(function(V,v){"use strict";var h=require("@stdlib/assert-is-plain-object"),q=require("@stdlib/assert-has-own-property"),w=require("@stdlib/utils-index-of"),i=require("@stdlib/string-format"),s=["values","indices","*"];function p(r,e){return h(e)?q(e,"returns")&&(r.returns=e.returns,w(s,r.returns)===-1)?new TypeError(i('invalid option. `%s` option must be one of the following: "%s". Option: `%s`.',"returns",s.join('", "'),r.returns)):null:new TypeError(i("invalid argument. Options argument must be an object. Value: `%s`.",e))}v.exports=p});var o=a(function(j,g){"use strict";var m=require("@stdlib/assert-is-collection"),b=require("@stdlib/array-base-group-values"),c=require("@stdlib/array-base-group-indices"),E=require("@stdlib/array-base-group-entries"),f=require("@stdlib/string-format"),O=l();function x(r,e,d){var u,n,t;if(!m(r))throw new TypeError(f("invalid argument. First argument must be a collection. Value: `%s`.",r));if(u={returns:"values"},arguments.length===2)t=e;else{if(n=O(u,e),n)throw n;t=d}if(!m(t))throw new TypeError(f("invalid argument. Last argument must be a collection. Value: `%s`.",t));if(r.length!==t.length)throw new RangeError("invalid arguments. First and last arguments must be the same length.");return u.returns==="values"?b(r,t):u.returns==="indices"?c(r,t):E(r,t)}g.exports=x});var y=o();module.exports=y;
2
+ /**
3
+ * @license Apache-2.0
4
+ *
5
+ * Copyright (c) 2018 The Stdlib Authors.
6
+ *
7
+ * Licensed under the Apache License, Version 2.0 (the "License");
8
+ * you may not use this file except in compliance with the License.
9
+ * You may obtain a copy of the License at
10
+ *
11
+ * http://www.apache.org/licenses/LICENSE-2.0
12
+ *
13
+ * Unless required by applicable law or agreed to in writing, software
14
+ * distributed under the License is distributed on an "AS IS" BASIS,
15
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16
+ * See the License for the specific language governing permissions and
17
+ * limitations under the License.
18
+ */
7
19
  //# sourceMappingURL=index.js.map
@@ -51,7 +51,10 @@ interface Options {
51
51
  * var out = group( arr, groups );
52
52
  * // returns { 'b': [ 'beep', 'boop', 'bar' ], 'f': [ 'foo' ] }
53
53
  */
54
- declare function group( collection: Collection, groups: Collection ): any;
54
+ declare function group<T, K extends PropertyKey>(
55
+ collection: Collection<T>,
56
+ groups: Collection<K>
57
+ ): { [key in K]: Collection<T> };
55
58
 
56
59
  /**
57
60
  * Groups values as arrays associated with distinct keys.
@@ -89,7 +92,11 @@ declare function group( collection: Collection, groups: Collection ): any;
89
92
  * var out = group( arr, opts, groups );
90
93
  * // returns { 'b': [ [ 0, 'beep' ], [ 1, 'boop' ], [ 3, 'bar' ] ], 'f': [ [ 2, 'foo' ] ] }
91
94
  */
92
- declare function group( collection: Collection, options: Options, groups: Collection ): any;
95
+ declare function group<T, K extends PropertyKey>(
96
+ collection: Collection<T>,
97
+ options: Options,
98
+ groups: Collection<K>
99
+ ): { [key in K]: Collection<T> };
93
100
 
94
101
 
95
102
  // EXPORTS //
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/utils-group",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "Group values as arrays associated with distinct keys.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -31,14 +31,14 @@
31
31
  },
32
32
  "dependencies": {
33
33
  "@stdlib/array-base-group-entries": "^0.2.1",
34
- "@stdlib/array-base-group-indices": "^0.2.1",
35
- "@stdlib/array-base-group-values": "^0.2.1",
36
- "@stdlib/assert-has-own-property": "^0.2.1",
37
- "@stdlib/assert-is-collection": "^0.2.1",
38
- "@stdlib/assert-is-plain-object": "^0.2.1",
39
- "@stdlib/string-format": "^0.2.1",
40
- "@stdlib/utils-index-of": "^0.2.1",
41
- "@stdlib/error-tools-fmtprodmsg": "^0.2.1"
34
+ "@stdlib/array-base-group-indices": "^0.2.2",
35
+ "@stdlib/array-base-group-values": "^0.2.2",
36
+ "@stdlib/assert-has-own-property": "^0.2.2",
37
+ "@stdlib/assert-is-collection": "^0.2.2",
38
+ "@stdlib/assert-is-plain-object": "^0.2.2",
39
+ "@stdlib/string-format": "^0.2.2",
40
+ "@stdlib/utils-index-of": "^0.2.2",
41
+ "@stdlib/error-tools-fmtprodmsg": "^0.2.2"
42
42
  },
43
43
  "devDependencies": {},
44
44
  "engines": {