0.0.4 • Published 7 years ago

object-attribute-combination v0.0.4

Weekly downloads
24
License
MIT
Repository
github
Last release
7 years ago

Generating all combination of object attribute for node.

var attrcomb = require('object-attribute-combination');

var  obj: {
    'integerVal': 1000000,
    'stringVal': 'testing !@# value',
    'booleanVal': true,
    'objVal': {
    'str2': 'test_QWE123',
    'int2': -5000
  }
},
var result = attrcomb.power(obj);

/*
  [ { integerVal: 1000000 },
    { integerVal: 1000000, stringVal: 'testing !@# value' },
    { integerVal: 1000000,
      stringVal: 'testing !@# value',
      booleanVal: true },
    { integerVal: 1000000,
      stringVal: 'testing !@# value',
      booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { integerVal: 1000000,
      stringVal: 'testing !@# value',
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { integerVal: 1000000, booleanVal: true },
    { integerVal: 1000000,
      booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { integerVal: 1000000,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { stringVal: 'testing !@# value' },
    { stringVal: 'testing !@# value', booleanVal: true },
    { stringVal: 'testing !@# value',
      booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { stringVal: 'testing !@# value',
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { booleanVal: true },
    { booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { objVal: { str2: 'test_QWE123', int2: -5000 } }
  ]
*/

var result2 = attrcomb.power(obj, 2, 3); // Only show object having 2 ~ 3 attributes 

/*
  [{ integerVal: 1000000, stringVal: 'testing !@# value' },
    { integerVal: 1000000,
      stringVal: 'testing !@# value',
      booleanVal: true },
    { integerVal: 1000000,
      stringVal: 'testing !@# value',
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { integerVal: 1000000, booleanVal: true },
    { integerVal: 1000000,
      booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { integerVal: 1000000,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { stringVal: 'testing !@# value', booleanVal: true },
    { stringVal: 'testing !@# value',
      booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { stringVal: 'testing !@# value',
      objVal: { str2: 'test_QWE123', int2: -5000 } },
    { booleanVal: true,
      objVal: { str2: 'test_QWE123', int2: -5000 } }
  ]
*/

Installation

$ npm install object-attribute-combination

Features

  • Build all object attribute combination for testing

Tests

$ npm install
$ npm test

People

The original author of is Edward Ma

License

MIT