UNPKG

algs4js

Version:

Basic algorithms and data structures implemented with es6

32 lines (23 loc) 1.59 kB
'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } var ArrayMap = function () { function ArrayMap() { _classCallCheck(this, ArrayMap); } _createClass(ArrayMap, null, [{ key: 'findSportsAuthors', value: function findSportsAuthors(authors) { return authors.filter(function (author) { return author.sections.indexOf('Sports') !== -1; }); } }]); return ArrayMap; }(); var authors = [{ name: 'Steve Trevor', sections: ['Leisure', 'Sports'] }, { name: 'Lin Clark', sections: ['Cooking', 'Art'] }, { name: 'Homer Simpson', sections: ['Politics', 'Pets'] }, { name: 'Quikcie Mart', sections: ['Math', 'Chess'] }, { name: 'Bart Simpson', sections: ['Fine Dining', 'Sports'] }]; console.log('The sports authors are: ' + JSON.stringify(ArrayMap.findSportsAuthors(authors))); exports.default = ArrayMap;