+19
-3
| var clone = require('clone'); | ||
| function hasPro(obj, pro, canBeEmpty) { | ||
| return obj.hasOwnProperty(pro) && (canBeEmpty ? true : obj[pro] != undefined) | ||
| return Object.hasOwnProperty.call(obj, pro) && (canBeEmpty ? true : obj[pro] != undefined) | ||
| } | ||
| function mapObj (origin, target, proList, canBeEmpty) { | ||
| function mapObj(origin, target, proList, canBeEmpty) { | ||
| var _origin = clone(origin); | ||
@@ -21,2 +21,18 @@ proList.forEach(function(v, i) { | ||
| module.exports = mapObj; | ||
| var q = { | ||
| currentPage: "1", | ||
| endTime: "2017-11-12", | ||
| keyWord:"1", | ||
| pageSize:"10", | ||
| startTime:"2017-10-11", | ||
| status:"2" | ||
| } | ||
| const obj = {} | ||
| map = mapObj(q, obj, ['keyWord', 'startTime', 'endTime']) | ||
| // map('b', ori => String(ori)) | ||
| console.log(obj) | ||
| // module.exports = mapObj; |
+1
-1
| { | ||
| "name": "mapobj", | ||
| "version": "1.0.1", | ||
| "version": "1.0.2", | ||
| "description": "map obj", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
1576
21.7%32
60%