@stdlib/utils-group 0.2.1 → 0.2.3
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/NOTICE +1 -1
- package/README.md +7 -7
- package/dist/index.js +18 -6
- package/docs/types/index.d.ts +9 -2
- package/package.json +10 -10
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -77,7 +77,7 @@ var out = group( arr, groups );
|
|
|
77
77
|
|
|
78
78
|
The function accepts the following `options`:
|
|
79
79
|
|
|
80
|
-
-
|
|
80
|
+
- **returns**: specifies the output format. If the option equals `'values'`, the function outputs element values. If the option equals `'indices'`, the function outputs element indices. If the option equals `'*'`, the function outputs both element indices and values. Default: `'values'`.
|
|
81
81
|
|
|
82
82
|
By default, the function returns element values. To return element indices, set the `returns` option to `'indices'`.
|
|
83
83
|
|
|
@@ -127,7 +127,7 @@ var out = group( arr, opts, groups );
|
|
|
127
127
|
// returns { '[object Object]': [ 'beep', 'boop', 'foo', 'bar' ] }
|
|
128
128
|
```
|
|
129
129
|
|
|
130
|
-
while each "group" is unique, all collection elements resolve to the same group because each group identifier serializes to the same `string`.
|
|
130
|
+
while each "group" is unique, all collection elements resolve to the same group because each group identifier serializes to the same `string`.
|
|
131
131
|
|
|
132
132
|
</section>
|
|
133
133
|
|
|
@@ -227,7 +227,7 @@ See [LICENSE][stdlib-license].
|
|
|
227
227
|
|
|
228
228
|
## Copyright
|
|
229
229
|
|
|
230
|
-
Copyright © 2016-
|
|
230
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
231
231
|
|
|
232
232
|
</section>
|
|
233
233
|
|
|
@@ -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.
|
|
244
|
-
[test-url]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml?query=branch:v0.2.
|
|
243
|
+
[test-image]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml/badge.svg?branch=v0.2.3
|
|
244
|
+
[test-url]: https://github.com/stdlib-js/utils-group/actions/workflows/test.yml?query=branch:v0.2.3
|
|
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
|
|
@@ -253,8 +253,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
253
253
|
|
|
254
254
|
-->
|
|
255
255
|
|
|
256
|
-
[chat-image]: https://img.shields.io/
|
|
257
|
-
[chat-url]: https://
|
|
256
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
257
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
258
258
|
|
|
259
259
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
260
260
|
|
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
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
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
|
package/docs/types/index.d.ts
CHANGED
|
@@ -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
|
|
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
|
|
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.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Group values as arrays associated with distinct keys.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": {
|
|
@@ -30,15 +30,15 @@
|
|
|
30
30
|
"url": "https://github.com/stdlib-js/stdlib/issues"
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@stdlib/array-base-group-entries": "^0.2.
|
|
34
|
-
"@stdlib/array-base-group-indices": "^0.2.
|
|
35
|
-
"@stdlib/array-base-group-values": "^0.2.
|
|
36
|
-
"@stdlib/assert-has-own-property": "^0.2.
|
|
37
|
-
"@stdlib/assert-is-collection": "^0.2.
|
|
38
|
-
"@stdlib/assert-is-plain-object": "^0.2.
|
|
39
|
-
"@stdlib/string-format": "^0.2.
|
|
40
|
-
"@stdlib/utils-index-of": "^0.2.
|
|
41
|
-
"@stdlib/error-tools-fmtprodmsg": "^0.2.
|
|
33
|
+
"@stdlib/array-base-group-entries": "^0.2.3",
|
|
34
|
+
"@stdlib/array-base-group-indices": "^0.2.4",
|
|
35
|
+
"@stdlib/array-base-group-values": "^0.2.4",
|
|
36
|
+
"@stdlib/assert-has-own-property": "^0.2.3",
|
|
37
|
+
"@stdlib/assert-is-collection": "^0.2.3",
|
|
38
|
+
"@stdlib/assert-is-plain-object": "^0.2.3",
|
|
39
|
+
"@stdlib/string-format": "^0.2.3",
|
|
40
|
+
"@stdlib/utils-index-of": "^0.2.3",
|
|
41
|
+
"@stdlib/error-tools-fmtprodmsg": "^0.2.3"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {},
|
|
44
44
|
"engines": {
|