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.

30 lines
886 B

4 years ago
  1. var arrayFilter = require('./_arrayFilter'),
  2. stubArray = require('./stubArray');
  3. /** Used for built-in method references. */
  4. var objectProto = Object.prototype;
  5. /** Built-in value references. */
  6. var propertyIsEnumerable = objectProto.propertyIsEnumerable;
  7. /* Built-in method references for those with the same name as other `lodash` methods. */
  8. var nativeGetSymbols = Object.getOwnPropertySymbols;
  9. /**
  10. * Creates an array of the own enumerable symbols of `object`.
  11. *
  12. * @private
  13. * @param {Object} object The object to query.
  14. * @returns {Array} Returns the array of symbols.
  15. */
  16. var getSymbols = !nativeGetSymbols ? stubArray : function(object) {
  17. if (object == null) {
  18. return [];
  19. }
  20. object = Object(object);
  21. return arrayFilter(nativeGetSymbols(object), function(symbol) {
  22. return propertyIsEnumerable.call(object, symbol);
  23. });
  24. };
  25. module.exports = getSymbols;