helperCreateGetObjects.js 469 B

123456789101112131415161718192021
  1. var each = require('./each')
  2. function helperCreateGetObjects (name, getIndex) {
  3. var proMethod = Object[name]
  4. return function (obj) {
  5. var result = []
  6. if (obj) {
  7. if (proMethod) {
  8. return proMethod(obj)
  9. }
  10. each(obj, getIndex > 1 ? function (key) {
  11. result.push(['' + key, obj[key]])
  12. } : function () {
  13. result.push(arguments[getIndex])
  14. })
  15. }
  16. return result
  17. }
  18. }
  19. module.exports = helperCreateGetObjects