array-combination

1.0.1 • Public • Published

array-combination

自由组合数组所有的可能 All the possibilities of a free combinatorial array

install

npm install --save array-combination

use

const arrayCombination = require('array-combination');

let optionList = {
  '姓名': [
    {name: '张三'},
    {name: '李四'},
  ],
  '年龄': [
    {age: '10-20'},
    {age: '20-30'},
  ],
  '其他': [
    {other: '是'},
    {other: '否'},
    {other: '1'},
  ],
};

let res = arrayCombination(optionList['姓名'], optionList['年龄'], optionList['其他']);
console.log(res);

// 输出 =>
[ [ { name: '张三' }, { age: '10-20' }, { other: '是' } ],
  [ { name: '张三' }, { age: '10-20' }, { other: '否' } ],
  [ { name: '张三' }, { age: '10-20' }, { other: '1' } ],
  [ { name: '张三' }, { age: '20-30' }, { other: '是' } ],
  [ { name: '张三' }, { age: '20-30' }, { other: '否' } ],
  [ { name: '张三' }, { age: '20-30' }, { other: '1' } ],
  [ { name: '李四' }, { age: '10-20' }, { other: '是' } ],
  [ { name: '李四' }, { age: '10-20' }, { other: '否' } ],
  [ { name: '李四' }, { age: '10-20' }, { other: '1' } ],
  [ { name: '李四' }, { age: '20-30' }, { other: '是' } ],
  [ { name: '李四' }, { age: '20-30' }, { other: '否' } ],
  [ { name: '李四' }, { age: '20-30' }, { other: '1' } ] ]

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i array-combination

      Weekly Downloads

      0

      Version

      1.0.1

      License

      ISC

      Unpacked Size

      2.55 kB

      Total Files

      3

      Last publish

      Collaborators

      • dearzoe