Comparing version 0.4.0 to 0.5.0
## [Unreleased] | ||
## 0.5.0 - 2015-12-04 | ||
### Changed | ||
- `getActiveElement`: No longer handles a non-existent `document` | ||
## 0.4.0 - 2015-10-16 | ||
@@ -4,0 +10,0 @@ |
@@ -17,9 +17,5 @@ /** | ||
* | ||
* The activeElement will be null only if the document or document body is not yet defined. | ||
* The activeElement will be null only if the document body is not yet defined. | ||
*/ | ||
function getActiveElement() /*?DOMElement*/ { | ||
if (typeof document === 'undefined') { | ||
return null; | ||
} | ||
try { | ||
@@ -26,0 +22,0 @@ return document.activeElement || document.body; |
@@ -14,4 +14,5 @@ /** | ||
var performance = require('performance'); | ||
var curPerformance = performance; | ||
var performanceNow; | ||
/** | ||
@@ -22,8 +23,8 @@ * Detect if we can use `window.performance.now()` and gracefully fallback to | ||
*/ | ||
if (!curPerformance || !curPerformance.now) { | ||
curPerformance = Date; | ||
if (performance.now) { | ||
performanceNow = () => performance.now(); | ||
} else { | ||
performanceNow = () => Date.now(); | ||
} | ||
var performanceNow = curPerformance.now.bind(curPerformance); | ||
module.exports = performanceNow; |
@@ -19,3 +19,3 @@ /** | ||
import type * as Promise from 'Promise'; | ||
import type Promise from 'Promise'; | ||
@@ -22,0 +22,0 @@ /** |
@@ -12,249 +12,249 @@ /** | ||
'use strict'; | ||
'use strict'; | ||
var UserAgentData = require('UserAgentData'); | ||
var VersionRange = require('VersionRange'); | ||
var UserAgentData = require('UserAgentData'); | ||
var VersionRange = require('VersionRange'); | ||
var mapObject = require('mapObject'); | ||
var memoizeStringOnly = require('memoizeStringOnly'); | ||
var mapObject = require('mapObject'); | ||
var memoizeStringOnly = require('memoizeStringOnly'); | ||
/** | ||
* Checks to see whether `name` and `version` satisfy `query`. | ||
* | ||
* @param {string} name Name of the browser, device, engine or platform | ||
* @param {?string} version Version of the browser, engine or platform | ||
* @param {string} query Query of form "Name [range expression]" | ||
* @param {?function} normalizer Optional pre-processor for range expression | ||
* @return {boolean} | ||
*/ | ||
function compare(name, version, query, normalizer) { | ||
// check for exact match with no version | ||
if (name === query) { | ||
return true; | ||
} | ||
/** | ||
* Checks to see whether `name` and `version` satisfy `query`. | ||
* | ||
* @param {string} name Name of the browser, device, engine or platform | ||
* @param {?string} version Version of the browser, engine or platform | ||
* @param {string} query Query of form "Name [range expression]" | ||
* @param {?function} normalizer Optional pre-processor for range expression | ||
* @return {boolean} | ||
*/ | ||
function compare(name, version, query, normalizer) { | ||
// check for exact match with no version | ||
if (name === query) { | ||
return true; | ||
} | ||
// check for non-matching names | ||
if (!query.startsWith(name)) { | ||
return false; | ||
} | ||
// check for non-matching names | ||
if (!query.startsWith(name)) { | ||
return false; | ||
} | ||
// full comparison with version | ||
var range = query.slice(name.length); | ||
if (version) { | ||
range = normalizer ? normalizer(range) : range; | ||
return VersionRange.contains(range, version); | ||
} | ||
// full comparison with version | ||
var range = query.slice(name.length); | ||
if (version) { | ||
range = normalizer ? normalizer(range) : range; | ||
return VersionRange.contains(range, version); | ||
} | ||
return false; | ||
} | ||
return false; | ||
} | ||
/** | ||
* Normalizes `version` by stripping any "NT" prefix, but only on the Windows | ||
* platform. | ||
* | ||
* Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class. | ||
* | ||
* @param {string} version | ||
* @return {string} | ||
*/ | ||
function normalizePlatformVersion(version) { | ||
if (UserAgentData.platformName === 'Windows') { | ||
return version.replace(/^\s*NT/, ''); | ||
} | ||
/** | ||
* Normalizes `version` by stripping any "NT" prefix, but only on the Windows | ||
* platform. | ||
* | ||
* Mimics the stripping performed by the `UserAgentWindowsPlatform` PHP class. | ||
* | ||
* @param {string} version | ||
* @return {string} | ||
*/ | ||
function normalizePlatformVersion(version) { | ||
if (UserAgentData.platformName === 'Windows') { | ||
return version.replace(/^\s*NT/, ''); | ||
} | ||
return version; | ||
} | ||
return version; | ||
} | ||
/** | ||
* Provides client-side access to the authoritative PHP-generated User Agent | ||
* information supplied by the server. | ||
*/ | ||
var UserAgent = { | ||
/** | ||
* Check if the User Agent browser matches `query`. | ||
* | ||
* `query` should be a string like "Chrome" or "Chrome > 33". | ||
* | ||
* Valid browser names include: | ||
* | ||
* - ACCESS NetFront | ||
* - AOL | ||
* - Amazon Silk | ||
* - Android | ||
* - BlackBerry | ||
* - BlackBerry PlayBook | ||
* - Chrome | ||
* - Chrome for iOS | ||
* - Chrome frame | ||
* - Facebook PHP SDK | ||
* - Facebook for iOS | ||
* - Firefox | ||
* - IE | ||
* - IE Mobile | ||
* - Mobile Safari | ||
* - Motorola Internet Browser | ||
* - Nokia | ||
* - Openwave Mobile Browser | ||
* - Opera | ||
* - Opera Mini | ||
* - Opera Mobile | ||
* - Safari | ||
* - UIWebView | ||
* - Unknown | ||
* - webOS | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `BrowserDetector` class and | ||
* related classes in the same file (see calls to `new UserAgentBrowser` here: | ||
* https://fburl.com/50728104). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name [range expression]" | ||
* @return {boolean} | ||
*/ | ||
isBrowser(query) { | ||
return compare( | ||
UserAgentData.browserName, | ||
UserAgentData.browserFullVersion, | ||
query | ||
); | ||
}, | ||
/** | ||
* Provides client-side access to the authoritative PHP-generated User Agent | ||
* information supplied by the server. | ||
*/ | ||
var UserAgent = { | ||
/** | ||
* Check if the User Agent browser matches `query`. | ||
* | ||
* `query` should be a string like "Chrome" or "Chrome > 33". | ||
* | ||
* Valid browser names include: | ||
* | ||
* - ACCESS NetFront | ||
* - AOL | ||
* - Amazon Silk | ||
* - Android | ||
* - BlackBerry | ||
* - BlackBerry PlayBook | ||
* - Chrome | ||
* - Chrome for iOS | ||
* - Chrome frame | ||
* - Facebook PHP SDK | ||
* - Facebook for iOS | ||
* - Firefox | ||
* - IE | ||
* - IE Mobile | ||
* - Mobile Safari | ||
* - Motorola Internet Browser | ||
* - Nokia | ||
* - Openwave Mobile Browser | ||
* - Opera | ||
* - Opera Mini | ||
* - Opera Mobile | ||
* - Safari | ||
* - UIWebView | ||
* - Unknown | ||
* - webOS | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `BrowserDetector` class and | ||
* related classes in the same file (see calls to `new UserAgentBrowser` here: | ||
* https://fburl.com/50728104). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name [range expression]" | ||
* @return {boolean} | ||
*/ | ||
isBrowser(query) { | ||
return compare( | ||
UserAgentData.browserName, | ||
UserAgentData.browserFullVersion, | ||
query | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent browser uses a 32 or 64 bit architecture. | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "32" or "64". | ||
* @return {boolean} | ||
*/ | ||
isBrowserArchitecture(query) { | ||
return compare( | ||
UserAgentData.browserArchitecture, | ||
null, | ||
query | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent browser uses a 32 or 64 bit architecture. | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "32" or "64". | ||
* @return {boolean} | ||
*/ | ||
isBrowserArchitecture(query) { | ||
return compare( | ||
UserAgentData.browserArchitecture, | ||
null, | ||
query | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent device matches `query`. | ||
* | ||
* `query` should be a string like "iPhone" or "iPad". | ||
* | ||
* Valid device names include: | ||
* | ||
* - Kindle | ||
* - Kindle Fire | ||
* - Unknown | ||
* - iPad | ||
* - iPhone | ||
* - iPod | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `DeviceDetector` class and | ||
* related classes in the same file (see calls to `new UserAgentDevice` here: | ||
* https://fburl.com/50728332). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name" | ||
* @return {boolean} | ||
*/ | ||
isDevice(query) { | ||
return compare(UserAgentData.deviceName, null, query); | ||
}, | ||
/** | ||
* Check if the User Agent device matches `query`. | ||
* | ||
* `query` should be a string like "iPhone" or "iPad". | ||
* | ||
* Valid device names include: | ||
* | ||
* - Kindle | ||
* - Kindle Fire | ||
* - Unknown | ||
* - iPad | ||
* - iPhone | ||
* - iPod | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `DeviceDetector` class and | ||
* related classes in the same file (see calls to `new UserAgentDevice` here: | ||
* https://fburl.com/50728332). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name" | ||
* @return {boolean} | ||
*/ | ||
isDevice(query) { | ||
return compare(UserAgentData.deviceName, null, query); | ||
}, | ||
/** | ||
* Check if the User Agent rendering engine matches `query`. | ||
* | ||
* `query` should be a string like "WebKit" or "WebKit >= 537". | ||
* | ||
* Valid engine names include: | ||
* | ||
* - Gecko | ||
* - Presto | ||
* - Trident | ||
* - WebKit | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `RenderingEngineDetector` | ||
* class related classes in the same file (see calls to `new | ||
* UserAgentRenderingEngine` here: https://fburl.com/50728617). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name [range expression]" | ||
* @return {boolean} | ||
*/ | ||
isEngine(query) { | ||
return compare( | ||
UserAgentData.engineName, | ||
UserAgentData.engineVersion, | ||
query | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent rendering engine matches `query`. | ||
* | ||
* `query` should be a string like "WebKit" or "WebKit >= 537". | ||
* | ||
* Valid engine names include: | ||
* | ||
* - Gecko | ||
* - Presto | ||
* - Trident | ||
* - WebKit | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `RenderingEngineDetector` | ||
* class related classes in the same file (see calls to `new | ||
* UserAgentRenderingEngine` here: https://fburl.com/50728617). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name [range expression]" | ||
* @return {boolean} | ||
*/ | ||
isEngine(query) { | ||
return compare( | ||
UserAgentData.engineName, | ||
UserAgentData.engineVersion, | ||
query | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent platform matches `query`. | ||
* | ||
* `query` should be a string like "Windows" or "iOS 5 - 6". | ||
* | ||
* Valid platform names include: | ||
* | ||
* - Android | ||
* - BlackBerry OS | ||
* - Java ME | ||
* - Linux | ||
* - Mac OS X | ||
* - Mac OS X Calendar | ||
* - Mac OS X Internet Account | ||
* - Symbian | ||
* - SymbianOS | ||
* - Windows | ||
* - Windows Mobile | ||
* - Windows Phone | ||
* - iOS | ||
* - iOS Facebook Integration Account | ||
* - iOS Facebook Social Sharing UI | ||
* - webOS | ||
* - Chrome OS | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `PlatformDetector` class and | ||
* related classes in the same file (see calls to `new UserAgentPlatform` | ||
* here: https://fburl.com/50729226). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name [range expression]" | ||
* @return {boolean} | ||
*/ | ||
isPlatform(query) { | ||
return compare( | ||
UserAgentData.platformName, | ||
UserAgentData.platformFullVersion, | ||
query, | ||
normalizePlatformVersion | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent platform matches `query`. | ||
* | ||
* `query` should be a string like "Windows" or "iOS 5 - 6". | ||
* | ||
* Valid platform names include: | ||
* | ||
* - Android | ||
* - BlackBerry OS | ||
* - Java ME | ||
* - Linux | ||
* - Mac OS X | ||
* - Mac OS X Calendar | ||
* - Mac OS X Internet Account | ||
* - Symbian | ||
* - SymbianOS | ||
* - Windows | ||
* - Windows Mobile | ||
* - Windows Phone | ||
* - iOS | ||
* - iOS Facebook Integration Account | ||
* - iOS Facebook Social Sharing UI | ||
* - webOS | ||
* - Chrome OS | ||
* - etc... | ||
* | ||
* An authoritative list can be found in the PHP `PlatformDetector` class and | ||
* related classes in the same file (see calls to `new UserAgentPlatform` | ||
* here: https://fburl.com/50729226). | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "Name [range expression]" | ||
* @return {boolean} | ||
*/ | ||
isPlatform(query) { | ||
return compare( | ||
UserAgentData.platformName, | ||
UserAgentData.platformFullVersion, | ||
query, | ||
normalizePlatformVersion | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent platform is a 32 or 64 bit architecture. | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "32" or "64". | ||
* @return {boolean} | ||
*/ | ||
isPlatformArchitecture(query) { | ||
return compare( | ||
UserAgentData.platformArchitecture, | ||
null, | ||
query | ||
); | ||
}, | ||
/** | ||
* Check if the User Agent platform is a 32 or 64 bit architecture. | ||
* | ||
* @note Function results are memoized | ||
* | ||
* @param {string} query Query of the form "32" or "64". | ||
* @return {boolean} | ||
*/ | ||
isPlatformArchitecture(query) { | ||
return compare( | ||
UserAgentData.platformArchitecture, | ||
null, | ||
query | ||
); | ||
}, | ||
}; | ||
}; | ||
module.exports = mapObject(UserAgent, memoizeStringOnly); | ||
module.exports = mapObject(UserAgent, memoizeStringOnly); |
@@ -0,1 +1,5 @@ | ||
'use strict'; | ||
var Promise = require('../Promise'); | ||
/** | ||
@@ -8,2 +12,4 @@ * Copyright 2013-2015, Facebook, Inc. | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @noflow | ||
*/ | ||
@@ -10,0 +16,0 @@ |
@@ -0,1 +1,5 @@ | ||
'use strict'; | ||
var Promise = require('../Promise'); | ||
/** | ||
@@ -8,2 +12,4 @@ * Copyright 2013-2015, Facebook, Inc. | ||
* of patent rights can be found in the PATENTS file in the same directory. | ||
* | ||
* @noflow | ||
*/ | ||
@@ -10,0 +16,0 @@ |
@@ -17,11 +17,7 @@ /** | ||
* | ||
* The activeElement will be null only if the document or document body is not yet defined. | ||
* The activeElement will be null only if the document body is not yet defined. | ||
*/ | ||
'use strict'; | ||
"use strict"; | ||
function getActiveElement() /*?DOMElement*/{ | ||
if (typeof document === 'undefined') { | ||
return null; | ||
} | ||
try { | ||
@@ -28,0 +24,0 @@ return document.activeElement || document.body; |
@@ -16,4 +16,5 @@ /** | ||
var performance = require('./performance'); | ||
var curPerformance = performance; | ||
var performanceNow; | ||
/** | ||
@@ -24,8 +25,12 @@ * Detect if we can use `window.performance.now()` and gracefully fallback to | ||
*/ | ||
if (!curPerformance || !curPerformance.now) { | ||
curPerformance = Date; | ||
if (performance.now) { | ||
performanceNow = function () { | ||
return performance.now(); | ||
}; | ||
} else { | ||
performanceNow = function () { | ||
return Date.now(); | ||
}; | ||
} | ||
var performanceNow = curPerformance.now.bind(curPerformance); | ||
module.exports = performanceNow; |
{ | ||
"name": "fbjs", | ||
"version": "0.4.0", | ||
"version": "0.5.0", | ||
"description": "A collection of utility libraries used by other Facebook JS projects", | ||
@@ -23,7 +23,7 @@ "main": "index.js", | ||
"fbjs-scripts": "file:scripts", | ||
"flow-bin": "^0.16.0", | ||
"flow-bin": "^0.18.1", | ||
"gulp": "^3.9.0", | ||
"gulp-babel": "^5.1.0", | ||
"gulp-flatten": "^0.2.0", | ||
"jest-cli": "^0.5.0", | ||
"jest-cli": "^0.7.1", | ||
"merge-stream": "^1.0.0", | ||
@@ -30,0 +30,0 @@ "object-assign": "^4.0.1", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5610
194496
7