🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

fbjs

Package Overview
Dependencies
Maintainers
8
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fbjs - npm Package Compare versions

Comparing version
0.6.1
to
0.7.0
+41
lib/_shouldPolyfillES6Collection.js
/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @preventMunge
*
*/
/**
* Checks whether a collection name (e.g. "Map" or "Set") has a native polyfill
* that is safe to be used.
*/
'use strict';
function shouldPolyfillES6Collection(collectionName) {
var Collection = global[collectionName];
if (Collection == null) {
return true;
}
// The iterator protocol depends on `Symbol.iterator`. If a collection is
// implemented, but `Symbol` is not, it's going to break iteration because
// we'll be using custom "@@iterator" instead, which is not implemented on
// native collections.
if (typeof global.Symbol !== 'function') {
return true;
}
var proto = Collection.prototype;
// These checks are adapted from es6-shim: https://fburl.com/34437854
// NOTE: `isCallableWithoutNew` and `!supportsSubclassing` are not checked
// because they make debugging with "break on exceptions" difficult.
return Collection == null || typeof Collection !== 'function' || typeof proto.clear !== 'function' || new Collection().size !== 0 || typeof proto.keys !== 'function' || typeof proto.forEach !== 'function';
}
module.exports = shouldPolyfillES6Collection;

Sorry, the diff of this file is not supported yet

/**
*
* Copyright 2013-2016 Facebook, Inc.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* This module wraps and augments the minimally ES6-compliant Promise
* implementation provided by the promise npm package.
*
*/
'use strict';
var Promise = require('promise/setimmediate/es6-extensions');
require('promise/setimmediate/done');
if (process.env.NODE_ENV !== 'production') {
require('./promise/setimmediate/rejection-tracking').enable({
allRejections: true,
onUnhandled: function (id, error) {
var message = error.message;
var stack = error.stack;
var warning = 'Possible Unhandled Promise Rejection (id: ' + id + '):\n' + (message == null ? '' : message + '\n') + (stack == null ? '' : stack);
console.warn(warning);
},
onHandled: function (id) {
var warning = 'Promise Rejection Handled (id: ' + id + ')\n' + 'This means you can ignore any previous messages of the form ' + ('"Possible Unhandled Promise Rejection (id: ' + id + '):"');
console.warn(warning);
}
});
}
/**
* Handle either fulfillment or rejection with the same callback.
*/
Promise.prototype['finally'] = function (onSettled) {
return this.then(onSettled, onSettled);
};
module.exports = Promise;

Sorry, the diff of this file is not supported yet

+14
-0
## [Unreleased]
## [0.7.0] - 2016-01-27
### Added
- `Promise` for React Native with rejection tracking in `__DEV__` and a `finally` method
- `_shouldPolyfillES6Collection`: check if ES6 Collections need to be polyfilled.
### Removed
- `toArray`: removed in favor of using `Array.from` directly.
### Changed
- `ErrorUtils`: Re-uses any global instance that already exists
- `fetch`: Switched to `isomorphic-fetch` when a global implementation is missing
- `shallowEqual`: handles `NaN` values appropriately (as equal), now using `Object.is` semantics
## [0.6.1] - 2016-01-06

@@ -4,0 +18,0 @@

+0
-1

@@ -9,3 +9,2 @@ /**

*
* @providesModule areEqual
*

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule base62
*

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule camelize
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule camelizeStyleName
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule containsNode
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule crc32
*

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule createArrayFromMixed
* @typechecks

@@ -16,5 +15,47 @@ */

var toArray = require('./toArray');
var invariant = require('./invariant');
/**
* Convert array-like objects to arrays.
*
* This API assumes the caller knows the contents of the data type. For less
* well defined inputs use createArrayFromMixed.
*
* @param {object|function|filelist} obj
* @return {array}
*/
function toArray(obj) {
var length = obj.length;
// Some browsers builtin objects can report typeof 'function' (e.g. NodeList
// in old versions of Safari).
!(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : undefined;
!(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : undefined;
!(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : undefined;
!(typeof obj.callee !== 'function') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object can\'t be `arguments`. Use rest params ' + '(function(...args) {}) or Array.from() instead.') : invariant(false) : undefined;
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
// without method will throw during the slice call and skip straight to the
// fallback.
if (obj.hasOwnProperty) {
try {
return Array.prototype.slice.call(obj);
} catch (e) {
// IE < 9 does not support Array#slice on collections objects
}
}
// Fall back to copying key by key. This assumes all keys have a value,
// so will not preserve sparsely populated inputs.
var ret = Array(length);
for (var ii = 0; ii < length; ii++) {
ret[ii] = obj[ii];
}
return ret;
}
/**
* Perform a heuristic test to determine if an object is "array-like".

@@ -21,0 +62,0 @@ *

@@ -9,3 +9,2 @@ /**

*
* @providesModule createNodesFromMarkup
* @typechecks

@@ -78,3 +77,3 @@ */

var nodes = createArrayFromMixed(node.childNodes);
var nodes = Array.from(node.childNodes);
while (node.lastChild) {

@@ -81,0 +80,0 @@ node.removeChild(node.lastChild);

@@ -9,3 +9,2 @@ /**

*
* @providesModule CSSCore
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -0,1 +1,7 @@

"use strict";
var Promise = require("./Promise");
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
/**

@@ -9,3 +15,2 @@ * Copyright 2013-2015, Facebook, Inc.

*
* @providesModule Deferred
* @typechecks

@@ -15,8 +20,2 @@ *

'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var Promise = require('./Promise');
/**

@@ -23,0 +22,0 @@ * Deferred provides a Promise-like API that exposes methods to resolve and

@@ -9,3 +9,2 @@ /**

*
* @providesModule emptyFunction
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule emptyObject
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule ErrorUtils
*/

@@ -17,11 +16,15 @@

var ErrorUtils = {
applyWithGuard: function (callback, context, args, onError, name) {
return callback.apply(context, args);
},
guard: function (callback, name) {
return callback;
}
};
if (global.ErrorUtils) {
module.exports = global.ErrorUtils;
} else {
var ErrorUtils = {
applyWithGuard: function (callback, context, args, onError, name) {
return callback.apply(context, args);
},
guard: function (callback, name) {
return callback;
}
};
module.exports = ErrorUtils;
module.exports = ErrorUtils;
}

@@ -16,3 +16,2 @@ /**

*
* @providesModule EventListener
* @typechecks

@@ -19,0 +18,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule everyObject
*

@@ -12,0 +11,0 @@ * @typechecks

@@ -9,3 +9,2 @@ /**

*
* @providesModule ExecutionEnvironment
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule fetch
*/

@@ -15,3 +14,9 @@

require('whatwg-fetch');
module.exports = self.fetch.bind(self);
// This hopefully supports the React Native case, which is already bringing along
// its own fetch polyfill. That should exist on `global`. If that doesn't exist
// then we'll try to polyfill, which might not work correctly in all environments.
if (global.fetch) {
module.exports = global.fetch.bind(global);
} else {
module.exports = require('isomorphic-fetch');
}

@@ -0,1 +1,11 @@

'use strict';
Object.defineProperty(exports, '__esModule', {
value: true
});
var Promise = require('./Promise');
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
/**

@@ -9,3 +19,2 @@ * Copyright 2013-2015, Facebook, Inc.

*
* @providesModule fetchWithRetries
* @typechecks

@@ -17,10 +26,3 @@ *

Object.defineProperty(exports, '__esModule', {
value: true
});
function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }
var ExecutionEnvironment = require('./ExecutionEnvironment');
var Promise = require('./Promise');

@@ -27,0 +29,0 @@ var sprintf = require('./sprintf');

@@ -9,3 +9,2 @@ /**

*
* @providesModule filterObject
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule flattenArray
* @typechecks

@@ -12,0 +11,0 @@ *

@@ -9,3 +9,2 @@ /**

*
* @providesModule focusNode
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule forEachObject
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule getActiveElement
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule getMarkupWrap
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule getUnboundedScrollPosition
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule hyphenate
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule hyphenateStyleName
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule invariant
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule isEmpty
*/

@@ -15,8 +14,12 @@

'use strict';
var invariant = require('./invariant');
/**
* Mimics empty from PHP.
*/
'use strict';
function isEmpty(obj) {
!!(obj && obj[Symbol.iterator] && obj.size !== undefined) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'isEmpty does not support Map or Set') : invariant(false) : undefined;
function isEmpty(obj) {
if (Array.isArray(obj)) {

@@ -23,0 +26,0 @@ return obj.length === 0;

@@ -9,3 +9,2 @@ /**

*
* @providesModule isNode
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule isTextNode
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule joinClasses
* @typechecks static-only

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule keyMirror
* @typechecks static-only

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule keyOf
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule Map
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule mapObject
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule memoizeStringOnly
* @typechecks static-only

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule monitorCodeUse
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule nativeRequestAnimationFrame
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule nullthrows
*

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule performance
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule performanceNow
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule Promise
*/

@@ -12,0 +11,0 @@

@@ -0,1 +1,7 @@

'use strict';
var Promise = require('./Promise');
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
/**

@@ -9,6 +15,11 @@ * Copyright 2013-2015, Facebook, Inc.

*
* @providesModule PromiseMap
*
*/
'use strict';
var Deferred = require('./Deferred');
var invariant = require('./invariant');
/**

@@ -19,10 +30,3 @@ * A map of asynchronous values that can be get or set in any order. Unlike a

*/
'use strict';
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError('Cannot call a class as a function'); } }
var Deferred = require('./Deferred');
var invariant = require('./invariant');
var PromiseMap = (function () {

@@ -29,0 +33,0 @@ function PromiseMap() {

@@ -9,3 +9,2 @@ /**

*
* @providesModule removeFromArray
* @typechecks

@@ -12,0 +11,0 @@ *

@@ -9,3 +9,2 @@ /**

*
* @providesModule requestAnimationFrame
*/

@@ -12,0 +11,0 @@

@@ -0,1 +1,5 @@

"use strict";
var Promise = require("./Promise");
/**

@@ -9,10 +13,5 @@ * Copyright 2013-2015, Facebook, Inc.

*
* @providesModule resolveImmediate
*
*/
'use strict';
var Promise = require('./Promise');
var resolvedPromise = Promise.resolve();

@@ -24,3 +23,3 @@

function resolveImmediate(callback) {
resolvedPromise.then(callback)['catch'](throwNext);
resolvedPromise.then(callback)["catch"](throwNext);
}

@@ -27,0 +26,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule shallowEqual
* @typechecks

@@ -15,2 +14,4 @@ *

/*eslint-disable no-self-compare */
'use strict';

@@ -21,2 +22,18 @@

/**
* inlined Object.is polyfill to avoid requiring consumers ship their own
* https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
*/
function is(x, y) {
// SameValue algorithm
if (x === y) {
// Steps 1-5, 7-10
// Steps 6.b-6.e: +0 != -0
return x !== 0 || 1 / x === 1 / y;
} else {
// Step 6.a: NaN == NaN
return x !== x && y !== y;
}
}
/**
* Performs equality by iterating through keys on an object and returning false

@@ -27,3 +44,3 @@ * when any key has values which are not strictly equal between the arguments.

function shallowEqual(objA, objB) {
if (objA === objB) {
if (is(objA, objB)) {
return true;

@@ -44,5 +61,4 @@ }

// Test for A's keys different from B.
var bHasOwnProperty = hasOwnProperty.bind(objB);
for (var i = 0; i < keysA.length; i++) {
if (!bHasOwnProperty(keysA[i]) || objA[keysA[i]] !== objB[keysA[i]]) {
if (!hasOwnProperty.call(objB, keysA[i]) || !is(objA[keysA[i]], objB[keysA[i]])) {
return false;

@@ -49,0 +65,0 @@ }

@@ -9,3 +9,2 @@ /**

*
* @providesModule someObject
*

@@ -12,0 +11,0 @@ * @typechecks

@@ -9,3 +9,2 @@ /**

*
* @providesModule sprintf
* @typechecks

@@ -12,0 +11,0 @@ */

@@ -9,3 +9,2 @@ /**

*
* @providesModule TouchEventUtils
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule URI
* @typechecks

@@ -12,0 +11,0 @@ *

@@ -9,3 +9,2 @@ /**

*
* @providesModule UserAgent
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule UserAgentData
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule VersionRange
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule warning
*/

@@ -12,0 +11,0 @@

@@ -9,3 +9,2 @@ /**

*
* @providesModule xhrSimpleDataSerializer
*/

@@ -12,0 +11,0 @@

@@ -15,2 +15,3 @@ {

"VersionRange": "fbjs/lib/VersionRange",
"_shouldPolyfillES6Collection": "fbjs/lib/_shouldPolyfillES6Collection",
"areEqual": "fbjs/lib/areEqual",

@@ -58,5 +59,4 @@ "base62": "fbjs/lib/base62",

"sprintf": "fbjs/lib/sprintf",
"toArray": "fbjs/lib/toArray",
"warning": "fbjs/lib/warning",
"xhrSimpleDataSerializer": "fbjs/lib/xhrSimpleDataSerializer"
}
{
"name": "fbjs",
"version": "0.6.1",
"version": "0.7.0",
"description": "A collection of utility libraries used by other Facebook JS projects",

@@ -13,2 +13,3 @@ "main": "index.js",

"test": "NODE_ENV=test jest",
"test-scripts": "cd scripts && npm install && npm test",
"typecheck": "flow check src"

@@ -24,3 +25,3 @@ },

"fbjs-scripts": "file:scripts",
"flow-bin": "^0.18.1",
"flow-bin": "^0.20.1",
"gulp": "^3.9.0",

@@ -30,3 +31,3 @@ "gulp-babel": "^5.1.0",

"gulp-rename": "^1.2.2",
"jest-cli": "^0.7.1",
"jest-cli": "^0.8.2",
"merge-stream": "^1.0.0",

@@ -60,2 +61,3 @@ "object-assign": "^4.0.1",

],
"testRunner": "node_modules/jest-cli/src/testRunners/jasmine/jasmine2.js",
"unmockedModulePathPatterns": [

@@ -69,9 +71,9 @@ "<rootDir>/node_modules/",

"loose-envify": "^1.0.0",
"promise": "^7.0.3",
"ua-parser-js": "^0.7.9",
"whatwg-fetch": "^0.9.0"
"isomorphic-fetch": "^2.1.1",
"promise": "^7.1.1",
"ua-parser-js": "^0.7.9"
},
"devEngines": {
"node": ">=3",
"npm": "2.x"
"npm": ">=2.x"
},

@@ -78,0 +80,0 @@ "browserify": {

/**
* Copyright 2013-2015, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
* @providesModule toArray
* @typechecks
*/
'use strict';
var invariant = require('./invariant');
/**
* Convert array-like objects to arrays.
*
* This API assumes the caller knows the contents of the data type. For less
* well defined inputs use createArrayFromMixed.
*
* @param {object|function|filelist} obj
* @return {array}
*/
function toArray(obj) {
var length = obj.length;
// Some browse builtin objects can report typeof 'function' (e.g. NodeList in
// old versions of Safari).
!(!Array.isArray(obj) && (typeof obj === 'object' || typeof obj === 'function')) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Array-like object expected') : invariant(false) : undefined;
!(typeof length === 'number') ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object needs a length property') : invariant(false) : undefined;
!(length === 0 || length - 1 in obj) ? process.env.NODE_ENV !== 'production' ? invariant(false, 'toArray: Object should have keys for indices') : invariant(false) : undefined;
// Old IE doesn't give collections access to hasOwnProperty. Assume inputs
// without method will throw during the slice call and skip straight to the
// fallback.
if (obj.hasOwnProperty) {
try {
return Array.prototype.slice.call(obj);
} catch (e) {
// IE < 9 does not support Array#slice on collections objects
}
}
// Fall back to copying key by key. This assumes all keys have a value,
// so will not preserve sparsely populated inputs.
var ret = Array(length);
for (var ii = 0; ii < length; ii++) {
ret[ii] = obj[ii];
}
return ret;
}
module.exports = toArray;

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet