From 47d06259bc58b6ae0ae9f23a5c0f66b3db1eb610 Mon Sep 17 00:00:00 2001 From: Damon Oehlman Date: Mon, 30 Jun 2014 14:02:35 +1000 Subject: [PATCH] Remove match helper --- match.js | 57 -------------------------------------------------------- 1 file changed, 57 deletions(-) delete mode 100644 match.js diff --git a/match.js b/match.js deleted file mode 100644 index f9d501f..0000000 --- a/match.js +++ /dev/null @@ -1,57 +0,0 @@ -/* jshint node: true */ -'use strict'; - -var detect = require('./detect'); -var semver = require('semver'); - -/** - ## rtc-core/match - - ``` - match(browser, spec?, fn?) ==> Boolean - ``` - - The `match` helper is useful for customizing the behaviour of your WebRTC - application based on browser environment and also specific versions of - the browser (using a [semver](http://semver.org/) based spec). The optional - `fn` argument allows you to provide a function you wish to be called given - a match rather as this is sometimes useful. - - <<< examples/match.js - -**/ -module.exports = function(browser, spec, fn) { - var isMatch = false; - var version = semver.clean(detect.version); - - if (typeof spec == 'function') { - fn = spec; - spec = ''; - } - - // ensure spec is a string value - spec = spec || ''; - - // if the version it not valid, then error out - if (spec && (! version)) { - throw new Error('Browser version is not semver compatible: ' + detect.version); - } - - // first check the browser name - if (browser instanceof RegExp) { - isMatch = browser.test(detect.browser); - } - else { - isMatch = browser === detect.browser; - } - - // check the spec - isMatch = isMatch && semver.satisfies(version, spec); - - // if we have a match and a handler, then invoke the handler - if (isMatch && typeof fn == 'function') { - fn(); - } - - return isMatch; -}; \ No newline at end of file