Skip to content

Commit db3a00d

Browse files
Kureev AlexeyFacebook Github Bot 3
authored andcommitted
Replace underscore by lodash
Summary:As far as we agreed to merge `rnpm` into react-native core, we need to align our dependencies to exclude duplications. One of the steps forward would be to use the same utilities library. According to the thread on fb, everybody is fine with replacing underscore by lodash (which we use internally for rnpm). So, here we go! cc mkonicek davidaurelio grabbou **Test plan** ``` $ npm test ``` ![image](https://cloud.githubusercontent.com/assets/2273613/13173972/ee34c922-d700-11e5-971b-68ff7322b6d6.png) **Code formatting** Changes are aligned with the current [style guide](https://github.com/facebook/react-native/blob/master/CONTRIBUTING.md#style-guide). Closes #6030 Differential Revision: D3016271 Pulled By: davidaurelio fb-gh-sync-id: c4f6776a7de7470283d3ca5a8b56e423247f5e45 shipit-source-id: c4f6776a7de7470283d3ca5a8b56e423247f5e45
1 parent f2483eb commit db3a00d

14 files changed

Lines changed: 82 additions & 85 deletions

File tree

local-cli/server/formatBanner.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
'use strict';
1010

11-
var _ = require('underscore');
11+
var _ = require('lodash');
1212
var wordwrap = require('wordwrap');
1313

1414
var HORIZONTAL_LINE = '\u2500';
@@ -45,7 +45,7 @@ var BOTTOM_RIGHT = '\u2518';
4545
function formatBanner(message, options) {
4646
options = options || {};
4747
_.defaults(options, {
48-
chalkFunction: _.identity,
48+
chalkFunction: (fn) => fn,
4949
width: 80,
5050
marginLeft: 0,
5151
marginRight: 0,
@@ -71,7 +71,7 @@ function formatBanner(message, options) {
7171

7272
var left = spaces(marginLeft) + VERTICAL_LINE + spaces(paddingLeft);
7373
var right = spaces(paddingRight) + VERTICAL_LINE + spaces(marginRight);
74-
var bodyLines = _.flatten([
74+
var bodyLines = _.flattenDeep([
7575
arrayOf('', paddingTop),
7676
body.split('\n'),
7777
arrayOf('', paddingBottom),
@@ -88,7 +88,7 @@ function formatBanner(message, options) {
8888
spaces(marginRight);
8989
var bottom = spaces(marginLeft) + BOTTOM_LEFT + horizontalBorderLine +
9090
BOTTOM_RIGHT + spaces(marginRight);
91-
return _.flatten([top, bodyLines, bottom]).join('\n');
91+
return _.flattenDeep([top, bodyLines, bottom]).join('\n');
9292
}
9393

9494
function spaces(number) {

npm-shrinkwrap.json

Lines changed: 54 additions & 59 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@
151151
"json-stable-stringify": "^1.0.1",
152152
"json5": "^0.4.0",
153153
"jstransform": "^11.0.3",
154+
"lodash": "^3.10.1",
154155
"mkdirp": "^0.5.1",
155156
"module-deps": "^3.9.1",
156157
"node-fetch": "^1.3.3",
@@ -169,7 +170,6 @@
169170
"stacktrace-parser": "^0.1.3",
170171
"temp": "0.8.3",
171172
"uglify-js": "^2.6.2",
172-
"underscore": "^1.8.3",
173173
"wordwrap": "^1.0.0",
174174
"worker-farm": "^1.3.1",
175175
"ws": "^0.8.0",

packager/react-packager/index.js

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ require('fast-path').replace();
1414
useGracefulFs();
1515

1616
var debug = require('debug');
17-
var omit = require('underscore').omit;
1817
var Activity = require('./src/Activity');
1918

2019
exports.createServer = createServer;
@@ -118,6 +117,16 @@ function createNonPersistentServer(options) {
118117
return createServer(options);
119118
}
120119

120+
function omit(obj, blacklistedKeys) {
121+
return Object.keys(obj).reduce((clone, key) => {
122+
if (blacklistedKeys.indexOf(key) === -1) {
123+
clone[key] = obj[key];
124+
}
125+
126+
return clone;
127+
}, {});
128+
}
129+
121130
// we need to listen on a socket as soon as a server is created, but only once.
122131
// This file also serves as entry point when spawning a socket server; in that
123132
// case we need to start the server immediately.

packager/react-packager/src/Bundler/Bundle.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*/
99
'use strict';
1010

11-
const _ = require('underscore');
11+
const _ = require('lodash');
1212
const base64VLQ = require('./base64-vlq');
1313
const BundleBase = require('./BundleBase');
1414
const ModuleTransport = require('../lib/ModuleTransport');
@@ -143,7 +143,7 @@ class Bundle extends BundleBase {
143143

144144
if (options.excludeSource) {
145145
if (map.sourcesContent && map.sourcesContent.length) {
146-
map = _.extend({}, map, {sourcesContent: []});
146+
map = Object.assign({}, map, {sourcesContent: []});
147147
}
148148
}
149149

0 commit comments

Comments
 (0)