index.js 555 B

12345678910111213141516171819
  1. "use strict";
  2. /**
  3. * Plugin dependencies
  4. */
  5. var Agent = require('../').Agent
  6. , semver = require('semver');
  7. /**
  8. * Checks if the user agent's version can be satisfied agents the give
  9. * ranged argument. This uses the semver libraries range construction.
  10. *
  11. * @param {String} ranged The range the version has to satisfie
  12. * @returns {Boolean}
  13. * @api public
  14. */
  15. Agent.prototype.satisfies = function satisfies (range) {
  16. return semver.satisfies((Number(this.major) || 0) + '.' + (Number(this.minor) || 0) + '.' + (Number(this.patch) || 0), range);
  17. };