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 } }
]
*/
$ npm install object-attribute-combination
- Build all object attribute combination for testing
$ npm install
$ npm test
The original author of is Edward Ma