@feizheng/next-group-by

1.2.1 • Public • Published

next-group-by

Creates an object composed of keys generated from the results of running each element of collection thru iteratee.

version license size download

installation

npm install -S @feizheng/next-group-by

usage

import '@feizheng/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' ]
}

license

Code released under the MIT license.

Dependencies (0)

    Dev Dependencies (18)

    Package Sidebar

    Install

    npm i @feizheng/next-group-by

    Weekly Downloads

    1

    Version

    1.2.1

    License

    MIT

    Unpacked Size

    5.63 kB

    Total Files

    5

    Last publish

    Collaborators

    • afeiship