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.

18 lines
405 B

4 years ago
  1. 'use strict';
  2. module.exports = function flip() {
  3. var _this = this;
  4. var collection = {};
  5. if (Array.isArray(this.items)) {
  6. Object.keys(this.items).forEach(function (key) {
  7. collection[_this.items[key]] = Number(key);
  8. });
  9. } else {
  10. Object.keys(this.items).forEach(function (key) {
  11. collection[_this.items[key]] = key;
  12. });
  13. }
  14. return new this.constructor(collection);
  15. };