https://github.com/afeiship/next-group-by
Creates an object composed of keys generated from the results of running each element of collection thru iteratee.
https://github.com/afeiship/next-group-by
computed group group-by next stat total
Last synced: 26 days ago
JSON representation
Creates an object composed of keys generated from the results of running each element of collection thru iteratee.
- Host: GitHub
- URL: https://github.com/afeiship/next-group-by
- Owner: afeiship
- License: mit
- Created: 2017-10-06T07:57:16.000Z (over 8 years ago)
- Default Branch: main
- Last Pushed: 2024-07-31T12:05:46.000Z (almost 2 years ago)
- Last Synced: 2025-10-11T22:38:27.969Z (7 months ago)
- Topics: computed, group, group-by, next, stat, total
- Language: JavaScript
- Homepage:
- Size: 59.6 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README
# next-group-by
> Creates an object composed of keys generated from the results of running each element of collection thru iteratee.
[![version][version-image]][version-url]
[![license][license-image]][license-url]
[![size][size-image]][size-url]
[![download][download-image]][download-url]
## installation
```bash
npm install -S @jswork/next-group-by
```
## usage
```js
import '@jswork/next-group-by';
const arr = [
'sljflsdjf.jpg',
'bb.jpg',
'bc.jpg',
'ccsdf.jpg',
'ccsdf.jpg',
'http://www.agc.cn/1.jpg',
'sldjfsld.jpg',
'wx://localResource'
];
const res = nx.groupBy(arr, (item) => {
var rs = item.split('://');
return rs.length === 2 ? rs[0] : 'normal';
});
// result
{
normal: [
'sljflsdjf.jpg',
'bb.jpg',
'bc.jpg',
'ccsdf.jpg',
'ccsdf.jpg',
'sldjfsld.jpg'
],
http: [ 'http://www.agc.cn/1.jpg' ],
wx: [ 'wx://localResource' ],
__computed__: {
normal: 6,
http: 1,
wx: 1
}
}
```
## license
Code released under [the MIT license](https://github.com/afeiship/next-group-by/blob/master/LICENSE.txt).
[version-image]: https://img.shields.io/npm/v/@jswork/next-group-by
[version-url]: https://npmjs.org/package/@jswork/next-group-by
[license-image]: https://img.shields.io/npm/l/@jswork/next-group-by
[license-url]: https://github.com/afeiship/next-group-by/blob/master/LICENSE.txt
[size-image]: https://img.shields.io/bundlephobia/minzip/@jswork/next-group-by
[size-url]: https://github.com/afeiship/next-group-by/blob/master/dist/next-group-by.min.js
[download-image]: https://img.shields.io/npm/dm/@jswork/next-group-by
[download-url]: https://www.npmjs.com/package/@jswork/next-group-by