Remove more upstream modules that aren't used
Immutable* hasn't been used... ever? copyProperties, merge were deprecated as part of 0.12. We've replaced them with Object.assign.
Paul O’Shannessy committed
Feb 6, 2015 at 09:54 UTC
3525d01b9b9e0e635fd1a76777abf510ee64275a
6 files changed
-393
src/vendor/immutable/Immutable.js
deleted
-125
@@ -1,125 +0,0 @@
1
-/**
2
- * Copyright 2013-2015, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule Immutable
10
- */
11
-
12
-var assign = require('Object.assign');
13
-var invariant = require('invariant');
14
-var isNode = require('isNode');
15
-var keyOf = require('keyOf');
16
-
17
-var SECRET_KEY = keyOf({_DONT_EVER_TYPE_THIS_SECRET_KEY: null});
18
-
19
-/**
20
- * `Immutable` provides a guarantee of immutability at developer time when
21
- * strict mode is used. The extra computations required to enforce immutability
22
- * are stripped out in production for performance reasons. `Immutable`
23
- * guarantees to enforce immutability for enumerable, own properties. This
24
- * allows easy wrapping of `Immutable` with the ability to store non-enumerable
25
- * properties on the instance that only your static methods reason about. In
26
- * order to achieve IE8 compatibility (which doesn't have the ability to define
27
- * non-enumerable properties), modules that want to build their own reasoning
28
- * of `Immutable`s and store computations can define their non-enumerable
29
- * properties under the name `toString`, and in IE8 only define a standard
30
- * property called `toString` which will mistakenly be considered not
31
- * enumerable due to its name (but only in IE8). The only limitation is that no
32
- * one can store their own `toString` property.
33
- * https://developer.mozilla.org/en-US/docs/ECMAScript_DontEnum_attribute#JScript_DontEnum_Bug
34
- */
35
-class Immutable {
36
- /**
37
- * An instance of `Immutable` appears to be a plain JavaScript object, except
38
- * `instanceof Immutable` evaluates to `true`, and it is deeply frozen in
39
- * development mode.
40
- *
41
- * @param {number} secret Ensures this isn't accidentally constructed outside
42
- * of convenience constructors. If created outside of a convenience
43
- * constructor, may not be frozen. Forbidding that use case for now until we
44
- * have a better API.
45
- */
46
- constructor(secret) {
47
- invariant(
48
- secret === Immutable[SECRET_KEY],
49
- 'Only certain classes should create instances of `Immutable`.' +
50
- 'You probably want something like ImmutableObject.create.'
51
- );
52
- }
53
-
54
- /**
55
- * Helper method for classes that make use of `Immutable`.
56
- * @param {Immutable} immutable Object to merge properties into.
57
- * @param {array<object>} propertyObjects List of objects to merge into
58
- * `destination`.
59
- */
60
- static mergeAllPropertiesInto(destination, propertyObjects) {
61
- var argLength = propertyObjects.length;
62
- for (var i = 0; i < argLength; i++) {
63
- assign(destination, propertyObjects[i]);
64
- }
65
- }
66
-
67
-
68
- /**
69
- * Freezes the supplied object deeply. Other classes may implement their own
70
- * version based on this.
71
- *
72
- * @param {*} object The object to freeze.
73
- */
74
- static deepFreezeRootNode(object) {
75
- if (isNode(object)) {
76
- return; // Don't try to freeze DOM nodes.
77
- }
78
- Object.freeze(object); // First freeze the object.
79
- for (var prop in object) {
80
- if (object.hasOwnProperty(prop)) {
81
- Immutable.recurseDeepFreeze(object[prop]);
82
- }
83
- }
84
- Object.seal(object);
85
- }
86
-
87
- /**
88
- * Differs from `deepFreezeRootNode`, in that we first check if this is a
89
- * necessary recursion. If the object is already an `Immutable`, then the
90
- * recursion is unnecessary as it is already frozen. That check obviously
91
- * wouldn't work for the root node version `deepFreezeRootNode`!
92
- */
93
- static recurseDeepFreeze(object) {
94
- if (isNode(object) || !Immutable.shouldRecurseFreeze(object)) {
95
- return; // Don't try to freeze DOM nodes.
96
- }
97
- Object.freeze(object); // First freeze the object.
98
- for (var prop in object) {
99
- if (object.hasOwnProperty(prop)) {
100
- Immutable.recurseDeepFreeze(object[prop]);
101
- }
102
- }
103
- Object.seal(object);
104
- }
105
-
106
- /**
107
- * Checks if an object should be deep frozen. Instances of `Immutable` are
108
- * assumed to have already been deep frozen, so we can have large `__DEV__`
109
- * time savings by skipping freezing of them.
110
- *
111
- * @param {*} object The object to check.
112
- * @return {boolean} Whether or not deep freeze is needed.
113
- */
114
- static shouldRecurseFreeze(object) {
115
- return (
116
- typeof object === 'object' &&
117
- !(object instanceof Immutable) &&
118
- object !== null
119
- );
120
- }
121
-}
122
-
123
-Immutable._DONT_EVER_TYPE_THIS_SECRET_KEY = Math.random();
124
-
125
-module.exports = Immutable;
src/vendor/immutable/ImmutableObject.js
deleted
-151
@@ -1,151 +0,0 @@
1
-/**
2
- * Copyright 2013-2015, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule ImmutableObject
10
- */
11
-
12
-"use strict";
13
-
14
-var Immutable = require('Immutable');
15
-
16
-var invariant = require('invariant');
17
-var keyOf = require('keyOf');
18
-var mergeHelpers = require('mergeHelpers');
19
-
20
-var checkMergeObjectArgs = mergeHelpers.checkMergeObjectArgs;
21
-var isTerminal = mergeHelpers.isTerminal;
22
-
23
-var SECRET_KEY = keyOf({_DONT_EVER_TYPE_THIS_SECRET_KEY: null});
24
-
25
-/**
26
- * Static methods creating and operating on instances of `Immutable`.
27
- */
28
-function assertImmutable(immutable) {
29
- invariant(
30
- immutable instanceof Immutable,
31
- 'ImmutableObject: Attempted to set fields on an object that is not an ' +
32
- 'instance of Immutable.'
33
- );
34
-}
35
-
36
-/**
37
- * Static methods for reasoning about instances of `ImmutableObject`. Execute
38
- * the freeze commands in `__DEV__` mode to alert the programmer that something
39
- * is attempting to mutate. Since freezing is very expensive, we avoid doing it
40
- * at all in production.
41
- */
42
-class ImmutableObject extends Immutable {
43
- /**
44
- * @arguments {array<object>} The arguments is an array of objects that, when
45
- * merged together, will form the immutable objects.
46
- */
47
- constructor() {
48
- super(Immutable[SECRET_KEY]);
49
- Immutable.mergeAllPropertiesInto(this, arguments);
50
- if (__DEV__) {
51
- Immutable.deepFreezeRootNode(this);
52
- }
53
- }
54
-
55
- /**
56
- * DEPRECATED - prefer to instantiate with new ImmutableObject().
57
- *
58
- * @arguments {array<object>} The arguments is an array of objects that, when
59
- * merged together, will form the immutable objects.
60
- */
61
- static create() {
62
- var obj = Object.create(ImmutableObject.prototype);
63
- ImmutableObject.apply(obj, arguments);
64
- return obj;
65
- }
66
-
67
- /**
68
- * Returns a new `Immutable` that is identical to the supplied `Immutable`
69
- * but with the specified changes, `put`. Any keys that are in the
70
- * intersection of `immutable` and `put` retain the ordering of `immutable.
71
- * New keys are placed after keys that exist in `immutable`.
72
- *
73
- * @param {Immutable} immutable Starting object.
74
- * @param {?object} put Fields to merge into the object.
75
- * @return {Immutable} The result of merging in `put` fields.
76
- */
77
- static set(immutable, put) {
78
- assertImmutable(immutable);
79
- invariant(
80
- typeof put === 'object' && put !== undefined && !Array.isArray(put),
81
- 'Invalid ImmutableMap.set argument `put`'
82
- );
83
- return new ImmutableObject(immutable, put);
84
- }
85
-
86
- /**
87
- * Sugar for `ImmutableObject.set(ImmutableObject, {fieldName: putField})`.
88
- * Look out for key crushing: Use `keyOf()` to guard against it.
89
- *
90
- * @param {Immutable} immutable Object on which to set properties.
91
- * @param {string} fieldName Name of the field to set.
92
- * @param {*} putField Value of the field to set.
93
- * @return {Immutable} new Immutable as described in `set`.
94
- */
95
- static setProperty(immutableObject, fieldName, putField) {
96
- var put = {};
97
- put[fieldName] = putField;
98
- return ImmutableObject.set(immutableObject, put);
99
- }
100
-
101
- /**
102
- * Returns a new `Immutable` that is identical to the supplied object but
103
- * with the supplied changes recursively applied.
104
- *
105
- * Experimental. Likely does not handle `Arrays` correctly.
106
- *
107
- * @param {Immutable} immutable Object on which to set fields.
108
- * @param {object} put Fields to merge into the object.
109
- * @return {Immutable} The result of merging in `put` fields.
110
- */
111
- static setDeep(immutable, put) {
112
- assertImmutable(immutable);
113
- return _setDeep(immutable, put);
114
- }
115
-}
116
-
117
-function _setDeep(obj, put) {
118
- checkMergeObjectArgs(obj, put);
119
- var totalNewFields = {};
120
-
121
- // To maintain the order of the keys, copy the base object's entries first.
122
- var keys = Object.keys(obj);
123
- for (var ii = 0; ii < keys.length; ii++) {
124
- var key = keys[ii];
125
- if (!put.hasOwnProperty(key)) {
126
- totalNewFields[key] = obj[key];
127
- } else if (isTerminal(obj[key]) || isTerminal(put[key])) {
128
- totalNewFields[key] = put[key];
129
- } else {
130
- totalNewFields[key] = _setDeep(obj[key], put[key]);
131
- }
132
- }
133
-
134
- // Apply any new keys that the base obj didn't have.
135
- var newKeys = Object.keys(put);
136
- for (ii = 0; ii < newKeys.length; ii++) {
137
- var newKey = newKeys[ii];
138
- if (obj.hasOwnProperty(newKey)) {
139
- continue;
140
- }
141
- totalNewFields[newKey] = put[newKey];
142
- }
143
-
144
- return (
145
- obj instanceof Immutable ? new ImmutableObject(totalNewFields) :
146
- put instanceof Immutable ? new ImmutableObject(totalNewFields) :
147
- totalNewFields
148
- );
149
-}
150
-
151
-module.exports = ImmutableObject;
src/vendor_deprecated/README.md
deleted
-3
@@ -1,3 +0,0 @@
1
-The files in this directory are modified from their original implementation. At some point the files here were included in the React package shipped to npm and used by other projects.
2
-
3
-We removed all uses of these files inside React itself but would like to provide a sane deprecation notice for other consumers. We made no promises about the files here; they were always "use at your own risk".
src/vendor_deprecated/core/copyProperties.js
deleted
-56
@@ -1,56 +0,0 @@
1
-/**
2
- * Copyright 2013-2015, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule copyProperties
10
- */
11
-
12
-"use strict";
13
-
14
-/**
15
- * Copy properties from one or more objects (up to 5) into the first object.
16
- * This is a shallow copy. It mutates the first object and also returns it.
17
- *
18
- * NOTE: `arguments` has a very significant performance penalty, which is why
19
- * we don't support unlimited arguments.
20
- */
21
-function copyProperties(obj, a, b, c, d, e, f) {
22
- obj = obj || {};
23
-
24
- if (__DEV__) {
25
- if (f) {
26
- throw new Error('Too many arguments passed to copyProperties');
27
- }
28
- }
29
-
30
- var args = [a, b, c, d, e];
31
- var ii = 0, v;
32
- while (args[ii]) {
33
- v = args[ii++];
34
- for (var k in v) {
35
- obj[k] = v[k];
36
- }
37
-
38
- // IE ignores toString in object iteration.. See:
39
- // webreflection.blogspot.com/2007/07/quick-fix-internet-explorer-and.html
40
- if (v.hasOwnProperty && v.hasOwnProperty('toString') &&
41
- (typeof v.toString != 'undefined') && (obj.toString !== v.toString)) {
42
- obj.toString = v.toString;
43
- }
44
- }
45
-
46
- return obj;
47
-}
48
-
49
-module.exports = copyProperties;
50
-
51
-// deprecation notice
52
-console.warn(
53
- 'react/lib/copyProperties has been deprecated and will be removed in the ' +
54
- 'next version of React. All uses can be replaced with ' +
55
- 'Object.assign(obj, a, b, ...) or _.extend(obj, a, b, ...).'
56
-);
src/vendor_deprecated/core/merge.js
deleted
-34
@@ -1,34 +0,0 @@
1
-/**
2
- * Copyright 2013-2015, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule merge
10
- */
11
-
12
-"use strict";
13
-
14
-var assign = require('Object.assign');
15
-
16
-/**
17
- * Shallow merges two structures into a return value, without mutating either.
18
- *
19
- * @param {?object} one Optional object with properties to merge from.
20
- * @param {?object} two Optional object with properties to merge from.
21
- * @return {object} The shallow extension of one by two.
22
- */
23
-var merge = function(one, two) {
24
- return assign({}, one, two);
25
-};
26
-
27
-module.exports = merge;
28
-
29
-// deprecation notice
30
-console.warn(
31
- 'react/lib/merge has been deprecated and will be removed in the ' +
32
- 'next version of React. All uses can be replaced with ' +
33
- 'Object.assign({}, a, b) or _.extend({}, a, b).'
34
-);
src/vendor_deprecated/core/mergeInto.js
deleted
-24
@@ -1,24 +0,0 @@
1
-/**
2
- * Copyright 2013-2015, Facebook, Inc.
3
- * All rights reserved.
4
- *
5
- * This source code is licensed under the BSD-style license found in the
6
- * LICENSE file in the root directory of this source tree. An additional grant
7
- * of patent rights can be found in the PATENTS file in the same directory.
8
- *
9
- * @providesModule mergeInto
10
- * @typechecks static-only
11
- */
12
-
13
-"use strict";
14
-
15
-var assign = require('Object.assign');
16
-
17
-module.exports = assign;
18
-
19
-// deprecation notice
20
-console.warn(
21
- 'react/lib/mergeInto has been deprecated and will be removed in the ' +
22
- 'next version of React. All uses can be replaced with ' +
23
- 'Object.assign(a, b, c, ...) or _.extend(a, b, c, ...).'
24
-);