You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
huazhiyu/node_modules/utils-extend/test/pick.js

29 lines
603 B

var assert = require('assert');
var util = require('../index');
describe('pick', function() {
it('Pick with keys', function() {
var obj = {
key1: 1,
key2: 2
};
var result = util.pick(obj, 'key1', 'key3');
assert.deepEqual(result, { key1: 1 });
});
it('Pick with function', function() {
var obj = {
key1: 1,
key2: '2',
key3: {
k: 'v'
}
};
var result = util.pick(obj, function(value) {
return util.isNumber(value) || util.isObject(value);
});
assert.deepEqual(result, { key1: 1, key3: { k: 'v' } });
});
});